Created
August 7, 2013 15:41
-
-
Save borisbat/6175244 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 kFactor = 2.0 / g_Steps; | |
// 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 c0 = finalColor / steps; | |
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 c1 = finalColor / steps; | |
float b0 = length(c0) + 1e-10; | |
float b1 = length(c1) + 1e-10; | |
float k = b0 / b1; | |
if ( abs(k - 1.0) < kFactor ) | |
break; | |
} | |
// this would be 'hotness' of the pixel, i.e how many extra passes | |
// return vec3( (steps - initialSteps) / (g_Steps*4)); | |
return ( g_Absorbtion / steps ) * finalColor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment