浏览代码

Attempt to add shadowing for regular transmission

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
ef74635b
共有 1 个文件被更改,包括 30 次插入7 次删除
  1. 37
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

37
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


#define LTC_LUT_SCALE ((LTC_LUT_SIZE - 1) * rcp(LTC_LUT_SIZE))
#define LTC_LUT_OFFSET (0.5 * rcp(LTC_LUT_SIZE))
#define MIN_N_DOT_V 0.0001 // The minimum value of 'NdotV'
#define MIN_N_DOT_V 0.0001 // The minimum value of 'NdotV'
#define MILLIMETERS_TO_METERS 0.001
uint _EnableSSS; // Globally toggles subsurface scattering on/off
uint _TexturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter

// float RdotL = NdotL - 2 * preLightData.NdotV * LdotV;
float illuminance = saturate(-LdotV);
// For low thickness, we can reuse the shadowing status for the back of the object.
shadow = bsdfData.useThinObjectMode ? shadow : 1;
// For thin objects, we can reuse the shadowing status for the back of the object.
[branch] if (!bsdfData.useThinObjectMode)
{
// TODO: precompute?
float d = bsdfData.thickness * (2 * MILLIMETERS_TO_METERS);
float3 P = positionWS - d * V;
shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, P, bsdfData.normalWS, lightData.shadowIndex, L, posInput.unPositionSS);
}
illuminance *= shadow * cookie.a;
// The difference between the Disney Diffuse and the Lambertian BRDF for transmission is negligible.

// float RdotL = NdotL - 2 * preLightData.NdotV * LdotV;
float illuminance = saturate(-LdotV * attenuation);
// For low thickness, we can reuse the shadowing status for the back of the object.
shadow = bsdfData.useThinObjectMode ? shadow : 1;
// For thin objects, we can reuse the shadowing status for the back of the object.
[branch] if (!bsdfData.useThinObjectMode)
{
// TODO: precompute?
float d = bsdfData.thickness * (2 * MILLIMETERS_TO_METERS);
float3 P = positionWS - d * V;
float3 offset = float3(0.0, 0.0, 0.0); // GetShadowPosOffset(nDotL, normal);
shadow = GetPunctualShadowAttenuation(lightLoopContext.shadowContext, P + offset, bsdfData.normalWS, lightData.shadowIndex, L, posInput.unPositionSS);
}
illuminance *= shadow * cookie.a;
// The difference between the Disney Diffuse and the Lambertian BRDF for transmission is negligible.

// float RdotL = NdotL - 2 * preLightData.NdotV * LdotV;
float illuminance = saturate(-LdotV * clipFactor);
// For low thickness, we can reuse the shadowing status for the back of the object.
shadow = bsdfData.useThinObjectMode ? shadow : 1;
// For thin objects, we can reuse the shadowing status for the back of the object.
[branch] if (!bsdfData.useThinObjectMode)
{
// TODO: precompute?
float d = bsdfData.thickness * (2 * MILLIMETERS_TO_METERS);
float3 P = positionWS - d * V;
shadow = GetDirectionalShadowAttenuation(lightLoopContext.shadowContext, P, bsdfData.normalWS, lightData.shadowIndex, L, posInput.unPositionSS);
}
illuminance *= shadow * cookie.a;
// The difference between the Disney Diffuse and the Lambertian BRDF for transmission is negligible.

正在加载...
取消
保存