uniform float lerp;
uniform float scale;
void main(void)
{
vec4 Vertex;
Vertex = mix( gl_Vertex, gl_Color, lerp ); // mix 2 keyframe using in model's motion
gl_Position = gl_ModelViewProjectionMatrix * scale * Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}
How can I scale model size in GLSL vertex program?
Here are my shader:
It does'n work. THe model is draw as usual, in normal size. How can I scale it in GLSL?
Thanks...
try this:
Vertex.x *= scale;
Vertex.y *= scale;
Vertex.z *= scale;
insert this between gl_Position and Vertex = mix(......); line
Vertex.x *= scale;
Vertex.y *= scale;
Vertex.z *= scale;
insert this between gl_Position and Vertex = mix(......); line
Isn't that illegeal according to the standard? I know nvidia supports it. but the standard says it has to be Vertex *= vec4(scale);
hmmm as far as i can remember vec*scale multipliers are fine... infact, I know it is as in my lighting equations I do it (speccolour * specpower where specpower is a float and speccolour is a vec3 or vec4)
gl_Vertex is 4 components thus Vertex *= scale; will also multiply the w as well but u only want to scale x,y,z
you raise a good point.. in which case adjusting it to Vertex.xyz *= scale; or at worse Vertex.xyz = Vertex.xyz * scale; should work.
The compiler should make a better job of optermising either of those when compared to doing it one component at a time as you are explicately vectorising it.
However, that said, looking at his inital 'lerp' code that needs adjusting as well, as he is lerping two vec4s, so he'll lerp the W coord there as well.
The compiler should make a better job of optermising either of those when compared to doing it one component at a time as you are explicately vectorising it.
However, that said, looking at his inital 'lerp' code that needs adjusting as well, as he is lerping two vec4s, so he'll lerp the W coord there as well.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement