|
|
|
|
|
|
half3 color; |
|
|
|
half3 attenuation; //NOTE: RGB attenuation for shadow scatter. |
|
|
|
half subtractiveModeAttenuation; |
|
|
|
int isSpot; |
|
|
|
}; |
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
|
light.attenuation = directionAndRealtimeAttenuation.w; |
|
|
|
light.subtractiveModeAttenuation = lightInput.distanceAttenuation.w; |
|
|
|
light.color = lightInput.color; |
|
|
|
light.isSpot = lightInput.spotAttenuation.w; |
|
|
|
|
|
|
|
return light; |
|
|
|
} |
|
|
|
|
|
|
light.attenuation = directionAndRealtimeAttenuation.w; |
|
|
|
light.subtractiveModeAttenuation = lightInput.distanceAttenuation.w; |
|
|
|
light.color = lightInput.color; |
|
|
|
light.isSpot = lightInput.spotAttenuation.w; |
|
|
|
|
|
|
|
return light; |
|
|
|
} |
|
|
|
|
|
|
return volumeAlbedo * (exp(-t2 * halfRcpVariance1) * lerpWeight1 + exp(-t2 * halfRcpVariance2) * lerpWeight2); |
|
|
|
} |
|
|
|
|
|
|
|
half3 DiffuseScattering(BRDFData brdfData, half3 normalHighWS, half3 normalLowWS, half3 lightDirectionWS) |
|
|
|
half3 DiffuseScattering(BRDFData brdfData, half3 normalHighWS, half3 lightDirectionWS, half Attenuation, int isSpot) |
|
|
|
NdotL = 0.5 * NdotL + 0.5; //Scale to 0..1 for lookup. |
|
|
|
|
|
|
|
//NOTE: We need to account for spot light attenuation here. |
|
|
|
float lookup = (0.5 * NdotL + 0.5) * lerp(1, 0.5 * Attenuation + 0.5, isSpot); //Scale lookup to 0..1 |
|
|
|
return SAMPLE_TEXTURE2D_ARRAY(_PreintegratedDiffuseScatteringTextures, sampler_PreintegratedDiffuseScatteringTextures, float2(NdotL, brdfData.curvature), _DiffusionProfile).rgb; |
|
|
|
return SAMPLE_TEXTURE2D_ARRAY(_PreintegratedDiffuseScatteringTextures, sampler_PreintegratedDiffuseScatteringTextures, float2(lookup, brdfData.curvature), _DiffusionProfile).rgb; |
|
|
|
} |
|
|
|
|
|
|
|
half3 ShadowScattering(half shadow, half NdotL) |
|
|
|
|
|
|
return lightColor * specularReflection; |
|
|
|
} |
|
|
|
|
|
|
|
half3 LightingPhysicallyBased(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half3 lightAttenuation, half3 normalWS, half3 viewDirectionWS) |
|
|
|
half3 LightingPhysicallyBased(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half3 lightAttenuation, int isSpot, half3 normalWS, half3 viewDirectionWS) |
|
|
|
half3 NdotL = DiffuseScattering(brdfData, normalWS, normalWS, lightDirectionWS); |
|
|
|
half3 NdotL = DiffuseScattering(brdfData, normalWS, lightDirectionWS, lightAttenuation, isSpot); |
|
|
|
half3 radiance = lightColor * (lightAttenuation * NdotL); |
|
|
|
return DirectBDRF(brdfData, normalWS, lightDirectionWS, viewDirectionWS) * radiance; |
|
|
|
} |
|
|
|
|
|
|
return LightingPhysicallyBased(brdfData, light.color, light.direction, light.attenuation, normalWS, viewDirectionWS); |
|
|
|
return LightingPhysicallyBased(brdfData, light.color, light.direction, light.attenuation, light.isSpot, normalWS, viewDirectionWS); |
|
|
|
} |
|
|
|
|
|
|
|
half3 VertexLighting(float3 positionWS, half3 normalWS) |
|
|
|