Hello,
I wanted to know if it was possible to slice a plan for example in 2 in Y coordinate and apply a different rotation for each new plan? I managed to almost do that with that code in a vertex shader:
uniform float Angle;
// simple vertex shader
vec4 rotate (vec4 p, float t)
{
if (t<0.5)
{
float a = smoothstep(0.0, 1.0, Angle * 1.0) * (3.14159 / 2.0);
float ca = cos(a);
float sa = sin(a);
return vec4( p.x * sa + p.z * ca,
p.y,
-p.x * ca + p.z * sa,
p.w);
}
else
{
float a = smoothstep(0.0, 1.0, Angle * 2.0) * (3.14159 / 2.0);
float ca = cos(a);
float sa = sin(a);
return vec4( p.x * sa + p.z * ca,
p.y,
-p.x * ca + p.z * sa,
p.w);
}
}
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 pos = rotate(gl_Vertex, gl_TexCoord[0].y);
gl_Position = gl_ModelViewProjectionMatrix * pos;
gl_FrontColor = gl_Color;
}
And I obtain something like that:
imageshack.us/photo/my-images/7/capturedcran20130408165.png
As you can see the two rectangles are linked and I want to avoid that. It works correctly if I create two rectangles and I apply the shader with different parameters for each but I wanted to know if it was possible to split a plan directly in two and just declare one shader directly and how if you have an idea?
Thanks a lot!