Hi!
I try to fake rotatable pointsprites by rotating the calculated
gl_PointCoord in the fragment shader.
For some strange reason the linking of the program
fails as soon as I try to modify a copy of the gl_PointCoord
values.
This is the error (including a typo from a nv dev ):
error C7001: inconsitent use of semantic modifiers: “sin_a” and “gl_PointCoord”
This is my fragment shader:
uniform sampler2D u_base;
varying float sin_a;
varying float cos_a;
void main()
{
// apply rotation
vec2 coords = gl_PointCoord;
/*
coords = coords * 2.0 - 1.0; // [0, 1] ->[-1, 1]
float xx = cos_a * coords.x + sin_a * coords.y;
coords.y = -sin_a * coords.x + cos_a * coords.y;
coords.x = xx;
coords = (coords + 1.0) * 0.5; // [-1, 1] -> [0, 1]
*/
vec3 color = texture2D(u_base, coords).rgb;
gl_FragColor = vec4(color, 1.0) * gl_Color;
}
The vertex shader
varying float sin_a;
varying float cos_a;
void main()
{
vec4 vtx = gl_ModelViewMatrix * vec4(gl_Vertex.xyz, 1.0);
// distance attenuation
// add an epsilon 'cause zero size is undefined for pointsprites
gl_PointSize = VIEWPORT_WIDTH * gl_Vertex.w * 2.0 / -vtx.z + 0.01;
// decode color and rotation
vec4 tmp = gl_MultiTexCoord0;
gl_FrontColor = vec4(tmp.r, tmp.g, fract(tmp.b) * 10.0, fract(tmp.a) * 10.0);
sin_a = tmp.b / 1000000.0;
cos_a = tmp.a / 1000000.0;
gl_Position = gl_ProjectionMatrix * vtx;
}
As soon as I remove the comments around the
codeblock that recalculates the coords, the linking fails.
Card used: Geforce 8 GTS
Version: 2.1.1 NVIDIA 100.14.19
OS is Linux