Hello, I wanted to learn how to write OSL Code for VRay in Maya. My goal was to write code rather than having to put together tons of nodes in maya just to do simple mathematical vector operations for example. The graph gets way too messy very quickly and not even speaking about accidentally hitting the wrong button or adding a node and suddenly the whole graph gets messed up.
So I wanna use OSL to define texture and numerical inputs, do stuff with them through code and then output a color. So I'm using the OSL-Texture node for that. Then I wanna use that output in a standard VRay-Material for example. (I don't wanna use an OSL Material, I just wanna modify a texture and use it in the standard materials.)
Now to my actual problem, I'm basically still stuck at square one regarding textures, because the "u" and "v" global variables seem to be not accessible. I've tried to simply just output the uvs by having my output = color(u, v, 0); yet it still only shows black. In the Open Shading Language specifications it says that "float u" and "float v" should be global variables that are "The 2D parametric coordinates of P (on the particular geometric primitive you are shading)."
I was trying to go around this, by defining a vector input and plugging in the uvOut from a placement-node in x and y and I also tried plugging the samplerinfo uvCoords in there, but it always just shows black.
My Test mesh does have a UV-Layout called map1.
For anyone to recreate, here is the simplest osl-code involving uvs that is already not working for me. I would expect this to be a red-green uv gradient, but instead it shows black. Use it in a Vray OSL-Texture node and plug it into the Diffuse or Self-Illumination Color of a VRay Standard Material:
Code:
shader uvTest ( output color result = color(0.5) ) { result = color(u, v, 0); }
Maya version is 2018.7
V-Ray 5 for Maya, update 1.2
(v5.10.22 from Sep 29 2021)
Thank you for any help.
Comment