View Full Version : constant sprites size based on camera distance ?
09-18-2003, 08:50 AM
I have a huge amount of particles that represent stars. I used sprites so that I can map my own star picture on each particle.
I would like to create an expression that change the size of the sprites based on the distance between them and the camera so that when rendered all sprites look the same size.
Any idea ? I'm sure it is easy but I'm not good with expressions at all.
Thanks in advance for your help !
09-18-2003, 04:50 PM
Create a locator and point constrain it to the camera.
Now go to the particleShape node and add a custom per particle float attribute. Name it 'distance' or something. Then in both creation and runtime expressions write something like the following:
vector $vectorDistance = <<locator1.tx, locator1.ty, locator1.tz>> - position;
distance = mag($vectorDistance);
Then add two more per particle attributes: spriteScaleXPP and spriteScaleYPP
Now you can use the distance between the camera and the particles to control the scale of the sprites to suite your needs.
09-18-2003, 05:03 PM
one word : PERFECT !
Thanks a lot rhankins !:beer:
09-18-2003, 07:37 PM
I just wrote what you said and made a simple equation :
vector $vectordistance = <<locator1.translateX , locator1.translateY , locator1.translateZ>> - particleShape1.position ;
particleShape1.distance = mag($vectordistance) ;
particleShape1.spriteScaleYPP = (1 * particleShape1.distance)/100 ;
particleShape1.spriteScaleXPP = particleShape1.spriteScaleYPP ;
thanks again !
09-18-2003, 09:10 PM
(1 * particleShape1.distance)/100
I guess that the multiplation of 1 does not help very much in this case.
:: Galactor ::
09-18-2003, 09:36 PM
Why the hell did I multiply by 1 ?????:hmm:
I really should go to bed I'm very tired !
01-16-2006, 04:09 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.