Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ideas on how to do these shadows....

Discussion in 'Scripting' started by Randy-Edmonds, May 9, 2007.

  1. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Any ideas on the best way to create shadows from numerous objects? Baked lighting won't work because the objects are randomly placed.

    This picture is very close to what I am trying to duplicate. Notice how each clover is at a random height and how the shadow may fall upon more than one other (lower) clover and on the ground.



    I have some ideas but none that are great. So I will leave it open for your thoughts. Any help will be appreciated. Thanks!
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Some ideas from the top of my head:

    Approximate shadows. For example, when placing the leaves somehow determine if some other leaf is above it; if so then darken it (via vertex colors for example). Could do this per-leaf or per-leaf-vertex. Going further of course would be almost complete "baking" of this shadowing information into a texture.

    Layer shadows. Each leaf gets assigned a height from a fixed set of heights (e.g. 4). Each height has it's own "lightmap" - a texture that has all leaves from the higher levels rendered into it. So when generating the leaves, assign heights and texcoords into this "lightmap"; when done with all the leaves, render one topmost layer into the lightmap for the 2nd layer, render topmost+2nd layer into lightmap for 3rd layer and so on.

    You could merge all layers into a single texture for performance reasons, and adjust UVs accordingly. For example, a 1024x1024 render texture would have four 512x512 layers.
     
  3. Randy-Edmonds

    Randy-Edmonds

    Joined:
    Oct 10, 2005
    Posts:
    1,122
    Thanks. The height/lightmap idea was what I was generally thinking too. Only bad thing about that is that it means the objects will have to be static. I'd like the objects to be able to move.... if possible.

    What about using blob shadow projections? Or would that be too big of a performance hit for this many objects?
     
  4. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    If the top layer was one object, maybe you could make a light cookie up that only renders layers below? perhaps you could split the leaves into a few horzontal layers(objects) and add more lights as the layers go down?

    More lights with cookies =more shadows? Yould probably have to make the bottom layer material quite dark as it would have the most lights on it

    Just an idea. I guess its that old"Performance vs Perfection" scenario...
    AC