Created
February 5, 2012 12:49
-
-
Save roxlu/1745363 to your computer and use it in GitHub Desktop.
Light Rays 0.6 - Fabien Sanglard's light ray shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uniform float exposure; | |
| uniform float decay; | |
| uniform float density; | |
| uniform float weight; | |
| uniform vec2 lightPositionOnScreen; | |
| uniform sampler2D firstPass; | |
| const int NUM_SAMPLES = 100 ; | |
| void main() { | |
| vec2 deltaTextCoord = vec2( gl_TexCoord[0].st - lightPositionOnScreen.xy ); | |
| vec2 textCoo = gl_TexCoord[0].st; | |
| deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density; | |
| float illuminationDecay = 1.0; | |
| for(int i=0; i < NUM_SAMPLES ; i++) { | |
| textCoo -= deltaTextCoord; | |
| vec4 sample = texture2D(firstPass, textCoo ); | |
| sample *= illuminationDecay * weight; | |
| gl_FragColor += sample; | |
| illuminationDecay *= decay; | |
| } | |
| gl_FragColor *= exposure; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment