PDA

View Full Version : Sprite Scale driven by image


triptych79
04-14-2008, 07:32 AM
Hi,

I have sprites being emitted from a plane. The emission is being controlled with a gray scale image. I was wanting to drive the scale the of emitted sprites with the colour of the image (ie. the lighter the colour, the smaller the sprite). How would I go about doing this?

Thanks,
trip

Aikiman
04-14-2008, 08:08 AM
At a guess use colorAtPoint command to reference the texture where the particle is born which will give you rgb values. Then perhaps wrap that in a mag function so you get a single float value which you then apply to your scale X and Y.

phildog
04-14-2008, 08:36 AM
did you know you can emit into rgbPP using the same texture?
just add the same texture to the emit color slider of the emitter
then add an rgbPP attribute to the particles.

you dont have to use this rgbPP to render (infact sprites ignore it) but you can use
the value to do a mag() like Jeremy said before

Hi,

I have sprites being emitted from a plane. The emission is being controlled with a gray scale image. I was wanting to drive the scale the of emitted sprites with the colour of the image (ie. the lighter the colour, the smaller the sprite). How would I go about doing this?

Thanks,
trip

triptych79
04-14-2008, 12:52 PM
Thanks to both of you for your help. It worked a treat - I tried Phil's method first up as it seemed the easiest. No doubt the other approach would have worked too.

I had another question which I don't necessarily want to do, but 'thought' of doing. Instead of inverting the image and the 'Emit from Dark' to basically invert the scale of the sprites, is there a way, using expressions, to set a new range for the values outputted by the rgbPP? For example, just say I wanted to make dark values of the image emit the scale that a lighter value would and vice versa.

I know it could be done as I had mentioned with the texture before, but is there a way or a particular function that allows it to be done with expressions?

Thanks again.

Aikiman
04-14-2008, 10:00 PM
Phils the expert but Im keen to have a stab. From my understanding if you subtract a linstep function from 1 yet get the reverse happening. So by using your min/max values from the mag function and using the 1 - linstep, you can reverse your values that way and apply that to your scale X and Y.

triptych79
04-15-2008, 12:25 AM
Hey Jeremy

Thanks for the reply. It worked!

Cheers,

trip

CGTalk Moderation
04-15-2008, 12:25 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.