oculus2_psprite

diff sdr/psprite.v.glsl @ 21:dc7af0f549b2

VR point sprite shooting test
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 22 Jan 2015 06:19:52 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sdr/psprite.v.glsl	Thu Jan 22 06:19:52 2015 +0200
     1.3 @@ -0,0 +1,22 @@
     1.4 +uniform vec2 viewport;
     1.5 +
     1.6 +void main()
     1.7 +{
     1.8 +	const float psize = 1.0;
     1.9 +
    1.10 +	vec4 ppos = gl_ModelViewProjectionMatrix * gl_Vertex;
    1.11 +	gl_Position = ppos;
    1.12 +
    1.13 +	float vs_z = (gl_ModelViewMatrix * gl_Vertex).z;
    1.14 +	vec4 p0 = gl_ProjectionMatrix * vec4(0.0, 0.0, vs_z, 1.0);
    1.15 +	vec4 p1 = gl_ProjectionMatrix * vec4(psize, 0.0, vs_z, 1.0);
    1.16 +
    1.17 +	p0.xyz /= p0.w;
    1.18 +	p1.xyz /= p1.w;
    1.19 +
    1.20 +	p0.xy = (p0.xy * vec2(0.5, 0.5) + vec2(0.5, 0.5)) * viewport;
    1.21 +	p1.xy = (p1.xy * vec2(0.5, 0.5) + vec2(0.5, 0.5)) * viewport;
    1.22 +
    1.23 +	float sz = length(p1.xy - p0.xy);
    1.24 +	gl_PointSize = sz;
    1.25 +}