Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Particle system casting shadows on the scene

Discussion in 'General Graphics' started by raja-bala, Mar 11, 2015.

  1. raja-bala

    raja-bala

    Joined:
    Jul 11, 2012
    Posts:
    29
    I'm working on a volumetric particle system which accounts for light propagation to get realistic looking particles. Currently, as you can see in the attached image, I have a decent self-shadowing look and also account for the scene casting shadows on the volume (it looks ugly though).

    I'd love to have the volume cast shadows on the scene, and to do this the right way, I'd have to sample the light propagation texture for each object and use the attenuated light factor in the direct lighting part of the equation.
    But, this would probably require changing every built in shader (not sure if I can change the include file to do this once and be done).

    If that isn't a possibility, I was thinking of a full-screen pass post-rendering the scene that uses the light propagation texture to shadow already lit pixels.
    The pass would work as follows:
    foreach pixel of the camera render target
    reconstruct camera view space x,y,z for the pixel (store in A)
    transform A to light space (store in B)
    if B.z > lightProgationFarPlane.z (i.e., scene object is behind volume wrt light)
    sample light propagation texture to get attenuated light factor (store in C)
    multiply scene pixel by C to account for the volume cast shadow​

    This wouldn't work well with multiple light sources (since the directional light shadow cast by the volume affects the final color of the pixel instead of just it's contribution).

    Any tips on how I can achieve this? The source is available here.

    Also, if Unity 5 already supports (volumetric or not) particles casting and receiving shadows, please let me know too.

    Cheers,
    Raja
     

    Attached Files:

  2. raja-bala

    raja-bala

    Joined:
    Jul 11, 2012
    Posts:
    29
    Bumping this thread up. I still haven't figured out a way to attenuate the directional light to simulate particle shadows.