PDA

View Full Version : Distance to Cam Gradient (not ray length)


jeremyhardin
10-02-2006, 01:09 PM
Hi all. I need to shade an object based on distance from the camera. black for nearest, white for farthest.

Limitations:
1. I can't use the normal routes because my objects are inside transparent refractive objects. So no using the default depth pass.
2. I can't use ray length, because the transparent refractive objects ruin that setup (as they alter the rays).

So ideally, I suppose I would need an expression or something to measure the distance between that object's location and the camera and pipe that into a gradient.

Does that make sense? Oh, and I need it today. Haha. I love how that goes.

JDex
10-02-2006, 02:36 PM
I'm not sure how you could get it to work with just a gradient... gradients generally need a texture projection, making them 2D in nature.

In the BA Volume shader pack (http://www.binaryalchemy.de/) there is a handy shader called BA_volumescalar_primitive that is designed to create a cube or sphere with falloff within a volume... you "could" apply a global material to all of you geometry using this shader set to sphere with it's origin at the camera location and adjust the falloff accordingly. I have not tried it however... if memory serves, the shader has a radius limitation, and I'm not sure if it's just a spdl setting, or if it's a true limitation of the shader. If you already have this pack, try it out. I'm nit sure you should buy it, just for this as there is probably another way.

Perhaps a point light at the camera's position with a linear falloff could get you started.

JDex
10-02-2006, 03:03 PM
Of course the solution in the XSIbase thread looks promising.

http://www.xsibase.com/forum/index.php?board=12;action=display;threadid=27083;start=1#msg175089

jeremyhardin
10-02-2006, 03:55 PM
Thanks JDex.

As to the suggestions on XSI Base:
I thought that might be it at first, but I still can't seem to get results out of it.

My suspicions:
1. My objects are point-baked using point oven for animation. So they have no SRT information.
2. Would the fact that these are REF LOCKed have anything to do with it?

(btw, this is true with or without the refractions I mentioned earlier).

As to your point light suggestion:
It seems like it just might work. The problem I'm having with that is the rolloff of light on the object's surface. Any out-there ideas that could handle that? :D

jeremyhardin
10-02-2006, 05:00 PM
In my desparation I tried volume fog, only to leave me feeling quite daft. The volume fog treats the transparent objects properly. So using solidly shaded objects with volume fog seems to be working properly after all.

Thanks again JDex.

CGTalk Moderation
10-02-2006, 05:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.