Search Unity

Unity Tegra Shadows?

Discussion in 'Works In Progress - Archive' started by PhobicGunner, Jan 25, 2013.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
  2. dradb

    dradb

    Joined:
    Jan 10, 2015
    Posts:
    86
    I'm a new Unity user. Unity 5.0 Shadows don't work on my Android Samsung. I've downloaded $TegraShadows.unitypackage but the example shows the plane and objects in pink ... with no shadows. Help please.
     
  3. Mahmoud-AlSati

    Mahmoud-AlSati

    Joined:
    Aug 14, 2013
    Posts:
    4
    in ShadowReceiver.shader, Add this line at the start of vert function:
    UNITY_INITIALIZE_OUTPUT(Input, o);

    So that the vert function would look like:
    void vert (inout appdata_full v, out Input o) {
    UNITY_INITIALIZE_OUTPUT(Input, o);
    o.sh = mul( _Object2World, v.vertex );
    o.sh = mul( _ShadowProjectionMatrix, o.sh );
    o.dpth = ( o.sh.z / o.sh.w );

    float4 vert = mul( UNITY_MATRIX_MVP, v.vertex );
    o.dpth2 = vert.z;
    }

    This would make it work on unity5 again.
     
  4. Gunarvingren-GP

    Gunarvingren-GP

    Joined:
    Jul 12, 2015
    Posts:
    3
    Hi all, i have downloaded the example and it work just fine with the shader ajustment posted above.

    But when i change camera position it stop working, when camera is far from objects shadows just desapear.

    I have changed all variables from ShadowManager script but nothing seens to work. Someone have experienced this too?
     
  5. Gunarvingren-GP

    Gunarvingren-GP

    Joined:
    Jul 12, 2015
    Posts:
    3
    I just put 2000 in the ShadowMapFar public variable and 50 in the ShadowMapCoverage and now it work.
     
  6. Gunarvingren-GP

    Gunarvingren-GP

    Joined:
    Jul 12, 2015
    Posts:
    3
    Now i have another problem, the shadows are completely black, i am looking for a way to change alpha of shadows.
     
  7. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    THIS is new BUG? Before I test this demo worked in unity 4.X,Now Test again in UNITY 5.3.2,but it not work now !!Why ...
     

    Attached Files:

  8. BoBo-san

    BoBo-san

    Joined:
    Jan 29, 2011
    Posts:
    11
    @dreamerflyer Verify the graphic API. Is it DirectX or OpenGL?

    The normalized projection is different between platform.
    On OpenGL depth's between [-1,1]. On DirectX depth's between [0,1].
    If you look into RenderDepth.shader, ( o.z/o.w ) give you normalized depth in projection space.

    Look into ShadowManager.cs the line which compose ShadowMatrix.
    Camera.projectionMatrix alway uses OpenGL format. If you want projection matrix to match the one used in shader, use GL.GetProjectionMatrix.
    Also look at texMatrix which transform projection's x,y,z for sampling depth texture.
    It also scale and bias z, z = z*texMatrix[2,2] + texMatrix[2,3].

    The current demo works on DirectX because it use texMatrix to scale and bias z from Camera.projectionMatrix to DirectX format.

    I don't know if ARGB32 format, for RenderTexture, support negative value. You probably want to look in RenderDepth.shader too.
     
    Last edited: Apr 1, 2016
  9. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    FI
    Fixed this,My fault, shader not place correct....
     
  10. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    But have another problem on mobile, depth shadow map is right ,but shadow not work - -
    depthM.jpg ns.jpg
     
  11. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    I show the depth texture use tex2D (_ObjectDepthTex, i.sh.xy).But in mobile fail ....Maybe is this code not work?: "Shader.SetGlobalTexture("_ObjectDepthTex", ShadowCamera.targetTexture);" dep.jpg dd.jpg
     
  12. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    anybody help?
     
  13. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    pcd.jpg pcd.jpg abd.jpg
    Code (CSharp):
    1.      half sampleShadowmap( float2 uv, float depth )
    2.         {
    3.        
    4.             float4 enc = tex2D (_ObjectDepthTex, uv);
    5.             //half bias=0.14506;
    6.             half bias=0.0;
    7.        
    8.             float shD = DecodeFloatRGBA( enc )+bias;
    9.             //shD= step(depth,shD);//if(depth> shD),get 1
    10.             shD= step(shD,depth);
    11.    
    12.  
    13.             return shD;
    14.  
    15.         }
    THIS not work on mobile, Below the plane should on have shadow,how to fixed?
     
  14. Zenchuck

    Zenchuck

    Joined:
    Jun 2, 2010
    Posts:
    297
    Sorry to revive this old thread. Thanks to PhobicGunner for the example. I found this runs fine in Unity editor but I am unsuccessful when building to nexus 7. Perfhud shows the render texture being created but for some reason I'm not getting any effect.