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

Question about hard shadows with one directional light

Discussion in 'Editor & General Support' started by Kirlim, Nov 8, 2014.

  1. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    Hi!

    I am currently making some toy-demos trying to figure out techs for a new project. I have a very big tile map (256x256), where each tile has its own quad. The quads vertices are defined by a heightmap. The aim is to have a tiled map like the ones seem in Sim City, but 3d.

    I want the map to be able to project shadows on itself dynamically, with a rotating directional light simulating the sun. The question is, is the built in Hard Shadows with directional light too heavy for this context? Besides the terrain, I'd like that some simplified buildings geometry would project shadows as well. (or, for example, trees and forests). Mountains might project shadows very far on the map, when the sun is rising or setting.

    Here's a demo without buildings of what I meant (but here, the shadows are vertex mapped). The map geometry is more complex than what I intend to use.
    https://dl.dropboxusercontent.com/u/10307038/varr/build3/varr_build.html
     
  2. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Whether thats too heavy or not really depends on what hardware you're targeting & what else is happening in your project.
    If you were to do a mockup with some placeholder buildings & trees and the like (roughly approximating what you'd see in the completed game), what sort of draw calls do you get?
     
  3. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    I'm targeting for pc, so I'd guess a few thousand draw calls.

    I've been studying about shadow maps these past few days, and now I get it that my question was rather meaningless. I'll collect some assets to do some testing as you suggested.
     
  4. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    It shouldn't be too much of a problem - if you're tight about using duplicate meshes, atlas textures, etc, with the various objects on the terrain, then batching should keep draw calls pretty low
     
  5. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    I'll keep that in mind, thanks!
     
  6. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    In case anyone was interested, I did a mockup scene with a few cubic buildings. I used two different meshes. One for the building and shadows receiver, another for the shadow caster. And then used this shader for the shadow casters:
    http://answers.unity3d.com/questions/269292/having-an-invisible-object-that-casts-shadows.html

    So far, it works quite well and with a good performance (and my notebook is quite weak). But since the numbers are huge (map 2560 unity units wide) there is some visible flickering, so I need to keep the scales and max shadows distance down and shadowmaps details high. There goes my vision of the neighbour mountain casting shadows on the village at sunset...

    But I doubt the player would notice the shadow lacking, anyway.