Jump to content
  • Advertisement
Sign in to follow this  
fazekaim

How can I scale model size in GLSL vertex program?

This topic is 4613 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here are my shader:
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;
}

It does'n work. THe model is draw as usual, in normal size. How can I scale it in GLSL? Thanks...

Share this post


Link to post
Share on other sites
Advertisement
Isn't that illegeal according to the standard? I know nvidia supports it. but the standard says it has to be Vertex *= vec4(scale);

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
gl_Vertex is 4 components thus Vertex *= scale; will also multiply the w as well but u only want to scale x,y,z

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!