Search Unity

Question How can i weaken the intensity of shadows casted on a billboard

Discussion in 'Universal Render Pipeline' started by sgu3d046, Jul 16, 2021.

  1. sgu3d046

    sgu3d046

    Joined:
    Jul 15, 2021
    Posts:
    1
    Have realized the function of a billboard(a LOD tree) and its switchable shadow casting, then awfully found its shadow seems too dark when looked in a distance(i can't tell whether it's fog or shadows calculation or color 's fault,it just looks sooo conspicuous)

    i defined a parameter called " _NORMALMAP",as the switcher of normal map based lighting,and I’m sure this part brings this incorrect shadows(cuz when switch it off ,I got a common billboard with albedo only )
    struct in VertexOutput:
    Code (CSharp):
    1.  #ifdef _NORMALMAP
    2.                     half4 normalWS : TEXCOORD3;
    3.                     half4 tangentWS : TEXCOORD4;
    4.                     half4 bitangentWS : TEXCOORD5;
    5.                     #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    6.                         float4 shadowCoord : TEXCOORD6;
    7.                     #endif
    8.                 #endif
    lighting caculation in vert:
    Code (CSharp):
    1. #ifdef _NORMALMAP
    2.                 //  Recalulate viewDirWS
    3.                     viewDirWS = normalize(GetCameraPositionWS() - output.positionWS);
    4.                     output.normalWS = half4(billboardNormalWS, viewDirWS.x);
    5.                     output.tangentWS = half4(billboardTangentWS, viewDirWS.y);
    6.                     output.bitangentWS = half4(billboardBitangentWS, viewDirWS.z);
    7.  
    8.                     half3 vertexLight = VertexLighting(output.positionWS, output.normalWS);
    9.                     //half3 vertexLight = VertexLighting(output.positionWS, output.normalWS);
    10.                     #if defined(_APPLYFOG) || defined(_APPLYFOGADDITIVELY)
    11.                         //output.fogFactorAndVertexLight = half4(0, vertexLight);
    12.                         output.fogFactorAndVertexLight = ComputeFogFactor(output.positionCS.z);
    13.                     #endif
    14.  
    15.        
    16.                     #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    17.                         output.shadowCoord = TransformWorldToShadowCoord(output.positionWS);
    18.                     #endif
    19.  
    20.                 #endif  
    lighting caculation in frag:
    Code (csharp):
    1.  #ifdef _NORMALMAP
    2.                     //input.col = (0.5,0.5,0.5,0.5);
    3.                     half3 normalTS = SampleNormal(input.uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
    4.                     half3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
    5.  
    6.                     //col.rgb = normalize(normalWS) * 0.5 + 0.5;
    7.  
    8.                     InputData inputData = (InputData)0;
    9.                     inputData.positionWS = input.positionWS;
    10.                     inputData.normalWS = NormalizeNormalPerPixel(normalWS);
    11.                     inputData.viewDirectionWS = SafeNormalize(half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w));
    12.                     //inputData.col = input.col;
    13.                     //inputData.fogCoord = 0;
    14.                     //inputData.vertexLighting = 0;
    15.                     #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
    16.                         inputData.shadowCoord = input.shadowCoord;
    17.                     #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
    18.                         inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
    19.                     #else
    20.                         inputData.shadowCoord = float4(0, 0, 0, 0);
    21.                     #endif
    22.                 //  We have to sample SH per pixel
    23.                     inputData.bakedGI = SampleSH(inputData.normalWS);
    24.  
    25.                     //half4 color = UniversalFragmentPBR(
    26.                     //    inputData,
    27.                     //    albedoAlpha.rgb,    // albedo
    28.                     //    0,                  // metallic,
    29.                     //    _SpecColor,         // specular
    30.                     //    _Smoothness,        // smoothness,
    31.                     //    1.0h,               // occlusion,
    32.                     //    0,                  // emission,
    33.                     //    alpha               // alpha
    34.                     //);
    35.                     half4 color = UniversalFragmentBlinnPhong(
    36.                         inputData,
    37.                         albedoAlpha.rgb,
    38.                         half4(_SpecColor,1),
    39.                          _Smoothness,
    40.                          0,
    41.                         alpha
    42.                     );
    43.                 #else
    44.                     half4 color = albedoAlpha;
    45.                 #endif
    46.  
    47.                        
    48.                 //#if defined(_APPLYFOGADDITIVELY)
    49.                 //    color.rgb = MixFogColor(color.rgb, half3(0,0,0), input.fogCoord);
    50.                 //#endif
    51.  
    52.                 #if defined(_APPLYFOG)
    53.                     // CUSTOM_FOG
    54.                     #if defined(CUSTOM_FOG) && defined(FOG_LINEAR)
    55.                         color.rgb = ApplyFog_Forward(color.rgb, input.positionWS);
    56.                     #endif
    57.                 #endif
    58.  
    i tried to change the color of inputdata.shadowCoord and returned it to make sure it was changed,no matter what color it be set , lighting never change...Also tried to Add a param ,'LightIntensity', in
    UniversalFragmentPBR but only make Light-receiving surface lighter, never touched the dark side.
    i dont know how to continue...so plz help TAT
     

    Attached Files:

    • pic1.png
      pic1.png
      File size:
      870.5 KB
      Views:
      381
    Last edited: Jul 16, 2021