question

Jesse Cushing avatar image
Jesse Cushing asked ·

Afew questions regarding working with object coordinates and projections

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.

po-to-rgb-with-frozen-translation.jpg

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.

po-to-rgb-translated.jpg

Then I can create the desired ramp using a remapvalue and aiRamprgb node.

object-coordinate-y-ramp.jpg

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.

aiadd.jpg

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

circle-gradient.jpg

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?

mtoashadermaterial
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Brian Foley avatar image
Brian Foley answered ·

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.

bbox.jpg


Also, take a look at:

https://docs.arnoldrenderer.com/pages/viewpage.action?pageId=86806359

for other variations.


bbox.jpg (68.7 KiB)
2 comments
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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.

0 Likes 0 ·

You should denote my answer as accepted and accept his answer instead.

1 Like 1 ·
Mads Drøschler avatar image
Mads Drøschler answered ·

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.

3 comments
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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.

0 Likes 0 ·

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.

qwe.png


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;;
}


1 Like 1 ·
qwe.png (169.0 KiB)

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.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.