-
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
3D Tiles - Point Cloud Styling #4336
Conversation
@lilleyse merge in
What do you want to do with them? GLSL-like functions, e.g.,
Roadmap, unless you have a compelling use case.
I'm confused; I thought you said you can only access their components. Are you sure we didn't implement
No, think of declarative styling as closer to JavaScript than GLSL. |
The options are:
1 is the least work, but 2 is probably the right solution since it keeps the spec simple and doesn't fragment itself. Just a warning that the styling spec updates may be non-trivial; a language spec is way harder than a format spec. Please deeply think through if just "types must match with absolutely no implicit conversion" limits any potentially common use cases. |
I'll look, but I think just recompiling the shader for now is fine (which is what we do for the CPU styling implementation). Later, we could map some variables to uniforms for fast paths, which is how the original CPU styling implementation worked. |
I think so. For complex conditions, wouldn't this let users break them over several checks? Just because the results is boolean doesn't mean we should limit how that boolean is computed. |
Yes. Is this tested in our CPU implementation and documented well enough in the spec? |
This is cool. Please clean it up and make it a separate "3D Tiles Point Cloud Styling" Sandcastle example; I think it would be too much to combine with the 3D Tiles example. |
Do you have the styling code example for the screenshot at the top of this PR? |
* | ||
* @param {String} name Name to give to the generated function. | ||
* @param {String} variablePrefix Prefix that is added to any variable names to access vertex attributes. | ||
* @param {Object} info Stores information about the generated shader 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.
Can we rename info
. From this context, I have no idea what it is.
* | ||
* @param {String} name Name to give to the generated function. | ||
* @param {String} variablePrefix Prefix that is added to any variable names to access vertex attributes. | ||
* @param {Object} info Stores information about the generated shader 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.
Same comment.
var length = content.featuresLength; | ||
var style = styleEngine._style; | ||
|
||
stats.numberOfFeaturesStyled += length; | ||
|
||
// Apply style to point cloud. Only apply style if the point cloud is not backed by a batch table. | ||
if ((content instanceof PointCloud3DTileContent) && (length === 0)) { | ||
content.applyStyle(frameState, style); |
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.
Perhaps rework this function so that each content type has a function like applyStyleWithShader
that returns a boolean. If it returns false
then the style was not applied and the loop below can be used. This avoids the special cases and reduces coupling.
case ExpressionNodeType.CONDITIONAL: | ||
return '(' + test + ' ? ' + left + ' : ' + right + ')'; | ||
case ExpressionNodeType.MEMBER: | ||
// This is intended for accessing the components of vec2, vec3, and vec4 properties. String members aren't supported. |
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.
} | ||
break; | ||
default: | ||
// Not supported: FUNCTION_CALL, ARRAY, REGEX, VARIABLE_IN_STRING, LITERAL_NULL, LITERAL_REGEX, LITERAL_UNDEFINED |
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.
Some of these can probably be explicitly disallowed by the spec (I suppose we can't get around this since any sane point cloud styling engine will use a shader) like regex
, but please mark this in the task list so we can think through it before merging.
this._hasNormals = false; | ||
this._hasBatchIds = false; | ||
|
||
// TODO : How to expose this? Will this be part of the point cloud styling or a property of the tileset? |
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.
Doesn't need to be part of this PR; we can determine this when we also consider point attenuation, blurring, etc., which will have the same questions.
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.
Ah, old TODO.
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'll do a more detailed review before merging, but this is off to a nice start.
attributeLocations[attributeName] = attribute.location; | ||
} | ||
|
||
var vs = 'attribute vec3 a_position; \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.
Can we combine all the shader generation code with the similar code above?
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.
Addressed in b7c2dfd, though I'm not sure if you had something else in mind.
When generating the shaders we should optimize out all constants at "compile time" mean that expressions like |
daacc56
to
976f32f
Compare
I made a few changes to the type comparisons:
It seems too restrictive to force the equality comparisons to be the same type, so in this case the shader styling would not conform to the spec. |
I made some changes to how scratch colors are used in the evaluate functions in 5cb1088 fixes CesiumGS/3d-tiles#2 (comment) The vector math situation is a little better now. I allow arrays to be converted to vec2, vec3, or vec4 to support some vector math. Will update soon with tests and a Point Cloud Styling sandcastle. |
Looks good, except:
I think it is important the the styling language be fully implementable both with a tradition compiler/interpreter as well as a transpiler to GLSL. So we need to:
Let's discussion in person if needed. |
var styleableProperties; | ||
if (!defined(batchIds) && defined(batchTableBinary)) { | ||
styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(pointsLength, batchTableJson, batchTableBinary); | ||
|
||
// WebGL does not support UNSIGNED_INT, INT, or DOUBLE vertex attributes. Convert these to FLOAT. |
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.
Does float
start to skip whole numbers in the max UNSIGNED_INT
/INT
range? If so, perhaps we should console.log
warn. Otherwise, we should just warn for doubles.
For the spec, I think we'll need to allow conversion to float so that styling is implementable with WebGL 1.0 shaders.
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 it does start to skip... I'll add a warning
Just those comments. |
Yes they are in the 3D Tiles Roadmap under the Point Cloud Shader Styling section.
Possibly depending on how strict we want to be with type conversions. What did you think about this comment: #4336 (comment)? Also there will be some point specific notes like using POSITION, COLOR, and NORMAL semantics.
Fixed now. My Chrome doesn't support OIT so I had to tweak the value a bit to make it pass. |
Agreed. I would change it to be loose like JavaScript until we decide otherwise. What else is this PR waiting on? Just |
Yes just that. |
39c63f7
to
55cf834
Compare
Updated. |
@@ -129,6 +129,11 @@ | |||
color : "rgb(${POSITION}[0] * 255, ${POSITION}[1] * 255, ${POSITION}[2] * 255)" | |||
}); | |||
|
|||
addStyle('Style point size', { | |||
color : "color('red')", | |||
size : "${temperature} * 10" |
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.
Why call this size
? Why not call it precisely what it is: pointSize
, and in the reference doc explain that it defines the point size in pixels when styling point cloud tiles.
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.
My thinking was a generic name would be good for other sizeable things thing billboards. If fine with either way.
Before we merge this, can you please also open a PR to add In the spec, note that systems may have min/max point size limits (http://webglreport.com/) and that a valid renderer can just clamp to those system limits (and recommend that they warn when doing so). Also add the Cesium code and unit test for this. |
Given that we don't yet know what billboard styling will look like, I would stick with the specific |
It's not always possible to know when the point size exceeds the maximum value when its based on a batch table property. Given that 0.4% of users have a point size limited to 1px is this note needed? |
0f5016a
to
c04ff78
Compare
Updated. Rename |
OK, the spec doesn't need to recommend warning, but I think it still needs to mention clamping; otherwise, it would be impossible to implement with GL point primitives and would require scaling triangles in a vertex shader. |
Nicely done, @lilleyse! |
For #3241 and CesiumGS/3d-tiles#22 (comment)
Initial steps for point cloud styling based on shaders. I've tested a bunch of different styles and it seems to be working pretty well.
TODO:
COLOR
, orNORMAL
?There are a few open issues:
show
expression support a conditions list? I can understand why it wouldn't need to, since it's just true/false.Demo: http://cesium-dev.s3-website-us-east-1.amazonaws.com/cesium/pnts-styling/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=9d8bd5ba00d15b424da2e294cfa1a5c4