PDA

View Full Version : Particle Distance shader ?


gagn
02-19-2008, 03:56 PM
Hi all,

I´m trying to achieve the following:

Particles, when in vicinity of a surface, color that surface.

Pretty much what this guy (http://forums.cgsociety.org/showthread.php?f=86&t=133066&highlight=particle+color+proximity) is asking for.

I´m using the Distance Shader from HIghend3d as a starting point.
I understand that I need to modify the distance expression, which looks like this:

float $array[]; //here are the distances stored

$array[0]=sqrt((l1.translateX-si.pointWorldX)*(l1.translateX-si.pointWorldX)+(l1.translateY-si.pointWorldY)*(l1.translateY-si.pointWorldY)+(l1.translateZ-si.pointWorldZ)*(l1.translateZ-si.pointWorldZ));
$array[1]=sqrt((l2.translateX-si.pointWorldX)*(l2.translateX-si.pointWorldX)+(l2.translateY-si.pointWorldY)*(l2.translateY-si.pointWorldY)+(l2.translateZ-si.pointWorldZ)*(l2.translateZ-si.pointWorldZ));
$array[2]=sqrt((l3.translateX-si.pointWorldX)*(l3.translateX-si.pointWorldX)+(l3.translateY-si.pointWorldY)*(l3.translateY-si.pointWorldY)+(l3.translateZ-si.pointWorldZ)*(l3.translateZ-si.pointWorldZ));
etc...


//we should find the minimum distance and store it in the first slot

int $i;
for($i=1;$i<8;$i++) if($array[0]>$array[$i]) $array[0]=$array[$i];

setDistRange.valueX=$array[0];

so that it instead of indicating the position of the locators, uses the particles´.

Has anyone done this?

Any help very appreciated.

Gabriel

alexx
02-20-2008, 08:45 AM
since that other post is really old; by now you can use mental ray to do that.

either an occlusion path to get the maps where to color the surface or by using an FG pass to have color light emitted by the particles.

cheers

alexx

CGTalk Moderation
02-20-2008, 08:45 AM
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.