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. Dismiss Notice

Baked/Dynamic Shadow Maps iOS (a la Bladeslinger) Source included

Discussion in 'Made With Unity' started by brianasu, May 18, 2013.

  1. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    A while ago I read this article
    http://blogs.unity3d.com/2013/01/15/bladeslinger-pushing-the-boundaries-part-i/

    I wanted to implement the static shadow maps algorithm except not as a projector but using shadow mapping techniques. This is a basic shadow map routine with no frills.






    Instructions
    -----------------
    Make sure all the objects you want shadows cast on use the Diffuse or Unlit Shadow Map shaders.
    Hit GameObject -> Create Other -> Shadow Map Baker to create a shadow camera.
    Select the Shadow Camera gameobject that was created
    Aim it so your entire scene is inside. You can adjust near/far and ortho size but keep it as small as you can
    Select resolution
    Hit Bake and save it to a folder inside your project
    adjust the bias to prevent artifacts

    If you hit realtime then it will render a shadowmap each frame.
    Requires Unity pro. But technically the static shadow maps only need it for baking.

    Only tested on Mac

    Source is included:) If you feel like giving a small donation for the demos it would be appreciated:).


    Dropbox Link
    -------------------
    https://dl.dropboxusercontent.com/u/17249329/baked%20shadow%20map.unitypackage

    My other demos
    -----------------------
    http://forum.unity3d.com/threads/182296-GPU-Water-ripple-effect-Desktop-and-iOS-source-code-available

    http://forum.unity3d.com/threads/180769-2D-dynamic-soft-shadows-(will-release-source-later)


    More to free stuff to come!
     

    Attached Files:

    Stardog likes this.
  2. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    could this be used on unity indie for static shadows?
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723

    You could bake those shadow maps elsewhere but it'd be more trouble than it's worth.
     
  4. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    Yeah you're right hippocoder. I think it might be possible to do a RenderWithShader and copypixels to create the depth buffer so it would be fully indie compatible. I might give that a go.
     
  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Sorry for waking an old thread, but... Want me to port it to indie? I can! ;) (I actually did a while back, but deleted it by accident... :D)

    Again, will port it again if anyone wants me to! :)
     
    Deleted User likes this.
  6. CampioneDev

    CampioneDev

    Joined:
    Feb 9, 2015
    Posts:
    4
    Hi FuzzyQuills, I would definitely and extensively use an indie port of it for the project I'm working on. If you are willing to do it again, could you please post it here? PM me if you prefer.
     
  7. dirtybassett

    dirtybassett

    Joined:
    Oct 3, 2012
    Posts:
    59
    Could really use this in my project.
     
  8. Deleted User

    Deleted User

    Guest

    Hey Brian,

    Thanks for posting this up. This technique looks super useful! I was wondering if you had a Unity5 compatible version, I downloaded the package but some of the scripts and shaders didn't compile properly.
     
  9. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
  10. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
  11. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    I've updated a few of my libraries including the water ripple one. Time to get off my lazy arse:)
     
  12. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    LOL. :D

    Anyway, which one's the water ripple one? sounds interesting.

    EDIT: nvm, found it via google, damn that's impressive. :) I'll have to try that someday when I need decent water in one of my game worlds!
     
  13. softscience

    softscience

    Joined:
    Jan 30, 2014
    Posts:
    5
    This is extremely rad! I'm wondering if there is a way to add an additional normal bias or slope-scaled depth bias, to help deal with some of the shadow acne?
     
  14. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    For a normal bias, I'm not quite sure how that works, but if all it needs is to offset all the verts by a tiny amount... try using a custom shader on the shadow map camera (aka. use SetReplacementShader) that "squishes" the meshes slightly using the normals as the direction to "squish" in. :)

    I can try writing a template to start off with. As for your second request... slope-scaled depth bias ain't my cake unfortunately. ;)