# transform texture coords within OSL?

Is it possible to transform/affect the texture coords from within the OSL shader?

I would like to be able to have my shader slip the input texture around on the surface of my object which already has uv coordinates.

• do you want something like the mapping node or all in one solution ? Feb 10 '15 at 9:05

From the osl language specification under Global Variables -

point P - Position of the point you are shading. In a displacement shader, changing this variable displaces the surface.

float u, v - The 2D parametric coordinates of P (on the particular geometric primitive you are shading).

While you don't technically alter these values, you start with them and calculate an offset position that is then used to choose the output.

• the u, v are generated coordinates for the triangulated mesh Feb 10 '15 at 13:07
• So I'm able to create an output which I can then use to translate a separate texture node, but is there any way to effect u and v from within the current OSL shader? Feb 10 '15 at 17:54
• Actually, as I am using more than one texture map which I need located in different positions, what I really need is a way to change where that map is positioned on the object without changing u and v. Feb 10 '15 at 18:00
• @P-Rod do you need to modify the UV layout, or just switch between different UVmaps if this is the case use getattribute("UVmap", UV) Feb 10 '15 at 21:41
• @P-Rod You can use getattribute() in your script and either hard code the uvmap names or have several string input sockets to choose the uv's used. You can also use vector input sockets and have a uvmap node to input a chosen uv, this also allows you to add a mapping node in between to adjust the input to the script. You also don't need to do everything in one script, this vector math script can alter the uv's input so other nodes use the altered uv's. You often find an osl script as just one node among many. Feb 11 '15 at 1:00

if you can get the texture coordinate from another node " since getattribute is not woring " what is lef is a simple vector manupilation here is simple osl code for shift and scale :

#include "stdosl.h"