Created
April 8, 2017 21:04
-
-
Save Shell64/48cfe3740308fc715541328f017085eb to your computer and use it in GitHub Desktop.
SSR Render Loop
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
for(int Count = 0; Count < 160; Count++) | |
{ | |
if(CurrentPosition.x < 0.0 || CurrentPosition.x > 1.0 || | |
CurrentPosition.y < 0.0 || CurrentPosition.y > 1.0 || | |
CurrentPosition.z < 0.0 || CurrentPosition.z > 1.0) | |
{ | |
return vec4(0.0, 0.0, 0.0, 1.0); | |
} | |
//intersections | |
float SampleDepth = texture2DLod(tex_depth, CurrentPosition.xy, 0).x; | |
/* | |
if(SampleDepth == 1.0) | |
{ | |
return vec4(0.0, 0.0, 0.0, 1.0); | |
} | |
*/ | |
float CurrentDepth = CurrentPosition.z; | |
float Difference = CurrentDepth - SampleDepth; | |
if(Difference >= 0.0 && Difference < length(ScreenSpaceVector)) | |
{ | |
ScreenSpaceVector *= StepRefinementAmount; | |
CurrentPosition = OLD_Position; | |
NumRefinements++; | |
if(NumRefinements >= MaxRefinements) | |
{ | |
SSR = CurrentPosition.xy; | |
break; | |
} | |
} | |
OLD_Position = CurrentPosition; | |
CurrentPosition = OLD_Position + ScreenSpaceVector; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment