forked from LeenkxTeam/LNXSDK
Update leenkx/Shaders/ssrefr_pass/ssrefr_pass.frag.glsl
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
//https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-refraction.html
|
//https://lettier.github.io/3d-game-shaders-for-beginners/screen-space-refraction.html
|
||||||
//Implemented by Yvain Douard.
|
//Implemented by Yvain Douard an 1k8.
|
||||||
|
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ vec4 rayCast(vec3 dir) {
|
|||||||
ddepth = getDeltaDepth(hitCoord);
|
ddepth = getDeltaDepth(hitCoord);
|
||||||
if (ddepth > 0.0) return binarySearch(dir);
|
if (ddepth > 0.0) return binarySearch(dir);
|
||||||
}
|
}
|
||||||
return vec4(getProjectedCoord(hitCoord), 0.0, 1.0);
|
return vec4(texCoord, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -72,10 +72,11 @@ void main() {
|
|||||||
float roughness = g0.z;
|
float roughness = g0.z;
|
||||||
vec4 gr = textureLod(gbuffer_refraction, texCoord, 0.0);
|
vec4 gr = textureLod(gbuffer_refraction, texCoord, 0.0);
|
||||||
float ior = gr.x;
|
float ior = gr.x;
|
||||||
float opac = gr.y;
|
float opac = 1.0 - 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 || d == 1.0 || opac == 1.0 || ior == 1.0) {
|
||||||
fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb;
|
fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb;
|
||||||
|
fragColor.a = opac;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vec2 enc = g0.rg;
|
vec2 enc = g0.rg;
|
||||||
@ -86,7 +87,7 @@ void main() {
|
|||||||
|
|
||||||
vec3 viewNormal = V3 * n;
|
vec3 viewNormal = V3 * n;
|
||||||
vec3 viewPos = getPosView(viewRay, d, cameraProj);
|
vec3 viewPos = getPosView(viewRay, d, cameraProj);
|
||||||
vec3 refracted = refract(viewPos, viewNormal, 1.0 / ior);
|
vec3 refracted = refract(normalize(viewPos), viewNormal, 1.0 / ior);
|
||||||
hitCoord = viewPos;
|
hitCoord = viewPos;
|
||||||
|
|
||||||
vec3 dir = refracted * (1.0 - rand(texCoord) * ss_refractionJitter * roughness) * 2.0;
|
vec3 dir = refracted * (1.0 - rand(texCoord) * ss_refractionJitter * roughness) * 2.0;
|
||||||
@ -98,9 +99,12 @@ void main() {
|
|||||||
clamp(-refracted.z, 0.0, 1.0) * clamp((length(viewPos - hitCoord)), 0.0, 1.0) * coords.w;
|
clamp(-refracted.z, 0.0, 1.0) * clamp((length(viewPos - hitCoord)), 0.0, 1.0) * coords.w;
|
||||||
intensity = clamp(intensity, 0.0, 1.0);
|
intensity = clamp(intensity, 0.0, 1.0);
|
||||||
|
|
||||||
vec3 refractionCol = textureLod(tex1, coords.xy, 0.0).rgb;
|
vec4 refractionCol = textureLod(tex1, coords.xy, 0.0).rgba;
|
||||||
refractionCol *= intensity;
|
refractionCol.a = opac;
|
||||||
vec3 color = textureLod(tex, texCoord.xy, 0.0).rgb;
|
//refractionCol *= intensity;
|
||||||
|
vec4 color = textureLod(tex, texCoord.xy, 0.0).rgba;
|
||||||
|
color.a = opac;
|
||||||
|
|
||||||
fragColor.rgb = mix(refractionCol, color, opac);
|
fragColor.rgba = mix(refractionCol, color, opac);
|
||||||
|
fragColor.a = opac;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user