Sorry this is going to be abit long, I want to make sure there is enough context for my questions and show what I have tried so far.
When creating procedural materials I often find it to create masks using ramps or using mathematical expressions. I am used to working in object coordinates something like the center of the object is (0,0,0) and the bounding box goes from -1 to 1 for each of the coordinates.
The built-in ramps seem to only work with UV coordinates or projections which is inconvenient when the object is not UV unwrapped, and projection causes issues if the object moves.
I read Lurk Lurksons question about creating ramps using object coordinates here https://answers.arnoldrenderer.com/questions/27997/ramp-in-object-space.html
where Peter Horvath suggested using the state_vector shader to read the object space coordinates (Po).
I created a rectangular object, translated it by 2 x and 2y then froze the transforms and fed the state vector (PO) into a aiFloatToRGBA node and rendered that out.
From this it looks like (PO) is not at the center of the object once you freeze transforms.
Using a aiMatrixMultiplyVector node with translate set to -2,-2,0 I am able to get the expected result. I had thought it would be 2,2,0 since the object was translated by 2,2,0 but I must be confused about the direction of the vectors.
Then I can create the desired ramp using a remapvalue and aiRamprgb node.
Anyways onto my questions
1. What is going on with the translation being (-2,-2,0) to center the object coordinates when the object is translated (2,2,0) then frozen? This seems backwards.
2. it possible to access the objects center after a frozen translation without using an aiMatrixMultiplyvector node? This would be useful when the previous translations are no longer known.
3. I was trying to shift the values by adding instead of using mapping nodes and ramps, but the aiWriteFloat node does not appear to do anything and I am not sure what the “beauty” slider is. I can’t seem to find this node in the documentation. It looks like what I really want is aiUserData, but I am still wondering what aiWriteFloat is for.
3. there a better way to create effects like this masked off circle gradient? I find the switching between float to color confusing (although they both seem to be floats?)
4. If you use a camera(or some other type) projection to create a mask or ramp, is there a way to convert it into object coordinates so that you can get rid of the projection and keep the mask/gradient once the object is moving?
Solved! Go to Solution.
Solved by brian_Foley. Go to Solution.
You will probably be better off using the Utility Shader set to relative bounding box with the RGB(XYZ) values driving an aiRamp set to Custom.
Also, take a look at:
https://docs.arnoldrenderer.com/pages/viewpage.action?pageId=86806359
for other variations.
You don't need a projection node to get angles and stuff going, but if you want you can just link the camera transform to the object so whenever you move, rotate the object the camera follows.
For these things you want to do, I would write a single OSL shader to cover all your cases of needs to keep things simple in the node canvas.
I will give that a try, looks like a great way of going about it. Thank you! I wish I could mark this as answer too.
Thanks for the help, OSL sounds like a good option. Regarding the 3rd question about aiWriteFloat, could you explain what that is for or point me towards some sort of documentation for it. I had originally thought it had the functionality of aiuserdata, but it doesn't seem to do anything when I use it in the node network. Apologies if its obvious, I haven't had any success finding information on it.
You have 2. points with 3, which one is it?
The first one with the FloatWrite, that is a node that does not directly do anything in a shading relation, it is a node you picked up in the AOV section I believe.
This node is used to write a Float AOV one you connect to the AOV manager as a custom AOV for example, its the output of whatever data you process, as a float ( you set the custom AOV to float and source this data chain.
For the second 3.
shader Sphere ( point Po = point(u,v,0), float d = 0.1, output float Out = 0, ) { Out = 1-length(Po-vector(0.5,0.5,0))-d;; }
Ah apologies for having two 3s. I meant the first one, but the answer you provided for the second one is very helpful as well. Thank you so much for sharing your knowledge with me.
Can't find what you're looking for? Ask the community or share your knowledge.