Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointPrimitive and PointPrimitiveCollection #2632

Merged
merged 38 commits into from
May 5, 2015
Merged

PointPrimitive and PointPrimitiveCollection #2632

merged 38 commits into from
May 5, 2015

Conversation

emackey
Copy link
Contributor

@emackey emackey commented Apr 13, 2015

This PR adds two new classes PointPrimitive and PointPrimitiveCollection. It does not make any changes to the Entity.point API, however the back end of Entity.point is now connected to the new PointPrimitive system instead of billboards. This means that existing Entity and CZML points will automatically make use of the new system, with no changes.

PointPrimitive and its collection are similar to Billboard and its collection, with the following differences:

  • PointPrimitive uses glPointSize instead of textured quads (for 1/4th the vertices and no indicies).
  • PointPrimitive does not have any image or texture atlas system at all.
  • PointPrimitive does not support EyeOffset, PixelOffset, or PixelOffsetScaleByDistance.
  • PointPrimitive directly supports concepts from Entity.point, such as outline color/width.
  • PointPrimitiveCollection uses a single draw call, as opposed to BillboardCollection's 16k billboards per draw due to 16-bit indicies (64k verts per draw, at 4 verts per billboard).
  • PointPrimitiveCollection does not suffer from a scale value being mismatched with a raster image of a circle of the wrong size.
  • The point's edges and outlines are visually clearer.

That last claim is perhaps subjective, so I'll attach some screenshots of a CZML file from SatelliteViewer. Here it is in master, with Billboards, followed by the same with PointPrimitives from this PR:

points2viabillboards

points2viaprimitives

Additional performance testing of this branch is most welcome. The biggest gains seen thus far are mostly in the creation of points, although the rendering does appear to yield a small percentage gain in FPS as well.

Here is a Gist of a Sandcastle demo that will create arbitrary numbers of PointPrimitives or Billboards, based on a number and a flag at the top of the file. Generally I find that creating PointPrimitives is an order of magnitude or so faster than creating the same number of Billboards. My machine will crash a Chrome tab if I ask for more than about 400k Billboards, but will let me render about 800k PointPrimitives at the high end.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 13, 2015 via email

@emackey
Copy link
Contributor Author

emackey commented Apr 13, 2015

No rush. This is large and changes existing behavior, so it needs thorough review.

pointPrimitive.color = Property.getValueOrDefault(pointGraphics._color, time, defaultColor, color);
pointPrimitive.outlineColor = Property.getValueOrDefault(pointGraphics._outlineColor, time, defaultOutlineColor, outlineColor);
pointPrimitive.outlineWidth = Property.getValueOrDefault(pointGraphics._outlineWidth, time, defaultOutlineWidth);
pointPrimitive.pixelSize = Property.getValueOrDefault(pointGraphics._pixelSize, time, defaultPixelSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to add a scene.clampPointSize similar to scene.clampLineWidth to avoid assigning a size the card/drivers don't support. I also assume all cards have fairly large maximums?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I've added this to the vertex shader, where in the most recent version this takes place after outline width and scale-by-distance effects have been included in the total glPointSize.

The typical size limits are shown on the very bottom chart on webglstats.com. Looks like the availability of extra-large (1023px) points has grown substantially in just the past year. Typical CZML point size real-world uses are far below 63 pixels, so they read as above 99% availability on this chart.

@mramato
Copy link
Contributor

mramato commented Apr 14, 2015

The point's edges and outlines are visually clearer.

Just an FYI, the main reason for the visual difference is #2130, once that is fixed, the points should look equally good in both cases (though this will probably be in master before then, so the point is moot).

@emackey
Copy link
Contributor Author

emackey commented Apr 14, 2015

Another demo: 1 million pointPrimitives scaled by distance. Give it time to load, and keep an eye on the Sandcastle console tab.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 22, 2015

just a heads up that I won't be able to until next week.

Sorry @emackey, it will be this weekend, really.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 24, 2015

PointPrimitiveCollection uses a single draw call, as opposed to BillboardCollection's 16k billboards per draw due to 16-bit indicies (64k verts per draw, at 4 verts per billboard).

The billboard collection could also use a single draw call. I actually wrote it so long ago that OES_element_index_uint was not available. Pull request welcome. :) #797

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 24, 2015

@emackey did you run code coverage? What is it? I'm on Mac.

'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/Color',
'../Core/createGuid',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 28, 2015

If we want this to make 1.9, I would want to merge it by Wednesday. 1.10 would also be fine for this.

@emackey
Copy link
Contributor Author

emackey commented May 4, 2015

This has 1.9 merged into it now, and is ready to go.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 4, 2015

I added point/terrain clamping to #2685.

varying vec4 v_pickColor;
#endif

float getNearFarScalar(vec4 nearFarScalar, float cameraDistSq)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this a czm_ function that is shared with billboards and has a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Is there any way to unit test a czm function directly? I don't see tests for any of the other czm_ functions. PointPrimitiveCollectionSpec does contain tests for scaleByDistance and translucencyByDistance which will make use of this once it's shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate question, is there any way to build documentation that includes czm?

@pjcozzi
Copy link
Contributor

pjcozzi commented May 4, 2015

@emackey what is test coverage for PointPrimitive and PointPrimitiveCollection? I imagine they are high.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 4, 2015

That's all I got. This looks good otherwise. Thanks for all the work, @emackey.

@emackey
Copy link
Contributor Author

emackey commented May 5, 2015

Test coverage is fairly complete, actually I just found and fixed a hole in PointPrimitiveCollection and the corresponding holes in BillboardCollection. There are some untested "required parameter" debug statements, and both collections lack testing for computing screen space positions during the middle of a morph sequence (there's no right answer there).

@emackey
Copy link
Contributor Author

emackey commented May 5, 2015

As far as I can tell, we have tests for Automatic Uniforms, but no tests for Shaders/Builtin/Functions. I searched for several existing functions like czm_getSpecular and got no hits from the Specs folder.

The functionality of the new czm_nearFarScalar is tested, for both rendering and picking, by several different tests in different collections.

This is ready.

@bagnell
Copy link
Contributor

bagnell commented May 5, 2015

We don't have tests for all of the builtin functions, but the ones we do have can be found in BuiltinFunctionsSpec.js

@emackey
Copy link
Contributor Author

emackey commented May 5, 2015

Thanks @bagnell. Test added. Ready.

@pjcozzi
Copy link
Contributor

pjcozzi commented May 5, 2015

Looks great, thanks again @emackey.

pjcozzi added a commit that referenced this pull request May 5, 2015
PointPrimitive and PointPrimitiveCollection
@pjcozzi pjcozzi merged commit 96d432f into master May 5, 2015
@pjcozzi pjcozzi deleted the point-primitive branch May 5, 2015 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants