Shadows

2»

Comments

  • gribblygribbly Posts: 80Member
    @Killa_Maaki

    Just saw your post in between my barrage =]

    >That doesn't look right to me... what does it look like on PC?

    See above.
  • Killa_MaakiKilla_Maaki Posts: 504Member
    Yeah see... the PC one is what it's SUPPOSED to look like (the striping is because of how the depth is packed into RGB). The problem is most likely that on the OUYA it's not rendering at all what it's supposed to be rendering.
    Maybe replacement shaders don't work on Android??
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • Killa_MaakiKilla_Maaki Posts: 504Member
    AHA!
    I have solved the problem.
    It's because Shader.Find is returning null in the final build (also in webplayer)
    The solve is to instead:

    Make a public field in ShadowManager.cs (call it RenderDepthShader)
    Replace the call to Shader.Find( ... ) with that public Shader.
    In the Editor, drag the RenderDepth shader onto that new slot.

    Let me know if that works!
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • gribblygribbly Posts: 80Member
    edited March 2013
    >Maybe replacement shaders don't work on Android??

    That looks like a pretty good guess, as I can duplicate the problem on PC by commenting out this line in ShadowManager:

    //ShadowCamera.SetReplacementShader( Shader.Find( "Hidden/RenderDepth" ), "" );
    Post edited by gribbly on
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Try downloading the shader souce and drop it into Assets/Resources
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • gribblygribbly Posts: 80Member
    @Killa_Maaki - testing it now! That fix makes total sense.
  • Killa_MaakiKilla_Maaki Posts: 504Member
    I actually did a simple test where I made a web player build and was running into the same problems you are reporting - the shadows looked totally wrong. It appears to be that Unity is trying to be smart and determines that the shader shouldn't be included in the final build (after all, no material or object is referencing it).
    The fix is of course to replace the Find call with an actual, hard reference to the shader so that Unity is forced to include the shader in the build (and indeed that fixed the shadow issues in my test webplayer build)
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • gribblygribbly Posts: 80Member
    Yes, that fixed the problem - I now have a complete car shadow! Although I clearly need to tune the values a bit:

    image
  • gribblygribbly Posts: 80Member
    There's definitely some difference in shader output Ouya vs. PC. I made Shadow Map Coverage small (8) and the render large so you could see the output of depth shader on each platform.

    Here's Ouya:
    image

    And here's PC:

    image

    In my game the flies around over a simple static terrain that is ~6000x6000 Unity units across. What would be recommended settings for the Shadow Manager parameters for that case? The style of the game is deliberately retro/low resolution (as you can see from the screenshots), so I'm happy if the shadows are obviously pixelated (that's actually preferable).
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    You can tell it's OUYA with the over scan :)
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • Killa_MaakiKilla_Maaki Posts: 504Member
    I suppose the difference could be due to a difference in depth buffer precision (wild guess here)
    But it appears to work.. so that good.

    As for values, I can't really suggest anything. I suppose increase the coverage until it's far enough to look acceptable, and then play around with resolution.

    Perhaps 100 meter coverage, 1024 shadowmap size? See if that's fast enough for the OUYA.
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
  • gribblygribbly Posts: 80Member
    I took a break from this to submit my game (it got accepted, wooo! I'm a Day 1 launch title =])... shadows are disabled in that build. Will tune and include in the next submission.
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    @gribbly Congrats! Super happy for ya!
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • gribblygribbly Posts: 80Member
    Thx @tgraupmann, couldn't have done it without your help!
  • gribblygribbly Posts: 80Member
    Hey @Killa_Maaki I got back to working on this. I sent you a PM via OuyaForum... you can also check out some screenshots here:


    Here's descriptions for those shots:

    Editor1 - Default start position on editor. You can just see the shadow on the right edge of the car.
    Editor2 - I moved to the side and rotated the car a bit to make the shadow more obvious.
    Editor3 - Rotated some more to basically face the sun... I captured this angle because it's the only one that works on Ouya!

    Ouya1 - Default start position on Ouya. Shadow is invisible.
    Ouya2 - Similar angle to Editor2. Still no shadow!
    Ouya3 - Similar angle to Editor3. Now we can see the shadow (and it looks perfect!)

    Any idea why the shadow would behave so differently on Ouya? I don't need to support a PC version, so I'm happy to break the PC/editor shadows in favor of the Ouya shadows...

    Thx again for all the help,
  • gribblygribbly Posts: 80Member
    Updating this with latest progress. I'm really close to a solution that I haven't yet been able to solve:

    image

    So today I'm trying to figure out why the pixels below the "magic line" in the texture don't cast a shadow, as the downstream pipeline (i.e., actually projecting shadows into the world) works great and gives me exactly the kind of low-resolution look I'm hoping for!
  • gribblygribbly Posts: 80Member
    More progress!

    I've gotten to a pretty good place, but I'm not done yet as this solution is fragile. But I think it demonstrates it can work:
    image
    image

    To do this, here's what I changed:

    In ShadowReceiver.shader:

    //half4 enc = tex2D ( _ShadowMapTex, uv);
    half4 enc = tex2D ( _ShadowMapTex, uv).argb;

    ...and in ShadowManager.cs:

    //ShadowCamera.backgroundColor = EncodeDepth(0.9999f);
    ShadowCamera.backgroundColor = Color.white;

    This got me a full shadow on the car, regardless of rotation. Unfortunately, it also introduced a new artifact - a large shadow line in the middle distance (marked with yellow arrow):

    image

    I was able to reduce this artifact by setting these values:

    Shadow Map Coverage: 10
    Shadow Map Far: 3500

    This is not perfect... that far clip plane feels very large, and I still get artifacts in some situations. I don't this solution will scale to larger levels, for example. But it's progress.

    I am 99% sure that the problem lies in encoding/decoding the texture to/from RGBA. And I'm suspecting the decode, because if you look at screenshot number 2 here: 

    image

    ...you can see that the shadow map texture is still stripy, but it's the wrong color. 
Sign In or Register to comment.