|
|
|
|
|
|
//#include "../SubsurfaceScattering/SubsurfaceScattering.hlsl" |
|
|
|
//#include "CoreRP/ShaderLibrary/VolumeRendering.hlsl" |
|
|
|
|
|
|
|
//NEWLITTODO : wireup CBUFFERs for ambientocclusion, and other uniforms and samplers used: |
|
|
|
//NEWLITTODO : wireup CBUFFERs for ambientocclusion, and other uniforms and samplers used: |
|
|
|
// |
|
|
|
// We need this for AO, Depth/Color pyramids, LTC lights data, FGD pre-integrated data. |
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
// This function is similar to ApplyDebugToSurfaceData but for BSDFData |
|
|
|
// |
|
|
|
// NOTE: |
|
|
|
// NOTE: |
|
|
|
// This will be available and used in ShaderPassForward.hlsl since in StackLit.shader, |
|
|
|
// just before including the core code of the pass (ShaderPassForward.hlsl) we include |
|
|
|
// Material.hlsl (or Lighting.hlsl which includes it) which in turn includes us, |
|
|
|
// This will be available and used in ShaderPassForward.hlsl since in StackLit.shader, |
|
|
|
// just before including the core code of the pass (ShaderPassForward.hlsl) we include |
|
|
|
// Material.hlsl (or Lighting.hlsl which includes it) which in turn includes us, |
|
|
|
// StackLit.shader, via the #if defined(UNITY_MATERIAL_*) glue mechanism. |
|
|
|
// |
|
|
|
void ApplyDebugToBSDFData(inout BSDFData bsdfData) |
|
|
|
|
|
|
// this can be use also in case of debug lighting mode like specular only |
|
|
|
|
|
|
|
|
|
|
|
//NEWLITTODO |
|
|
|
//bool overrideSpecularColor = _DebugLightingSpecularColor.x != 0.0; |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
BSDFData bsdfData; |
|
|
|
ZERO_INITIALIZE(BSDFData, bsdfData); |
|
|
|
|
|
|
|
|
|
|
|
// NEWLITTODO: will be much more involved obviously, and use metallic, etc. |
|
|
|
bsdfData.diffuseColor = surfaceData.baseColor; |
|
|
|
bsdfData.normalWS = surfaceData.normalWS; |
|
|
|
|
|
|
void GetSurfaceDataDebug(uint paramId, SurfaceData surfaceData, inout float3 result, inout bool needLinearToSRGB) |
|
|
|
{ |
|
|
|
GetGeneratedSurfaceDataDebug(paramId, surfaceData, result, needLinearToSRGB); |
|
|
|
//NEWLITTODO |
|
|
|
|
|
|
|
// Overide debug value output to be more readable |
|
|
|
switch (paramId) |
|
|
|
{ |
|
|
|
case DEBUGVIEW_LIT_SURFACEDATA_NORMAL_VIEW_SPACE: |
|
|
|
// Convert to view space |
|
|
|
result = TransformWorldToViewDir(surfaceData.normalWS) * 0.5 + 0.5; |
|
|
|
break; |
|
|
|
} |
|
|
|
//NEWLITTODO |
|
|
|
|
|
|
|
// Overide debug value output to be more readable |
|
|
|
switch (paramId) |
|
|
|
{ |
|
|
|
case DEBUGVIEW_LIT_BSDFDATA_NORMAL_VIEW_SPACE: |
|
|
|
// Convert to view space |
|
|
|
result = TransformWorldToViewDir(bsdfData.normalWS) * 0.5 + 0.5; |
|
|
|
break; |
|
|
|
} |
|
|
|
// PreLightData |
|
|
|
// |
|
|
|
// PreLightData |
|
|
|
// |
|
|
|
// Make sure we respect naming conventions to reuse ShaderPassForward as is, |
|
|
|
// ie struct (even if opaque to the ShaderPassForward) name is PreLightData, |
|
|
|
// GetPreLightData prototype. |
|
|
|
|
|
|
float3 N = bsdfData.normalWS; |
|
|
|
preLightData.NdotV = dot(N, V); |
|
|
|
|
|
|
|
float NdotV = ClampNdotV(preLightData.NdotV); |
|
|
|
//float NdotV = ClampNdotV(preLightData.NdotV); |
|
|
|
|
|
|
|
|
|
|
|
return preLightData; |
|
|
|
|
|
|
float NdotL = dot(N, L); |
|
|
|
//float LdotV = dot(L, V); |
|
|
|
|
|
|
|
// color and attenuation are outputted by EvaluateLight: |
|
|
|
// color and attenuation are outputted by EvaluateLight: |
|
|
|
float3 color; |
|
|
|
float attenuation; |
|
|
|
EvaluateLight_Directional(lightLoopContext, posInput, lightData, bakeLightingData, N, L, color, attenuation); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// NEWLITTODO: Mixed thickness, transmission |
|
|
|
|
|
|
|
|
|
|
|
// Save ALU by applying light and cookie colors only once. |
|
|
|
lighting.diffuse *= color; |
|
|
|
lighting.specular *= color; |
|
|
|
|
|
|
float LdotV = dot(L, V); |
|
|
|
|
|
|
|
// NEWLITTODO: mixedThickness, transmission |
|
|
|
|
|
|
|
|
|
|
|
float3 color; |
|
|
|
float attenuation; |
|
|
|
EvaluateLight_Punctual(lightLoopContext, posInput, lightData, bakeLightingData, N, L, |
|
|
|
|
|
|
// Simulate a sphere light with this hack |
|
|
|
// Note that it is not correct with our pre-computation of PartLambdaV (mean if we disable the optimization we will not have the |
|
|
|
// same result) but we don't care as it is a hack anyway |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//bsdfData.coatRoughness = max(bsdfData.coatRoughness, lightData.minRoughness); |
|
|
|
//bsdfData.roughnessT = max(bsdfData.roughnessT, lightData.minRoughness); |
|
|
|
//bsdfData.roughnessB = max(bsdfData.roughnessB, lightData.minRoughness); |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//NEWLITTODO : transmission |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save ALU by applying light and cookie colors only once. |
|
|
|
lighting.diffuse *= color; |
|
|
|
|
|
|
return lighting; |
|
|
|
} |
|
|
|
|
|
|
|
// NEWLITTODO: For a refence rendering option for area light, like LIT_DISPLAY_REFERENCE_AREA option in eg EvaluateBSDF_<area light type> : |
|
|
|
// NEWLITTODO: For a refence rendering option for area light, like LIT_DISPLAY_REFERENCE_AREA option in eg EvaluateBSDF_<area light type> : |
|
|
|
//#include "LitReference.hlsl" |
|
|
|
|
|
|
|
//----------------------------------------------------------------------------- |
|
|
|
|
|
|
{ |
|
|
|
DirectLighting lighting; |
|
|
|
ZERO_INITIALIZE(DirectLighting, lighting); |
|
|
|
|
|
|
|
|
|
|
|
//NEWLITTODO |
|
|
|
|
|
|
|
return lighting; |
|
|
|
|
|
|
{ |
|
|
|
IndirectLighting lighting; |
|
|
|
ZERO_INITIALIZE(IndirectLighting, lighting); |
|
|
|
|
|
|
|
|
|
|
|
//NEWLITTODO |
|
|
|
|
|
|
|
return lighting; |
|
|
|
|
|
|
#endif |
|
|
|
else if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) |
|
|
|
{ |
|
|
|
// NEWLITTODO |
|
|
|
// NEWLITTODO |
|
|
|
//diffuseLighting = bsdfData.diffuseColor; |
|
|
|
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting |
|
|
|
} |
|
|
|