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

Standardize how hidden geometry gets clipped in the vertex shader #8547

Open
lilleyse opened this issue Jan 16, 2020 · 2 comments
Open

Standardize how hidden geometry gets clipped in the vertex shader #8547

lilleyse opened this issue Jan 16, 2020 · 2 comments

Comments

@lilleyse
Copy link
Contributor

There are several systems that batch features together into a single draw call and hide individual features in the vertex shader by accessing their show property in the batch table and forcing them to be clipped. All these systems have a slightly different way of doing this.

  • b3dm/i3dm uses gl_Position *= show; in Cesium3DTileBatchTable.js
  • PointCloud.js (for 3D Tiles) uses gl_Position.w *= float(show); (see 8479 - Fix grey screen on Other/Unclassified toggle #8538) and gl_PointSize *= float(show);
  • Primitive.js distance display condition uses gl_Position *= show;
  • PointPrimitiveCollection
  • BillboardCollection uses positionEC.xyz = vec3(0.0); for small eye distance scales and eye distance translucency.
  • There may be more I haven't noticed

The gl_Position.w *= show approach is probably the easiest to use everywhere and is the easiest one to implement as a built-in function. Another thing to look at is how log depth affects all this, especially anything in DerivedCommand.createLogDepthCommand.

@lilleyse
Copy link
Contributor Author

lilleyse commented Jun 4, 2021

Another option is setting one of the coordinates to a NaN value. See

From @loshjawrence

@ptrgags
Copy link
Contributor

ptrgags commented Apr 13, 2022

I wish I had seen this sooner, for ModelExperimental we've been doing yet a different way: positionMC *= 0.0 (see CPUStylingStageVS.glsl). This makes an assumption that WebGL won't render zero-area triangles as a single pixel. We'd have to refactor the shader a bit. If we just switched to gl_Position, the value is likely to get clobbered by later shader stages.

But also, in this forum thread I saw a use case where a user wanted to hide a specific building in a vertex shader so something else could be rendered in its place. We'd need another variable in custom shaders to hide a vertex, as positionMC doesn't have a w component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants