How do I implement shadow volumes using webgl (or opengl 3.2+)

Started by
0 comments, last by fruitsaladyummyummy 4 years, 5 months ago

Hello everyone!

I am very interested in shadow volumes and was wondering how to implement it. I can't really find any good tutorials that walk through some code in webgl (preferably) or opengl. There are a lot of online resources for putting the general steps to words but I don't know exactly how to translate that to code.

I am trying to create a pretty simple project that has a square floating over a ground object with a light source above both, with the square's shadow being projected onto the ground below and can't really figure out how to begin implementation (beyond creating a square over ground with light source). I am trying to do this in webgl, but I was told that OpenGL 3.2+ isn't that different so code in either language would be helpful.

From what I have read so far it seems like I would have to render my whole scene minus the light source (so whole scene with ambient light), initialize a stencil buffer and figure out where shadows should be, setting those positions to some value other than 0 in the stencil buffer. Render the scene again, but where ever the stencil buffer position = 0 add in diffuse and specular.

I assume this would use deferred shading but I am not confident.


TL;DR Y'all got any good examples of shadow volumes in webgl or opengl 3.2+ that I could take a look at?




This topic is closed to new replies.

Advertisement