Search Unity

Customizing particle shaders

Discussion in 'Shaders' started by akira3d, Jul 30, 2011.

  1. akira3d

    akira3d

    Joined:
    Jun 28, 2011
    Posts:
    10
    I spent the day attempting to modify particle shaders / adapt surface shaders for use with Unity's particle system and, after a bit of debugging, came to the conclusion that not much data is actually passed into the shaders.

    The particle renderer only appears to drive vertex color, UVs, and position. These are accessible from shader programs, but not entirely in the ways I had hoped.

    Within particle shaders, vertex positions already appear transformed into view space, normals are not transformed (so supplying a bump map is not really an option), matrices (_Object2World, _World2Object, UNITY_MATRIX_MV, etc) and useful vectors like viewDir, worldNormal contain no useful data. This appears true in vert, frag, surface shaders, and custom lighting functions.

    Without these, I cannot figure out how to achieve lit particle effects...nor can I figure out how to calculate the scale of particles to achieve more interesting depth blending effects than the basic soft particle shader that is provided.

    Am I missing something?
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Particle normals are always (0,0,-1) in view space. Lighting and shadows work fine on particles. Which version of Unity are you using?
     
  3. akira3d

    akira3d

    Joined:
    Jun 28, 2011
    Posts:
    10
    I'm using Unity Pro 3.4.0f5.

    I am trying to customize lighting on particle shaders (vertex lit with spherical normals or supporting the use of normal maps, ramp shaded). The particle shaders that came with Unity only appear to support flat vertex lighting...which is not the look I am going for.
     
    Last edited: Aug 1, 2011