Posted by
Sven Gothel on
Aug 24, 2011; 7:25am
URL: https://forum.jogamp.org/2D-Lighting-Tribulations-with-Shaders-tp3279698p3280253.html
On Wednesday, August 24, 2011 02:29:15 AM Rejechted [via jogamp] wrote:
>
> (Repost from java-gaming.org)
>
> We've figured out our text renderer issues and have moved onto dynamic
> lighting. Currently we are having some trouble. A bit of background,
> explained again later: We are new to OpenGL and have just now learned how to
> utilize shaders, but haven't yet implemented FBOs or VBOs. Just a bit of
> context moving forward.
>
> We started out with the example given here:
>
http://www.youtube.com/watch?v=s60AljUbpKY> which goes into dynamic soft shadows via creating an alpha texture,
> rendering a black "ambient darkness" sheet with alpha 1.0f over the scene,
> and then using the alpha map of your lights to "reveal" through the
> darkness. Downsides to this system were the lack of our ability to do any
> kind of bloom effect without shader language, which led us to...
>
>
http://www.youtube.com/watch?v=fsbECSpwtigThats a dramatic 'neon' lighting demo, cute.
Their FS is also pretty simple. Sure they use blending,
which is equivalent of compositioning via FBOs, ie multipass.
The latter would be required if the hardware doesn't support blending,
e.g. on some mobile ES2 implementations.
<FS shader attached>
> Finally implementing GLSL and GL2.0 compatibility, we explored the
> possibility of using shader programs for our lights. Currently we have the
> following simple fragment shader that draws a basic circular light:
>
> fragment shader
>
> /varying vec2 pos;
> uniform vec4 color;
>
> void main()
> {
> float t = 1.0 - sqrt(pos.x*pos.x + pos.y*pos.y);
> //Enable this line if you want sigmoid function on the light
> interpolation
> //t = 1.0 / (1.0 + exp(-(t*12.0 - 6.0)));
> gl_FragColor = vec4(color.r, color.g, color.b, color.a) * t;
> }/
>
> (The vertices are +/-1, +/-1, so this math works out)
>
> Which is an example from the youtube video. Using this, we draw the lights
> to the screen as before, create the alpha map, and then blend this alpha map
> into our finished scene at the very end.
looks great (your screenshot too).
>
> Again we run into the problem of being unable to add any sort of bloom
> effect (we assume that this is another type of fragment shader that we would
> have to pass our lights through), and the idea of how to achieve even "hard"
> shadows is somewhat of a mystery (save for finding the dot product of the
> light vector and the normal of the shadow casting surface).
yup, sorry. indeed you would need to read about the details of such implementations,
which would exceed this thread for sure.
http://fabiensanglard.net/shadowmapping/index.phphttp://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=279198http://www.lighthouse3d.com/opengl/docs.shtmlhttp://www.punkuser.net/vsm/ !!!! (solves AA problems)
http://www.devmaster.net/articles/projectiveshadows/>
> The context of our project: We are developing a 2D indie title that we hope
> will be as backwards-compatible as possible (I think GL2 is pretty safe).
I would choose GL2ES2, which would ensure your product will be available
on ES2 devices (Android ..) as well.
> However, having good looking shadows gives a game a great "pop" factor. We
> are complete strangers to VBOs and FBOs, having used the fixed function
> pipeline until now. However, we understand the basic purposes of these
> objects; we're just lost on implementation and how they might help us arrive
> at a lighting solution without breaking the rest of our working code.
>
> A picture of our current light... uses a shader program, but uses GL_QUADS
There are no GL_QUADS in ES2, use TRIS and TRI_FANS ..
Please check the Gears ES1 and ES2 demos in our unit tests, which
I have described a few days earlier.
> to actually draw it... kind of a bastardization of GL2, but we're working on
> it:
>
>
http://forum.jogamp.org/file/n3279698/qLnhx.jpg
looks great
>
> Hopefully you guys see that we have put a decent amount of effort into
no need to apologize.
and I am sure, you are willing to maybe put back a unit test or demo .. or both :)
all great.
>
> Thanks in advance!
hoped it helped a bit ..
maybe you can try to enhance our gears w/ the
VSM <
http://www.punkuser.net/vsm/>
shadow technique! We maybe able help, plus this would allow us to have
a little unit test and we know what we are talking about.
Thank you in adnvance!
Cheers, Sven