Created
August 7, 2013 01:34
-
-
Save borisbat/6170459 to your computer and use it in GitHub Desktop.
This file contains 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
vec3 finalColor = vec3( 0.0 ); | |
float steps = 0.0; | |
int initialSteps = max ( 4, g_Steps / 3 ); | |
int maxEstSteps = 32; | |
float factor = max ( 1.0, length(g_light_color.rgb)/length(vec3(1.0)) ); | |
float tolerance = 1.0 / ( (g_Steps * 4.0 + initialSteps) * factor ); | |
// do initial steps | |
for ( int i=0; i<initialSteps; ++i ) | |
finalColor += EstGI(worldPosition, worldNormal, uv_initial); | |
steps += initialSteps; | |
// do additional steps | |
for ( int step=0; step<maxEstSteps; ++step ) | |
{ | |
vec3 oldFinalColor = finalColor; | |
finalColor += EstGI(worldPosition, worldNormal, uv_initial); | |
finalColor += EstGI(worldPosition, worldNormal, uv_initial); | |
finalColor += EstGI(worldPosition, worldNormal, uv_initial); | |
finalColor += EstGI(worldPosition, worldNormal, uv_initial); | |
steps += 4.0; | |
vec3 c0 = oldFinalColor / (steps-4.0); | |
vec3 c1 = finalColor / steps; | |
float dc = length(c1-c0); | |
if ( length(c1-c0) < tolerance ) | |
break; | |
} | |
return ( g_Absorbtion / steps ) * finalColor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment