oculus2_psprite
annotate sdr/psprite.v.glsl @ 22:fdfb911879df
renamed vc project: oculus2 -> oculus2_psprite
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 22 Jan 2015 06:22:38 +0200 |
parents | |
children |
rev | line source |
---|---|
nuclear@21 | 1 uniform vec2 viewport; |
nuclear@21 | 2 |
nuclear@21 | 3 void main() |
nuclear@21 | 4 { |
nuclear@21 | 5 const float psize = 1.0; |
nuclear@21 | 6 |
nuclear@21 | 7 vec4 ppos = gl_ModelViewProjectionMatrix * gl_Vertex; |
nuclear@21 | 8 gl_Position = ppos; |
nuclear@21 | 9 |
nuclear@21 | 10 float vs_z = (gl_ModelViewMatrix * gl_Vertex).z; |
nuclear@21 | 11 vec4 p0 = gl_ProjectionMatrix * vec4(0.0, 0.0, vs_z, 1.0); |
nuclear@21 | 12 vec4 p1 = gl_ProjectionMatrix * vec4(psize, 0.0, vs_z, 1.0); |
nuclear@21 | 13 |
nuclear@21 | 14 p0.xyz /= p0.w; |
nuclear@21 | 15 p1.xyz /= p1.w; |
nuclear@21 | 16 |
nuclear@21 | 17 p0.xy = (p0.xy * vec2(0.5, 0.5) + vec2(0.5, 0.5)) * viewport; |
nuclear@21 | 18 p1.xy = (p1.xy * vec2(0.5, 0.5) + vec2(0.5, 0.5)) * viewport; |
nuclear@21 | 19 |
nuclear@21 | 20 float sz = length(p1.xy - p0.xy); |
nuclear@21 | 21 gl_PointSize = sz; |
nuclear@21 | 22 } |