git-svn-id: svn://db.shs.com.ru/libs@70 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
32
qglview/shaders/ssao_merge.frag
Normal file
32
qglview/shaders/ssao_merge.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D t0, ts, tg1;
|
||||
uniform float z_near, z_far;
|
||||
uniform mat4 mat_proj;
|
||||
|
||||
in vec3 view_dir;
|
||||
|
||||
void main(void) {
|
||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0), vg1 = texelFetch(tg1, tc, 0);
|
||||
vec3 n = vec3(-vg1.xy, vg1.z);
|
||||
vec3 bn = cross(n, vec3(0, 0, 1));
|
||||
vec3 bn2 = cross(n, bn);
|
||||
vec4 pos;
|
||||
pos.w = 1;
|
||||
pos.xyz = view_dir * vs.w;
|
||||
vec4 spos = pos, tpos, tv0;
|
||||
vec2 tsp;
|
||||
float l = 20 * 0.5;
|
||||
pos.xyz += bn2 * l;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
tpos = mat_proj * pos;
|
||||
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
|
||||
tv0 = texture(ts, tsp);
|
||||
l *= 0.5;
|
||||
pos.xyz += bn2 * (step(pos.z, tv0.w) * 2. - 1.) * l;
|
||||
}
|
||||
qgl_FragData[0].rgb = vec3(1.-(vs.w - v0.w));
|
||||
qgl_FragData[0].rgb = vec3(length(pos.z - spos.z)/15);
|
||||
//qgl_FragData[0].rgb = vec3(abs(v0.w/1));
|
||||
}
|
||||
Reference in New Issue
Block a user