Jump to content
  • Advertisement
Sign in to follow this  
DigiMan Shart

Scaling in GLSL

This topic is 3429 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

This may be a beginner's question, but I wasn't exactly sure how to do it. If I wanted to scale my image in GLSL, does anyone know how I would go about doing so within my shaders. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Assumption:
You are rendering an image to the screen by rendering a full-screen quad?


You can scale the image by scaling the texture-coordinates which are being used to sample the texture.
However, texture coordinates are in the range 0-1, so simply multiplying them by a scale value will scale the image out from one corner.
If you want to scale from the center you could do:texCoords = (texCoords - 0.5) * scale + (0.5 * scale);

Share this post


Link to post
Share on other sites
I was thinking more along the lines of, that I render a teapot once as black, but scale it slightly larger than it is, and then render it a second time normally, to give myself a black outline around it.

Share this post


Link to post
Share on other sites
Ok, scaling a 3d model, not an image then.

The outline-scaling effect is usually achieved by adding the (scaled) normal to the position. Also, when rendering the black version, you probably want to reverse the culling operation (so front-faces are culled and back-faces are visible).

In your vertex shader:
vec3 outputPosition = inputPosition + inputNormal * 42.0;

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!