浏览代码

Fix shadows for tessellation

/Branch_Batching2
Evgenii Golubev 7 年前
当前提交
e30162ef
共有 4 个文件被更改,包括 18 次插入4 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  2. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.hlsl
  3. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  4. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


#pragma target 4.5
#pragma only_renderers d3d11 ps4 metal // TEMP: until we go futher in dev
//#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.hlsl


// TODO: Handle inverse culling (for mirror)!
if (_TessellationBackFaceCullEpsilon > -0.99) // Is backface culling enabled ?
{
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, _WorldSpaceCameraPos);
faceCull = BackFaceCullTriangle(p0, p1, p2, _TessellationBackFaceCullEpsilon, GetCurrentCameraPosition());
}
#endif

// Distance based tessellation
if (_TessellationFactorMaxDistance > 0.0)
{
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, _WorldSpaceCameraPos, _TessellationFactorMinDistance, _TessellationFactorMaxDistance);
float3 distFactor = GetDistanceBasedTessFactor(p0, p1, p2, GetCurrentCameraPosition(), _TessellationFactorMinDistance, _TessellationFactorMaxDistance);
// We square the disance factor as it allow a better percptual descrease of vertex density.
tessFactor *= distFactor * distFactor;
}

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader


#pragma target 5.0
#pragma only_renderers d3d11 ps4// TEMP: until we go futher in dev
// #pragma enable_d3d11_debug_symbols
//-------------------------------------------------------------------------------------
// Variant

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl


return mul(GetWorldToHClipMatrix(), float4(positionWS, 1.0));
}
float3 GetCurrentCameraPosition()
{
#if SHADERPASS != SHADERPASS_DEPTH_ONLY
return _WorldSpaceCameraPos;
#else
// TEMP: this is a workaround until the shadow map pass sets '_WorldSpaceCameraPos'.
// This code is far more expensive than loading a constant from a cbuffer!
float4x4 viewMat = transpose(GetWorldToViewMatrix());
float3 rotCamPos = viewMat[3].xyz;
return mul((float3x3)viewMat, -rotCamPos);
#endif
}
float3 V = _WorldSpaceCameraPos.xyz - positionWS;
float3 V = GetCurrentCameraPosition() - positionWS;
// Uncomment this once the compiler bug is fixed.
// if (unity_OrthoParams.w == 1.0)

正在加载...
取消
保存