How to transform image (diffuse texture) on a 3D object in shader

 

Most shaders have a Tex Coord Transf property, but for special effects you might want to do additional operations.

You can open a shader like you open an xcomp file.

We highly recommend to always use an existing one as a starting point.
To begin we suggest checking basic.xshad out first. 

Also make sure that you never overwrite a built-in shader. (Best to copy it or do "save as...")

When you open a shader it contains two blocks: Vertex and Pixel.

It is best if you do this modification in the Vertex block. You can enter by double clicking it.

It will contain a Material Vertex Input 1 box that has a Tex Coords 1 output.

In most shaders there are a few operations in this value and at the end it enters into Material Vertex Output 1.

This Tex Coords 1 is a 2 dimensional vector. (In other words: two values)

First one is the X, second is the Y coordinate of the image. (usually called "U" and "V" in computer graphics)

If you want to shift your image then you can add a value. To be more precise you have to add a 2 dimensional vector.

You can use Add to add two vectors. 

1 means a full image size. So if you want to shift your image 50% in X coordinate and 10% in Y coordinate then you have to add (0.5,0.1).

If you want to scale your image then you have to multiply this vector. (in this case also you will multiply two vector component by component)

After your changes you have to save the shader to actually see the changes. (you can have an open active scene while you edit your shader but it is not mandatory)

It will take some time to do the refresh.

Also make sure that you are using the correct shader in your scene.

We highly suggest always doing small changes and testing regularly.

   Aximmetry

;