Search Unity

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,900
    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:
    11
  5. A132LW

    A132LW

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

    Hysparions

    Joined:
    Jan 7, 2019
    Posts:
    29
    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:
    11
    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:
    11
    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. SlimeClay

    SlimeClay

    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?
     
  11. reigota

    reigota

    Joined:
    Mar 23, 2010
    Posts:
    86
    Sorry for ressurecting this once more.. I am a bit lost here..
    The method "TransformWorldToShadowCoord" exist in shadow.hlsl (URP) with exactly the same signature.

    But in HDShadowAlgorithms the method "EvalShadow_WorldToShadow" has a different signature (besides the different name).

    So, how is suppose to "translate" one thing (URP) in the another (HDRP)?
     
    alevjen, Brady, HyperPwner and 2 others like this.
  12. EXNDL

    EXNDL

    Joined:
    Jul 17, 2016
    Posts:
    1
    Hello so I'm using HDRP and yeah I'm also having this issue with TransformWorldToShadowCoord, using EvalShadow_WorldToShadow gives another error.

    Shader error in 'Master': undeclared identifier 'TransformWorldToShadowCoord' at Assets/GetLighting.hlsl(12) (on d3d11)

    Shader error in 'Master': 'EvalShadow_WorldToShadow': cannot implicitly convert from 'float3' to 'struct HDShadowData' at Assets/GetLighting.hlsl(12) (on d3d11)

    not really sure how to proceed with this.
     
  13. alevjen

    alevjen

    Joined:
    Sep 11, 2020
    Posts:
    11
    I've got the same issue. I can see I need to use
    EvalShadow_WorldToShadow
    but how do I set up the
    HDShadowData
    for the function to work?

    It would be suer helpful for some actual examples
     
  14. OverGast

    OverGast

    Joined:
    Aug 8, 2015
    Posts:
    30
    Bump, stuck on the same issue
     
  15. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    nothing yet? i really need this for our project :(
     
  16. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    765
    So yeah, in HDRP you cannot get the same kind of information sadly (at least you cannot get it without doing some over complicated stuff that might break a few month).

    The only thing you can get for sure is the main light direction by using the "main light direction" node.
    So the rest need to be hardcoded (color, attenuation.. etc) in order to port this to HDRP
     
    GamerLordMat likes this.