This repository has been archived on 2020-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libs/qglview/shaders/ssr.frag

18 lines
526 B
GLSL

#version 150
uniform sampler2D t0, t1, ts;
uniform float z_near, z_far;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec2 sp = qgl_FragTexture.xy;
vec4 v0 = texelFetch(t0, tc, 0), v1 = texelFetch(t1, tc, 0), vs = texelFetch(ts, tc, 0);
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
vec3 vd = vec3(0, 0, 1);
vec3 rn = reflect(vd, n);
float coeff = clamp(dot(vd, rn), 0, 1);
vec3 rvs = texture(ts, sp - rn.xy/v0.w).rgb;
qgl_FragData[0].rgb = mix(vs.rgb, rvs, coeff);
//qgl_FragData[0].rgb = vec3(v0.w/10);
}