Update leenkx/Shaders/ssrefr_pass/ssrefr_pass.frag.glsl
This commit is contained in:
parent
5153cff790
commit
5303ad3ac6
@ -57,14 +57,17 @@ vec4 binarySearch(vec3 dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec4 rayCast(vec3 dir) {
|
vec4 rayCast(vec3 dir) {
|
||||||
float ddepth;
|
float ddepth;
|
||||||
dir *= ss_refractionRayStep;
|
dir *= ss_refractionRayStep;
|
||||||
for (int i = 0; i < maxSteps; i++) {
|
for (int i = 0; i < maxSteps; i++) {
|
||||||
hitCoord += dir;
|
hitCoord += dir;
|
||||||
ddepth = getDeltaDepth(hitCoord);
|
ddepth = getDeltaDepth(hitCoord);
|
||||||
if (ddepth > 0.0) return binarySearch(dir);
|
if (ddepth > 0.0)
|
||||||
}
|
return binarySearch(dir);
|
||||||
return vec4(texCoord, 0.0, 1.0);
|
}
|
||||||
|
// No hit — fallback to projecting the ray to UV space
|
||||||
|
vec2 fallbackUV = getProjectedCoord(hitCoord);
|
||||||
|
return vec4(fallbackUV, 0.0, 0.5); // We set .w lower to indicate fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -74,7 +77,7 @@ void main() {
|
|||||||
float ior = gr.x;
|
float ior = gr.x;
|
||||||
float opac = gr.y;
|
float opac = gr.y;
|
||||||
float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
|
float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
|
||||||
if (d == 0.0 || d == 1.0 || opac == 1.0 || ior == 1.0) {
|
if (d == 0.0 || opac == 1.0 || ior == 1.0) {
|
||||||
fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb;
|
fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user