浏览代码

Consistently handle 'NdotL' problems

/main
Evgenii Golubev 8 年前
当前提交
47bf244a
共有 6 个文件被更改,包括 28 次插入10 次删除
  1. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader
  2. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute
  3. 11
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  4. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
  5. 7
      Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl
  6. 2
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/Resources/Deferred.shader


float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
// We do not saturate for double-sided lighting.
// For single-sided lighting, the normal has already been adjusted during the G-buffer pass.
float NdotV = dot(bsdfData.normalWS, V);
PreLightData preLightData = GetPreLightData(V, NdotV, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Lighting/TilePass/Resources/shadeopaque.compute


float3 bakeDiffuseLighting;
DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
// We do not saturate for double-sided lighting.
// For single-sided lighting, the normal has already been adjusted during the G-buffer pass.
float NdotV = dot(bsdfData.normalWS, V);
PreLightData preLightData = GetPreLightData(V, NdotV, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;

11
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl


float ltcDisneyDiffuseMagnitude;
};
PreLightData GetPreLightData(float3 V, PositionInputs posInput, BSDFData bsdfData)
PreLightData GetPreLightData(float3 V, float NdotV, PositionInputs posInput, BSDFData bsdfData)
// TODO: check Eric idea about doing that when writting into the GBuffer (with our forward decal)
preLightData.NdotV = GetShiftedNdotV(bsdfData.normalWS, V, false);
preLightData.NdotV = NdotV;
preLightData.ggxLambdaV = GetSmithJointGGXLambdaV(preLightData.NdotV, bsdfData.roughness);

{
float3 N = bsdfData.normalWS;
float3 tangentX = bsdfData.tangentWS;
// This function call may modify the normal.
float NdotV = GetShiftedNdotV(N, V, false);
float NdotV = GetShiftedNdotV(N, V, false);
float3 acc = float3(0.0, 0.0, 0.0);
// Add some jittering on Hammersley2d

float3 N = bsdfData.normalWS;
float3 tangentX = bsdfData.tangentWS;
float3 tangentY = bsdfData.bitangentWS;
// This function call may modify the normal.
float NdotV = GetShiftedNdotV(N, V, false);
float NdotV = GetShiftedNdotV(N, V, false);
float3 acc = float3(0.0, 0.0, 0.0);

6
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
bool twoSided = false;
float NdotV = GetShiftedNdotV(bsdfData.normalWS, V, twoSided);
PreLightData preLightData = GetPreLightData(V, NdotV, posInput, bsdfData);
float3 diffuseLighting;
float3 specularLighting;

7
Assets/ScriptableRenderLoop/HDRenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl


GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);
BSDFData bsdfData = ConvertSurfaceDataToBSDFData(surfaceData);
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
bool twoSided = false;
float NdotV = GetShiftedNdotV(bsdfData.normalWS, V, twoSided);
PreLightData preLightData = GetPreLightData(V, NdotV, posInput, bsdfData);
float3 bakeDiffuseLighting = GetBakedDiffuseLigthing(surfaceData, builtinData, bsdfData, preLightData);
ENCODE_INTO_GBUFFER(surfaceData, bakeDiffuseLighting, outGBuffer);

2
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// NdotV should not be negative for visible pixels, but it can happen due to the
// perspective projection and the normal mapping + decals. In that case, the normal
// should be modified to become valid (i.e facing the camera) to avoid weird artifacts.
// Note: certain applications (e.g. SpeedTree) make use of two-sided lighting.
// Note: certain applications (e.g. SpeedTree) make use of double-sided lighting.
float GetShiftedNdotV(inout float3 N, float3 V, bool twoSided)
{
float NdotV = dot(N, V);

正在加载...
取消
保存