@@ -1080,10 +1080,31 @@ void lilGetToonSHDoubleAPV(float3 lightDirection, float3 positionWS, float3 norm
10801080 #endif
10811081}
10821082
1083+ float3 lilGetFixedLightDirectionAPV (float3 positionWS, float3 normalWS, float4 lightDirectionOverride)
1084+ {
1085+ float3 mainDir = LIL_MAINLIGHT_DIRECTION * lilLuminance (LIL_MAINLIGHT_COLOR);
1086+ float4 SHAr = unity_SHAr;
1087+ float4 SHAg = unity_SHAg;
1088+ float4 SHAb = unity_SHAb;
1089+ float3 V = normalize (lilViewDirection (positionWS));
1090+ APVSample apvSample = SampleAPV (positionWS, normalWS, lilGetRenderingLayer (), V);
1091+ if (apvSample.status != APV_SAMPLE_STATUS_INVALID)
1092+ {
1093+ apvSample.Decode ();
1094+ SHAr = half4 (apvSample.L1_R, apvSample.L0.r);
1095+ SHAg = half4 (apvSample.L1_G, apvSample.L0.g);
1096+ SHAb = half4 (apvSample.L1_B, apvSample.L0.b);
1097+ }
1098+
1099+ float3 sh9Dir = SHAr.xyz * 0.333333 + SHAg.xyz * 0.333333 + SHAb.xyz * 0.333333 ;
1100+ float3 L = float3 (sh9Dir.x, abs (sh9Dir.y), sh9Dir.z) + mainDir + lilGetCustomLightDirection (lightDirectionOverride);
1101+ return L;
1102+ }
1103+
10831104void lilGetLightColorDoubleAPV (float3 positionWS, float3 normalWS, out float3 lightColor, out float3 indLightColor)
10841105{
10851106 float3 shMax, shMin;
1086- lilGetToonSHDoubleAPV (lilGetLightDirectionForSH9 ( ), positionWS, normalWS, shMax, shMin);
1107+ lilGetToonSHDoubleAPV (lilGetFixedLightDirectionAPV (positionWS, normalWS, float4 ( 0 , 0.001 , 0 , 0 ) ), positionWS, normalWS, shMax, shMin);
10871108 lightColor = LIL_MAINLIGHT_COLOR + shMax;
10881109 indLightColor = saturate (shMin);
10891110}
0 commit comments