how to script a fade out

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  08 August 2009
how to script a fade out

I have some news papers falling which I have simulating with ncloth. I would like to be able to control their opacity so that at a certain distance from the camera they start to fade out.
I don't really know how to do this.

Could someone give me some advice of how to achieve this?
  08 August 2009
Hi flore33

I would prefer to build a node network to achieve what you ask for, but if you want to do it with an expression then you could writ it like this:


//Give Name of current camera

//Get cameraPosition

vector $camPosV = `xform -q -ws -t camera1`;

//Give Name of clothmesch

vector $spherePosV = `xform -q -ws -t pSphere1`;

// PosCamera minus PosMesh

vector $lenghtV = abs( $camPosV - $spherePosV);

// Lengh of Vector

float $lenghF = mag($lenghtV);

//Change Expression like this: linstep "your startFade", "your endFade"

float $oppacety = `linstep 18 25 $lenghF`;

// revers

float $oppacetyNeu = ($oppacety*(-1)+1);

// set the transparenty attribute of the shader: "your Shader.transparency. ..."

lambert1.transparencyR = $oppacety;

lambert1.transparencyG = $oppacety;

lambert1.transparencyB = $oppacety;



  08 August 2009
I am trying to learn more how to script so thank you very much for your help.
  08 August 2009
Hi flore33

I did not consider that the transform of your clothmesh will not move so better calculate the boundingBox:

//Give Name of clothmesch
float $spherePosFArry[] = `xform -q -ws -bb pSphere1`;
vector $bbmin = <<$spherePosFArry[0],$spherePosFArry[1], $spherePosFArry[2]>>;
vector $bbmax = <<$spherePosFArry[3],$spherePosFArry[4], $spherePosFArry[5]>>;
vector $spherePosV = `hermite $bbmax $bbmin <<0, 0, 0>> <<0, 0, 0>> 0.5`;


  08 August 2009
Hi RuthW

Thank you so much
  08 August 2009
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 10:30 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.