FORUMS: list search recent posts

need help with distance based shader :)

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
alek panfilov
need help with distance based shader :)
on Oct 6, 2007 at 2:50:28 pm

hi all,
i'm making an animation were i need to make a shader with color value based on distance of object (with that shader) from camera.
i.e. if object is close to camera it's red , in the middle it's pink , far - it's white.

as i know it's possible to make such shader network , but i don't know how .

can anybody help me , please :)


Return to posts index

Steve Sayer
Re: need help with distance based shader :)
on Oct 7, 2007 at 1:29:10 pm

Hi, Alek.

Do you want the colour of the entire object to be affected simultaneously, or do you want the closer sections of the object to be one colour, while the farther sections are another?

I assume the latter, in which case your Hypershade network could look something like this:

[samplerInfo node] -> [distanceBetween node] -> [setRange node] -> [ramp node] -> [material node]

The connections would be as follows:
samplerInfo.pointCamera -> distanceBetween.point1
distanceBetween.distance -> setRange.valueX
setRange.outValueX -> ramp.vCoord
ramp.outColor -> lambert.incandescence

Then you have to choose appropriate values for the 'old min X' and 'old max X' values of the setRange node, based on what distance you want the ramp to vary over. For example, if you wanted parts of the object within 20 units of the camera to be red, and parts beyond 100 units to be white, set 'old min X' to 20 and 'old max X' to 100. Create a red-pink-white ramp and you're all set.

Good luck--post again if you need more direction.


Return to posts index

alek panfilov
Re: need help with distance based shader :)
on Oct 9, 2007 at 8:53:22 pm

Hi :)
Well , first of all , thanks for help :)

but i've got a problem , maybe i'm missing something like connecting camera to sampele node , i've tryed with it but it didn't help.

http://www.dzeday.pl/maya-test.jpg
here's jpg with a view of shadernetwork i've made with your help , have a look at it.

polygon at render view is 150 units long, old_range at setrangenode are both 0. ; when i change min.or max. to anything , ramp is changing to bottom color of the ramp. with standart maya's ramp it's red.

basicaly it should work but it's not :)

thankyou for any further help :)



Return to posts index


Steve Sayer
Re: need help with distance based shader :)
on Oct 10, 2007 at 5:36:14 am

Hello again.

I see that you've got a 2d texture placement node plugged into your ramp: you don't need one, and it might be causing the problems. Delete it, and make sure the setRange output is plugged into the V-coord of the ramp (which should be a V ramp). Then you will hopefully be able to edit the min/max values of the setRange and get the desired results.

As for your other post, I think this method should work fine for all those objects, as long as you apply the same material to all of them and choose appropriate min/max values for the scene.

-Steve


Return to posts index

alek panfilov
Re: need help with distance based shader :)
on Oct 10, 2007 at 10:15:20 am

i gona cry but removing 2dtexture_placement_node didn't help :(

i've tryed to connect camera to normal_camera at [sampler node],
it helped a little , but i don't get smooth ramp of color at object instead of that i get faces colored by max and min colors of ramp. if i move camera colors are changing but still covering full color on face of obj.

:)

alek


Return to posts index

Steve Sayer
Re: need help with distance based shader :)
on Oct 11, 2007 at 7:14:34 pm

Hi again, Alek.

Don't connect any attributes other than the ones I named in my initial post; the 'normalCamera' attribute is for bump mapping etc.

Can you upload your scene as a Maya ASCII file (.ma) for me to take a look at?

-Steve


Return to posts index


alek panfilov
Re: need help with distance based shader :)
on Oct 9, 2007 at 9:04:42 pm

one thing i've forgot,

here's screen of what i will use this shader for

http://www.dzeday.pl/city.jpg

i'll try to explain what i'm into,
maybe you can help me to solve it in another way instead of making shader.

i want to color objects in the city while camera moves thru it
using distance of ANY/EVERY object from the camera

for ex. we have a ramp from color 1 to 2
the strait road in front of us should be a nice gradient from color 1 to 2.
roads in back are colored 1.5
buildings at horizont are 2

but when we get closer with the camera to the crossroads, our color scheme is moving with us ;)

this way objects near camera are intensive red and those far away are white so they can mix with background etc.

:)

alek.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]