Reverse godrays shader

edited April 2014 in GLSL / Shaders

Hi, I need to make a shader (for a 2D game) that works like this: there is a black and white image that act similar to light maps and its drawn by a designed, that is parallaxed to player movement. The image is drawn on full screen but the light that is illuminating the floor needs to be "volumetric" so god rays. Now to imagine this better, imagine a black image with a white square in the middle (actual image), from above the screen at a small height there is a light (imaginary) that generates that light, from that light we can see the god rays effect directed to that square coming from out of screen. Now the thing is that the input is not the light and mask but the resulting illumination. So first thing I tried is to reverse the godrays algorithm, instead of sampling up, I'm sampling down and do the inverse decay. Now as you might already guessed there are problems with this that in godrays the ray distance are based on light -> mask distance so it looks correct, when its inverted it acts its mixed differently. The other way I was thinking is to sample the light map as its a smaller god rays mask situated at proportional distance and scaled down up. But failed to implement this as when I add offset there appears white borders with weight of the offset. I'm not sure how to make this kind of effect, so maybe somebody may suggest a method that can work. Thanks

Tagged:

Answers

  • Perhaps you could show the code you have already and some example images and then explain how the current behavior differs from the desired behavior?

  • Hi, sorry for delay, we ended up using quads with textures because of deadline, sadly its not procedural and match the shadow/lightmap but adds the desire effect. I might get back to the examples later as we're under pressure now. Thanks and sorry for inconvenience.

Sign In or Register to comment.