oculus1

diff sdr.glsl @ 14:cceffea995a4

implemented wasd controls and clamping of the texcoords to [0, 1]
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 03:35:53 +0300
parents 464e1d135d68
children
line diff
     1.1 --- a/sdr.glsl	Sat Sep 21 03:00:47 2013 +0300
     1.2 +++ b/sdr.glsl	Sat Sep 21 03:35:53 2013 +0300
     1.3 @@ -3,20 +3,20 @@
     1.4  uniform float lens_center_offset;
     1.5  uniform vec4 dist_factors;
     1.6  
     1.7 -vec2 distort_texcoords(in vec2 tc, out float dbgrad);
     1.8 +vec2 distort_texcoords(in vec2 tc);
     1.9  float barrel_scale(float x, in vec4 k);
    1.10  
    1.11  void main()
    1.12  {
    1.13 -	float dbgrad;
    1.14 -	vec2 tc = distort_texcoords(gl_TexCoord[0].xy, dbgrad);
    1.15 +	vec2 tc = distort_texcoords(gl_TexCoord[0].xy);
    1.16  
    1.17 -	gl_FragColor.rgb = texture2D(tex, tc).rgb;
    1.18 -	gl_FragColor.rgb += mix(vec3(1.0, 1.0, 0.0), vec3(0.0), smoothstep(0.01, 0.05, dbgrad));
    1.19 +	float vis = any(greaterThan(tc, vec2(1.0)) || lessThan(tc, vec2(0.0))) ? 0.0 : 1.0;
    1.20 +
    1.21 +	gl_FragColor.rgb = texture2D(tex, tc).rgb * vis;
    1.22  	gl_FragColor.a = 1.0;
    1.23  }
    1.24  
    1.25 -vec2 distort_texcoords(in vec2 tc, out float dbgrad)
    1.26 +vec2 distort_texcoords(in vec2 tc)
    1.27  {
    1.28  	// map tc [0, 1] -> [-1, 1]
    1.29  	vec2 pt = tc * 2.0 - 1.0;
    1.30 @@ -27,8 +27,7 @@
    1.31  	float rad = barrel_scale(dot(pt, pt), dist_factors);
    1.32  	pt *= rad;	// scale the point by the computer distortion radius
    1.33  
    1.34 -	dbgrad = length(pt) * rad;
    1.35 -
    1.36 +	pt /= scale;
    1.37  	pt.y *= aspect;
    1.38  	pt.x -= lens_center_offset * 2.0;
    1.39