Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Resolved TransformWorldToShadowCoord function in HDRP?

Discussion in 'Shader Graph' started by A132LW, Aug 1, 2019.

  1. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    I am trying to port the custom lighting nodes in LWRP to HDRP, but this line throws an error:
    float4 shadowCoord = TransformWorldToShadowCoord(WorldPos);

    I cannot find the HLSL file in the API containing this function. If someone can point me to the location in the API, then I can include that file.

    Thank you.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,082
    lwrp --> Shadows.hlsl
     
  3. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    Thank you, larsbertram1.
    I am looking for the equivalent file in hdrp, so I can port the custom lighting to hdrp.
     
  4. meadjix

    meadjix

    Joined:
    Dec 31, 2014
    Posts:
    8
  5. A132LW

    A132LW

    Joined:
    Jun 21, 2017
    Posts:
    37
    Thank you, meadjix!
     
  6. Hysparions

    Hysparions

    Joined:
    Jan 7, 2019
    Posts:
    22
    Hello,
    First excuse me for the revival of this thread but I'm facing the same error. The link doesn't exist anymore, do you have the function's name or another link, I couldn't find on the net,
    Thank you
     
  7. meadjix

    meadjix

    Joined:
    Dec 31, 2014
    Posts:
    8
    Hysparions likes this.
  8. pielloy

    pielloy

    Joined:
    Dec 16, 2020
    Posts:
    1
    The_Swiss_Guy likes this.
  9. meadjix

    meadjix

    Joined:
    Dec 31, 2014
    Posts:
    8
    Code (CSharp):
    1. float4 EvalShadow_WorldToShadow(HDShadowData sd, float3 positionWS, bool perspProj)
    2. {
    3.     // Note: Due to high VGRP load we can't use the whole view projection matrix, instead we reconstruct it from
    4.     // rotation, position and projection vectors (projection and position are stored in SGPR)
    5. #if 0
    6.     return mul(viewProjection, float4(positionWS, 1));
    7. #else
    8.  
    9.     if(perspProj)
    10.     {
    11.         positionWS = positionWS - sd.pos;
    12.         float3x3 view = { sd.rot0, sd.rot1, sd.rot2 };
    13.         positionWS = mul(view, positionWS);
    14.     }
    15.     else
    16.     {
    17.         float3x4 view;
    18.         view[0] = float4(sd.rot0, sd.pos.x);
    19.         view[1] = float4(sd.rot1, sd.pos.y);
    20.         view[2] = float4(sd.rot2, sd.pos.z);
    21.         positionWS = mul(view, float4(positionWS, 1.0)).xyz;
    22.     }
    23.  
    24.     float4x4 proj;
    25.     proj = 0.0;
    26.     proj._m00 = sd.proj[0];
    27.     proj._m11 = sd.proj[1];
    28.     proj._m22 = sd.proj[2];
    29.     proj._m23 = sd.proj[3];
    30.     if(perspProj)
    31.         proj._m32 = -1.0;
    32.     else
    33.         proj._m33 = 1.0;
    34.  
    35.     return mul(proj, float4(positionWS, 1.0));
    36. #endif
    37. }
    38.  
     
  10. jlee3900

    jlee3900

    Joined:
    Sep 13, 2020
    Posts:
    1
    Hello! I'm getting an undefined punctual shadow filter algorithm error after including the shadow hlsl file. Do you have any tips on how to get rid of this error?
     
    Euri and The_Swiss_Guy like this.
unityunity