I am looking into flat and smooth shading and was wondering if Cesium can use webgl version 300 es shader already? The latest info on webgl2 support i found was from 2019 I think…
It would be useful for flat qualifier.
Or is there any better way without duplicating vertices
CesiumJS doesn’t currently support WebGL 2, we have a roadmap issue with the current known problems here: https://github.com/CesiumGS/cesium/issues/797
Here’s a post on the forum about how to do flat shading on the globe: Forcing a low poly look on Cesium3DTileset. It requires modifying the source code though.
What kind of project are you working on?
Thanks for the quick reply.
I got that to work and I think that avoids some data duplication. We wil have to measure if its a significant saving for large meshes. We would love to avoid duplicating vertices…
I am a bit surprised GLTF format has not more explicit support for this kind of thing, or does it? Seems so common. Is there support for different normal precision?
Gltf format seems to expect vertex normals in float
NORMAL “VEC3” 5126 (FLOAT) Normalized XYZ vertex normals
and that is how webgl needs them
Probably not much room for anything…
Wrong forum for all these questions (right people though)
Yeah I would say this is worth asking on the glTF forums, but if you get some useful answers here please do link to it from here!
I am also curious about learning more about your use case, since I haven’t seen a lot of need for flat shading in Cesium. Are you generating your own terrain? Do you need to see it flat shaded as a debug view or as your main application view? If you just want to see the triangles there is a wireframe mode you can toggle with the Cesium inspector (under the terrain dropdown): https://sandcastle.cesium.com/index.html?src=Cesium%20Inspector.html
For better speed we switched out obj2Gltf to some custom code (our native input format isn’t obj so we dont want to translate to it first). It runs on the cloud so size matters
does cesium support this?
Flat normals : The most efficient way to store flat normals is to omit them entirely. From the glTF specification, in [the Meshes section]
“When normals are not specified, client implementations should calculate flat normals.”
Smooth normals : You are correct, the core glTF specification requires that normals use 5126 / float32 precision. If you need other options, enable the
KHR_mesh_quantization extension (extension spec) on your model, which allows for additional types (int16 normalized or int8 normalized). The [gltfpack]ibrary can apply these optimizations automatically, or you can modify the model directly.
Both sounds promising. Would you be able to confirm gltf extension should work?
The forum software wont let me repost the links mentioned in the stackoverflowpost unfortunately…
Oh, seem still open, are there plans to support auto generating normals in the future?
How about these gltf extensions?
Yes, although I don’t know what the timeline for implementing that in CesiumJS will be. I’d subscribe to that GitHub issue for updates.
Great, i think it will be really useful. Thanks again