Login  Register

Re: 2D Lighting Tribulations with Shaders

Posted by Rejechted on Aug 24, 2011; 8:14pm
URL: https://forum.jogamp.org/2D-Lighting-Tribulations-with-Shaders-tp3279698p3281984.html

We actually already do use a LightSource wrapper in Java that has a few fields.

This doesn't really seem to make sense given our current model, which is to just render the shader I described above onto a quad, simulating a circular light.  In a TRUE two-dimensional world, a light directly overhead of a wall is really just a light shining down onto a plane whose normal is orthogonal to the light vector.  In the real world you'd see light on the plane but in computer graphics you wont unless light is pointing at the surface in such a way that the angle is between 0 and 90 degrees.  This is the challenge we're facing.

We maintain a list of entities that should cast shadows.  The plan is to use the edges of their polygons to see which edge normal vectors form the correct angle with the light source, and cast the shadow from the vertices of that edge.  This theory we understand.  The issue is creating the correct "pipeline" of shader executions, rendering the world, applying the lightmap, drawing the shadows, etc. all blended with the correct glBlendFunc so that the end result makes sense.  It's not just a challenge in programming and computer graphics but it's a pretty complex logic puzzle as well.