Isotropix Forums

Texture Lookup in OSL Shader

Clarisse Scripting related topics

Texture Lookup in OSL Shader

Unread postby briansilva » Thu Oct 01, 2020 4:08 pm

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!
Posts: 70
Joined: Mon Mar 25, 2019 12:43 pm

Re: Texture Lookup in OSL Shader

Unread postby chanson » Fri Oct 29, 2021 7:28 pm

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)?

Posts: 7
Joined: Mon Apr 23, 2018 7:38 pm

Re: Texture Lookup in OSL Shader

Unread postby sam » Fri Oct 29, 2021 8:15 pm

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.
Sam Assadian
User avatar
Posts: 1827
Joined: Fri Jan 25, 2013 11:33 pm

Re: Texture Lookup in OSL Shader

Unread postby chanson » Fri Oct 29, 2021 8:49 pm

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!
Posts: 7
Joined: Mon Apr 23, 2018 7:38 pm

Return to Scripting