(lack of) Clipping Planes on WebGL 1 and 2 Spec

474 views
Skip to first unread message

André Venâncio

unread,
Dec 4, 2017, 11:34:14 AM12/4/17
to WebGL Dev List
Hi everyone.
I'm new to the Group, and I'm  wondering if there's a reason (and what that reason might be) why WebGL1.0 or WebGL 2.0 didn't implement clipping planes (gl_ClipDistance)  in the standard?

I would think that if the clipping was done at the vertex shader level then there would be less calls to the fragment shader - hence better performance, as opposite to discard pixels on the fragment shader.
Also I've read in quite a few places that shaders with "discard" can't be optimised by the GPU as they normally would. (Not totally sure about this though).

Thank you

Ken Russell

unread,
Dec 4, 2017, 4:27:13 PM12/4/17
to WebGL Dev List
Hi André,

In OpenGL ES, on which WebGL is based, gl_ClipDistance is provided via an extension: https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_clip_cull_distance.txt .

We can expose it as an extension to WebGL. From this report:


it looks like it's supported on Mesa, NVIDIA GPUs, and newer Adreno GPUs.

Could you please file an issue requesting it here: https://github.com/KhronosGroup/WebGL/issues .

Thanks,

-Ken



--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-list+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

André Venâncio

unread,
Dec 5, 2017, 6:45:10 AM12/5/17
to WebGL Dev List
Hey Ken.
thanks for your reply.


To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.

Gabby Getz

unread,
Dec 5, 2017, 9:31:42 AM12/5/17
to WebGL Dev List
Hi Andre,

If you are interested in the approach using discard in the fragment shader, I recently added clipping planes to CesiumJS using that method. The code changes are here.

Thanks!
Gabby

André Venâncio

unread,
Dec 5, 2017, 7:26:44 PM12/5/17
to WebGL Dev List
Hi Gabby.
Thank you kindly for your reply. I've implemented this myself so I dont need the code. I just want to improve performance on my engine. :)
Reply all
Reply to author
Forward
0 new messages