# Scaling in GLSL

## 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 on other sites
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:[code]texCoords = (texCoords - 0.5) * scale + (0.5 * scale);[code]

##### 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 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).

vec3 outputPosition = inputPosition + inputNormal * 42.0;

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628300
• Total Posts
2981894

• 9
• 9
• 11
• 10
• 10