-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Simple point cloud attenuation #5824
Conversation
d8dc16f
to
629e8c1
Compare
scratchPointSizeAndTilesetTime.x = content._pointSize; | ||
scratchPointSizeAndTilesetTime.y = content._tileset.timeSinceLoad; | ||
return scratchPointSizeAndTilesetTime; | ||
u_pointAttenuationMaxSize : function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not bundled in u_pointSizeAndTilesetTimeAndAttenuation
because #5455 overrides just this uniform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; even though this behavior might seem redundant; it makes the uniform map easier to modify from future stages
@AnimatedRNG could you please do a first review of this and then bump to me for a quick final review? |
@pcozzi Sure, I'll take a look soon! |
@lilleyse Your code looks pretty good! I left a few comments for review. |
@AnimatedRNG is #5824 (comment) your only comment? Is this ready to merge? |
@lileyse I left three other comments on the code for review. Can you see them? |
@@ -432,6 +428,28 @@ defineSuite([ | |||
}); | |||
}); | |||
|
|||
it('point attenuation', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my understanding is correct, this code renders a point with point attenuation disabled, fails to find it, then enables point attenuation and finds it. This test is useful because it proves that point attenuation "grows" points which are close to the camera.
A nice complement test would also check that point attenuation does not grow points which are far away from the camera. This test would prove that the point size is actually being attenuated, rather than just being scaled uniformly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, added a few more lines onto the existing test.
} else { | ||
vs += ' gl_PointSize = u_pointSize; \n'; | ||
} | ||
|
||
vs += ' color = color * u_highlightColor; \n'; | ||
if (pointAttenuation) { | ||
vs += ' vec4 positionEC = czm_view * vec4(positionWC, 1.0); \n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, PointCloud3DTileContent
modifies the shader by conditionally appending some code to it (e.g no normals vs has normals, has a point size vs doesn't have a point size, etc.). The shader code incision/excision is made in Javascript, which makes sense given that the shader string is formed, bit by bit, in Javascript.
An alternative may involve using preprocessor defines to selectively enable/disable regions of code, and then merely adding the defines to the defines
array, or just prepending those lines to the source.
If you prefer constructing the shader completely in Javascript, then the current method is totally fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I could see it going either way. The one area that would be more complicated with defines is the attribute declaration section, but otherwise it falls pretty neatly into defines.
this._pointSize = 1.0; | ||
this._pointAttenuationMaxSize = 10.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to configure the maximum size or the start distance without access to private variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if I wanted to expose much of the internals yet since the attenuation is still kind of basic and not on by default. I could see those becoming options in the future though.
@lilleyse Ah okay it looks like I hadn't submitted my review yet, sorry! Here it is. |
@AnimatedRNG followed up with your comments. |
@lilleyse please merge in master. Do we want this for the next release. @AnimatedRNG will you have time to do another quick review pass on it? |
It would nice to get this in before the release. |
@mramato Sorry about the delay; everything looks good! |
* @type {Boolean} | ||
* @default true | ||
*/ | ||
this.pointAttenuation = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention this in CHANGES.md.
Are you sure this is the only field you want to expose, e.g., no parameters to change the size?
Are you also sure that it belongs here and not on the style? This seems out of place and more tightly coupled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you also sure that it belongs here and not on the style? This seems out of place and more tightly coupled.
I don't think it makes sense to be on the style, all 3D Tiles-conformant engines would need to support point attenuation. I think of this as similar to the color blend mode for tilesets, just an engine option to tweak the visuals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is the only field you want to expose, e.g., no parameters to change the size?
@AnimatedRNG also suggested this. I might make them private to start since I expect the attenuation to be more involved in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnimatedRNG also suggested this. I might make them private to start since I expect the attenuation to be more involved in the future
Could be fine to be public and then deprecate everything when we have the new method; otherwise, I think users will ask for these properties right away.
Just that comment. |
What part of the spec says this? Seems to be that this is exactly the type of behavior defined by a style. |
@lilleyse please bump when ready. Just a heads up that I will not have the bandwidth to review in time for the release today. |
Updated to make all the point size controls public. I'm still not sure about adding this to the style. The same question applies to point cloud surface reconstruction (#5455) - should a style be able to say whether it uses that technique? I feel like these options are too tied to the rendering engine to be useful as styles. Maybe we can discuss more offline. |
Discussed offline - we are going to try this with declarative styling. |
Closing in favor of #6069 |
Before #5455 is ready, I've taken some code from there and tweaked a few things so we can support very basic point attenuation.
It just does a mix between the minimum point size and maximum point size based on the distance from the camera, given a max distance of
100
currently. Ideally this value should be tuned based on the tileset scale and point density, but these defaults are decent for now.