浏览代码

Disable blending during the first SSS pass

/main
Evgenii Golubev 8 年前
当前提交
3c0d55d7
共有 2 个文件被更改,包括 21 次插入14 次删除
  1. 29
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  2. 6
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader

29
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


// Various set of material use in render loop
readonly Material m_DebugViewMaterialGBuffer;
readonly Material m_CombineSubsurfaceScattering;
readonly Material m_FilterSubsurfaceScattering;
readonly Material m_FilterAndCombineSubsurfaceScattering;
readonly Material m_DebugDisplayShadowMap;
// Various buffer

m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugViewMaterialGBuffer");
m_CombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.Zero);
m_FilterSubsurfaceScattering.SetFloat("_FilterHorizontal", 0);
m_FilterAndCombineSubsurfaceScattering = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/CombineSubsurfaceScattering");
m_FilterAndCombineSubsurfaceScattering.SetFloat("_DstBlend", (float)BlendMode.One);
m_FilterAndCombineSubsurfaceScattering.SetFloat("_FilterHorizontal", 1);
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayShadowMap");
m_ShadowPass = new ShadowRenderPass(owner.shadowSettings);

// Assume that the height of the projection window is 2 meters.
float distanceToProjectionWindow = 1.0f / Mathf.Tan(0.5f * Mathf.Deg2Rad * hdCamera.camera.fieldOfView);
m_CombineSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow);
m_CombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale);
// Upload the kernel data.
Vector4[] kernelData = new Vector4[SubsurfaceScatteringParameters.maxNumProfiles * SubsurfaceScatteringProfile.numSamples];

kernelData[n * j + i] = sssParameters.profiles[j].filterKernel[i];
}
}
m_CombineSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData);
MaterialPropertyBlock properties = new MaterialPropertyBlock();

properties.SetFloat("_DstBlend", (float)BlendMode.Zero); // TODO: this doesn't work for some reason...
properties.SetFloat("_FilterHorizontal", 0);
m_FilterSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow);
m_FilterSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale);
m_FilterSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData);
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera,
Utilities.DrawFullscreen(cmd, m_FilterSubsurfaceScattering, hdCamera,
properties.SetFloat("_DstBlend", (float)BlendMode.One); // TODO: this doesn't work for some reason...
properties.SetFloat("_FilterHorizontal", 1);
m_FilterAndCombineSubsurfaceScattering.SetFloat("_DistToProjWindow", distanceToProjectionWindow);
m_FilterAndCombineSubsurfaceScattering.SetFloat("_BilateralScale", 0.05f * sssParameters.bilateralScale);
m_FilterAndCombineSubsurfaceScattering.SetVectorArray("_FilterKernels", kernelData);
Utilities.DrawFullscreen(cmd, m_CombineSubsurfaceScattering, hdCamera,
Utilities.DrawFullscreen(cmd, m_FilterAndCombineSubsurfaceScattering, hdCamera,
m_CameraColorBufferRT, m_CameraStencilBufferRT, properties);
context.ExecuteCommandBuffer(cmd);

6
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Resources/CombineSubsurfaceScattering.shader


ZTest Always
ZWrite Off
Blend One [_DstBlend], Zero [_DstBlend]
Blend One [_DstBlend]
HLSLPROGRAM
#pragma target 4.5

return output;
}
float4 Frag(Varyings input) : SV_Target
float3 Frag(Varyings input) : SV_Target
{
PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw);

filteredIrradiance += lerp(sampleIrradiance, centerIrradiance, t) * sampleWeight;
}
return float4(filteredIrradiance, 1.0);
return filteredIrradiance;
}
ENDHLSL
}

正在加载...
取消
保存