Search Unity

particle system rotation info into a shader

Discussion in 'Scripting' started by eyalfx, Nov 9, 2010.

  1. eyalfx

    eyalfx

    Joined:
    Oct 8, 2010
    Posts:
    108
    Is there any way to get particle info into a shader?
    I'm trying to get transformation info so I can treat the shader based on particle rotation.
    And while I'm at the subject....
    Is there any way to orient particles towards the direction(velocity) they are travelling to?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You can use the SetXXX functions of the Material class to pass values from a script to a shader (you probably want SetFloat to pass the angle of rotation). There isn't a setting to rotate particles to align with their velocity but you can do this from a script using the particle emitter's particles array.
     
  3. eyalfx

    eyalfx

    Joined:
    Oct 8, 2010
    Posts:
    108
    Andeeee, I've only been using Unity for 2 weeks and very impressed with the engine. although I was very disappointed from the particle system, until now :)
    being able to control every variable in the particles array is like using Houdini or Maya for effects animation. Its AWESOME!
    And SetFloat to pass any parameters to shader... you've just added renderman to the mix.
    Thanks a lot for a very useful information.
    Let the fun begin.