Page 1 of 1

Texture Lookup in OSL Shader

Unread postPosted: Thu Oct 01, 2020 4:08 pm
by briansilva
Hello! When using OSL shaders, it's awesome that Clarisse creates parameters that can accept texture connections. That's working great for pulling a texture colour value at the current UV coordinate (or the other projections available in Projection mode).

However, I have a shader that's doing some complex calculations to determine the (u,v) coordinate to sample on a texture. Currently I just pass the texture file to the OSL shader, and it samples it. That's working great. But, I would love to be able to specify the UV of the connected texture input to determine the value of that colour coming into the shader. This would allow me to feed in something being live-rendered in Clarisse, which would be very useful.

Is there a way to do this with OSL in Clarisse? If I were to output the UVs from my shader, I still don't see a UV input on any of the map nodes, so I'm not sure how to drive a map lookup other than within OSL itself.

Any suggestions on how I might set this up?

Thank you!

Re: Texture Lookup in OSL Shader

Unread postPosted: Fri Oct 29, 2021 7:28 pm
by chanson
Actually, did anyone ever post a reply to this? I am wondering about the same issue.

While i can feed in a filename into an osl shader and call the texture inside the osl shader, it really breaks the entire purpose of having a material graph then, and being able to feed in texture nodes that possible are themselves manipulated etc.

Is there a way around this, to use say generated uv's from an osl script, and use those for the lookup on a texture? Is there an istropix clean way/approved way to do this in clarisse 5(or 4.0)?

Thanks!

Re: Texture Lookup in OSL Shader

Unread postPosted: Fri Oct 29, 2021 8:15 pm
by sam
The current OSL support has been intended to generate patterns. So no unfortunately that's not possible. Clarisse textures have UV Translate, Rotate, Scale but no Input UV Position (besides a UV Property) that would overwrite/drive the UV coordinates of the primitive. That would require a new projection mode that would take as input UV coordinates. I advise you add a feature request. The other thing to note is I'm not sure we would have enough information to be able to compute ray differentials from arbitrary UVs.

Re: Texture Lookup in OSL Shader

Unread postPosted: Fri Oct 29, 2021 8:49 pm
by chanson
Yea, i was wondering if there is anyway can make that possible, re: ray differentials. I opened up a feature request ticket, if it is entirely not possible I guess there is nothing much we can do. I am currently calling texture function in the OSL which just seems like such a bad way to do it.

If there was some abstraction inside osl that I could call the texture node itself explicitly setting uv's, and possible du/dv maybe. As i could probably calculate the du/dv in the shader possible, and feed it into a call, if such an osl function existed. ie create a handle for a texture node as a parameter and then have a way to use that inside the osl code specifying the uv's and du/dv when it is called/used.

But I'll leave the details to you guys since you probably have a way better handle on this stuff, but I really just want to be able to use a full texture graph, etc instead of just specifying a filename,which yea, seems to kind of break the Clarisse paradigm in the material graph....

Thanks very much again Sam. Definitely appreciate the help!