I'm doing some experiments on my own to improve my general skills with HLSL and so forth. In other words, I'm not doing any serious game development, but only looking to expand my knowledge within the field.

I'm trying to figure out how I can increase the resolution of a texture, and multiply it X amount of times.

Consider the following low-resolution picture:

A typical scenario for me would be to scale up this picture 3 times in the shader without interpolation, and draw the new result:

I've been experimenting with a shader that transfers the small picture on to a texture as a variable on the shader. I got that far. Now I just need it to take that texture using tex2D or something else, and scale it up.

1 Answer
1

It depends because it's not clear whether you want to scale the texture (which would be scaling the UV coords as @Jari said) or if you want to scale the underlying geometry.

For example, you may want to display a square with a texture, such as sprite rendering, then for scaling the sprite you wouldn't be scaling the texture coordinates but the vertex positions themselves. In this case, transforming the texture coordinates will make your texture wrap or truncate according to the relative mapping to the vertices and won't match the underlying geometry.

Anyway, for transforming the texture coordinates alone you can do it simply by scaling the texture coordinates of the vertices (the UV mapping), like this:

The tex2D comes later with the pixel shader, but by then you already have the scaled coordinates, so you don't need to do anything else other than get the colors as float4 texColor = tex2D(SampS0, tex0).rgba; or something like that.