Can i use webgl2 #version 300 es shader?

hi,
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?

1 Like

Hi,
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
http://andrewmarsh.com/blog/2016/01/05/understanding-webgl/
Probably not much room for anything…
Wrong forum for all these questions (right people though) :smiley:

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

from https://stackoverflow.com/questions/62057162/most-efficient-way-to-store-normals-in-gltf-files/62070206#62070206
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.

1 Like

hi,
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