"distance to" in RenderTree???

Discussions regarding Materials, Material-Compounds or Shaders, etc.
Post Reply
User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

"distance to" in RenderTree???

Post by Hirazi Blue » 05 Apr 2011, 13:37

I am doing some NPR experiments and now I was wondering if there an elegant way to get the distance of an object (point to be shaded) to a light/camera/null in the RenderTree? I guess I can solve this using one of the Proximity Map generators out on the web, but I would like to know if this could be done with on-board/non-ICE/RenderTree tools only...
:-\
Stay safe, sane & healthy!

User avatar
rray
Moderator
Posts: 1775
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: "distance to" in RenderTree???

Post by rray » 05 Apr 2011, 14:40

It's possible directly (for point objects):

(Ingredients)
Vector_State node (set to "Intersection Point" - this outputs the position of the rendered point)
Vector_Save_state node (set expressions for X,Y,Z to the null's X,Y,Z respectively - outputs the nulls position)
(Plug into vector_input1 and 2 of)
Vector-Vector node, set to "Vector Input 1-Vector Input 2" (outputs difference vector)
(Plug into V1 of)
Vector-Scalar node, set to "Length of V1"
(Plug into)
Scalar to color
(Plug into)
Surface of Material

For this example the colors get black when you move the null close to the shaded surface
softimage resources section updated Jan 5th 2024

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: "distance to" in RenderTree???

Post by Hirazi Blue » 05 Apr 2011, 17:03

Ah, I knew something must be possible in good old-fashioned RenderTree style.
Thanks for the info... ;)
Stay safe, sane & healthy!

User avatar
druitre
Posts: 471
Joined: 25 Jun 2009, 23:35

Re: "distance to" in RenderTree???

Post by druitre » 07 Sep 2011, 14:32

Hi, I found this thread when searching for an answer on how to change a material's attributes based on distance to an object or camera. For instance, changing color the closer to the camera, or fading into full transparency etc.

I followed the explanation above and this works - it gets me a black dot when the null is close to the surface of my object. The dot is always the same size though, and always black. How do I use this to create a gradient on color/transparency etc etc with controllable falloff?

Or is there another method altogether for that type of effect?

User avatar
rray
Moderator
Posts: 1775
Joined: 26 Sep 2009, 15:51
Location: Bonn, Germany
Contact:

Re: "distance to" in RenderTree???

Post by rray » 07 Sep 2011, 17:50

Hi, in that case you can use a mixer->gradient node instead of the "scalar to color" node. By modifying the gradient you have full control over radius/colors.
Be sure to use mixer->gradient node, not the texture->gradient node.
softimage resources section updated Jan 5th 2024

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests