Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to rotate a texture using OSL

0 REPLIES 0
Reply
Message 1 of 1
maxrose8841
283 Views, 0 Replies

How to rotate a texture using OSL

I have a simple OSl script that renders a Matcap texture created in Photoshop. I want to be able to rotate the texture, so that - for example - if I have a Matcap that fakes a rim light I can rotate it to make it look like the rim is coming from another direction.

I followed a tutorial from this page, but the result I got isn't what I wanted.

http://www.fundza.com/rfm/osl/tex_rotate/index.html


Is there a way to simply rotate the incoming texture using OSL?

Here's the code I got so far (pieced together from several sources...)

shader SimpleMatCap
(

string filename = "" [[ string widget = "filename" ]],

float Gamma = 1.0,

float s = 0 [[int lockgeom = 0]],
float t = 0 [[int lockgeom = 0]],
float angle = 0,
float pivot_s = 0.5,
float pivot_t = 0.5,

output color result = color(0, 0, 0),
output float resultS = 0,
output float resultT = 0
)


{
vector Normal_camera = transform ("world", "camera", N);
float norU = clamp (Normal_camera[0] * 0.5 + 0.5, 0.0, 1.0);
float norV = clamp (Normal_camera[1] * -0.5 + 0.5, 0.0, 1.0);
color c_out = texture (filename, norU+s, norV+t);

result=pow(c_out, 1/Gamma);


point pntST = point(s, t, 0);

point p1 = point(pivot_s, 0, pivot_t);
point p2 = point(pivot_s, 1, pivot_t);
point rotatedImg = rotate(pntST, radians(angle), p1, p2);

resultS = rotatedImg[0];
resultT = rotatedImg[2];
}


Tags (1)
Labels (1)
  • OSL
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report