[Fix] Shadow Depth
This commit is contained in:
@@ -27,7 +27,11 @@ void CInstancedProp::Late_Update(_float fTimeDelta)
|
||||
}
|
||||
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this);
|
||||
|
||||
//pair<_bool, _ubyte> pairShadowResult = m_pGameInstance->IsIn_ShadowViewFrustum(m_pTransformCom->Get_State(STATE::POSITION), m_pTransformCom->Get_Radius());
|
||||
//if (0 == ((_ubyte)SHADOW::SHADOW_FAR & pairShadowResult.second)) {
|
||||
// pairShadowResult.first = true;
|
||||
// Set_Shadow(pairShadowResult);
|
||||
//}
|
||||
}
|
||||
|
||||
HRESULT CInstancedProp::Render()
|
||||
|
||||
@@ -32,9 +32,9 @@ HRESULT CLight_Main::Initialize(void* pArg)
|
||||
|
||||
void CLight_Main::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4 vLook = {};
|
||||
XMStoreFloat4(&vLook, m_pTransformCom->Get_State(STATE::LOOK));
|
||||
m_pGameInstance->Ready_Shadow_Light(vLook);
|
||||
_float4 vRPYQuat = {};
|
||||
XMStoreFloat4(&vRPYQuat, m_pTransformCom->Get_QuarternionVector());
|
||||
m_pGameInstance->Ready_Shadow_Light(vRPYQuat);
|
||||
}
|
||||
|
||||
void CLight_Main::Update(_float fTimeDelta)
|
||||
@@ -55,9 +55,7 @@ HRESULT CLight_Main::Render()
|
||||
|
||||
HRESULT CLight_Main::Capture_PreShadow()
|
||||
{
|
||||
_vector vRotq = m_pTransformCom->Get_QuarternionVector();
|
||||
_uint iLevel = NEXT_LEVEL;
|
||||
CLayer* pLayer = m_pGameInstance->Get_Layer(iLevel, LAYER_BACKGROUND);
|
||||
CLayer* pLayer = m_pGameInstance->Get_Layer(NEXT_LEVEL, LAYER_BACKGROUND);
|
||||
assert(nullptr != pLayer);
|
||||
|
||||
const list<CGameObject*>* pObjects = pLayer->Get_Objects();
|
||||
@@ -151,7 +149,14 @@ _matrix CLight_Main::Get_OffCenterProjMatrix(_fmatrix ViewMatrix, vector<_float3
|
||||
fMinY = min(fMinY, y); fMaxY = max(fMaxY, y);
|
||||
fMinZ = min(fMinZ, z); fMaxZ = max(fMaxZ, z);
|
||||
}
|
||||
if (fMinZ > fMaxZ)
|
||||
{
|
||||
swap(fMinZ, fMaxZ);
|
||||
}
|
||||
|
||||
_float fShadowDepthMArgin = 10.f; // 캐릭터 이동 보정
|
||||
fMinZ -= fShadowDepthMArgin;
|
||||
fMaxZ += fShadowDepthMArgin;
|
||||
return XMMatrixOrthographicOffCenterLH(fMinX, fMaxX, fMinY, fMaxY, fMinZ, fMaxZ);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,13 @@ DepthStencilState DSS_None
|
||||
DepthWriteMask = zero;
|
||||
};
|
||||
|
||||
DepthStencilState DSS_Default_Less
|
||||
{
|
||||
DepthEnable = true;
|
||||
DepthWriteMask = all;
|
||||
DepthFunc = less;
|
||||
};
|
||||
|
||||
DepthStencilState DSS_Effect
|
||||
{
|
||||
DepthEnable = true;
|
||||
|
||||
@@ -26,6 +26,7 @@ float g_fFarBlurStart;
|
||||
float g_fFarBlurEnd;
|
||||
float g_fDOFBlurMultiplier;
|
||||
float g_fSSAO_BIAS;
|
||||
float g_fSSAOStrength;
|
||||
|
||||
Texture2D g_Texture;
|
||||
Texture2D g_SSAONoiseTexture;
|
||||
@@ -219,10 +220,10 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||
|
||||
float2 uv = In.vTexcoord;
|
||||
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
float fViewZ = vDepth.y * g_fFar;
|
||||
|
||||
@@ -278,12 +279,12 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
|
||||
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
|
||||
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
|
||||
|
||||
return Out;
|
||||
}
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 디렉셔널
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -342,7 +343,7 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
|
||||
float fLightDistance = length(vFinalLightPosition - vWorldPosition.xyz);
|
||||
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀에서 카메라로
|
||||
float3 vToLight = normalize(vFinalLightPosition - vWorldPosition.xyz); // 픽셀에서 라이트로
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
if (g_bUsePowerLightAttenuation)
|
||||
{
|
||||
@@ -390,13 +391,13 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vSpecular = fAttenuation * ((g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f));
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 점광원
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -429,7 +430,7 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
float fViewZ = vDepth.y * g_fFar;
|
||||
|
||||
@@ -518,12 +519,12 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vSpecular = fAttenuation * ((g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f));
|
||||
|
||||
return Out;
|
||||
}
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 점광원
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -606,7 +607,7 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
|
||||
/* 광원의 NDC에서 샘플링 */
|
||||
float fVisibility_Dynamic_Near = ShadowVisibility_hwPCF(g_ShadowNearTexture, vNearShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.x);
|
||||
float fVisibility_Dynamic_Middle = ShadowVisibility_hwPCF(g_ShadowMiddleTexture, vMiddleShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.y);
|
||||
float fVisibility_Dynamic_Far = ShadowVisibility_hwPCF(g_ShadowFarTexture, vFarShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.z);
|
||||
//float fVisibility_Dynamic_Far = ShadowVisibility_hwPCF(g_ShadowFarTexture, vFarShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.z);
|
||||
float fVisibility_Static = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.w);
|
||||
|
||||
////////////////////////////
|
||||
@@ -619,17 +620,17 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
|
||||
// 경계 주변 부드럽게 할 비중
|
||||
float fCascadeBlend_NearToMiddle = smoothstep(g_fCascadeSplitRatioNear - fShadowCascadeBlendWidthRatio,
|
||||
g_fCascadeSplitRatioNear + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
|
||||
g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
//float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
|
||||
// g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
|
||||
// Near -> Middle
|
||||
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_NearToMiddle);
|
||||
// Middle -> Far 경계 부드럽게
|
||||
fVisibilityDynamic = lerp(fVisibilityDynamic, fVisibility_Dynamic_Far, fCascadeBlend_MiddleToFar);
|
||||
//fVisibilityDynamic = lerp(fVisibilityDynamic, fVisibility_Dynamic_Far, fCascadeBlend_MiddleToFar);
|
||||
|
||||
// PreShadow(Static)로 넘어가는 구간(원하는 대로 조절)
|
||||
float fStaticShadowBlendStartRatio = 0.15f;
|
||||
float fStaticShadowBlendEndRatio = 0.25f;
|
||||
// PreShadow로 넘어가는 구간
|
||||
float fStaticShadowBlendStartRatio = g_fCascadeSplitRatioFar;
|
||||
float fStaticShadowBlendEndRatio = 1.f;
|
||||
|
||||
float fStaticShadowBlendWeight = smoothstep(fStaticShadowBlendStartRatio, fStaticShadowBlendEndRatio, fDepthRatio);
|
||||
float fVisibilityCombined = lerp(fVisibilityDynamic, fVisibility_Static, fStaticShadowBlendWeight);
|
||||
@@ -1126,7 +1127,7 @@ PS_OUT_SSAO_AMBIENT_OCCLUSION PS_SSAO_AMBIENT_OCCLUSION(PS_IN In)
|
||||
fIsOccluded *= fRangeCheck;
|
||||
fOcclusion += fIsOccluded;
|
||||
}
|
||||
fOcclusion = (1.f - (fOcclusion / g_iKernelSize) * fRatio);
|
||||
fOcclusion = saturate(1.f - (fOcclusion * g_fSSAOStrength / g_iKernelSize) * fRatio);
|
||||
Out.fOcclusion = fOcclusion ;
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -563,7 +563,7 @@ technique11 DefaultTechnique
|
||||
pass ShadowPass // 1
|
||||
{
|
||||
SetRasterizerState(RS_Default);
|
||||
SetDepthStencilState(DSS_None, 0);
|
||||
SetDepthStencilState(DSS_Default_Less, 0);
|
||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||
VertexShader = compile vs_5_0 VS_MAIN_SHADOW();
|
||||
GeometryShader = NULL;
|
||||
|
||||
@@ -790,7 +790,7 @@ technique11 MeshTechnique11
|
||||
pass ShadowPass
|
||||
{
|
||||
SetRasterizerState(RS_Default);
|
||||
SetDepthStencilState(DSS_None, 0);
|
||||
SetDepthStencilState(DSS_Default_Less, 0);
|
||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||
VertexShader = compile vs_5_0 VS_MAIN_SHADOW();
|
||||
GeometryShader = NULL;
|
||||
|
||||
@@ -249,7 +249,7 @@ technique11 NorTexTechnique11
|
||||
pass ShadowPass // 3
|
||||
{
|
||||
SetRasterizerState(RS_Default);
|
||||
SetDepthStencilState(DSS_None, 0);
|
||||
SetDepthStencilState(DSS_Default_Less, 0);
|
||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||
VertexShader = compile vs_5_0 VS_MAIN_SHADOW();
|
||||
GeometryShader = NULL;
|
||||
|
||||
@@ -77,6 +77,13 @@ DepthStencilState DSS_None
|
||||
DepthWriteMask = zero;
|
||||
};
|
||||
|
||||
DepthStencilState DSS_Default_Less
|
||||
{
|
||||
DepthEnable = true;
|
||||
DepthWriteMask = all;
|
||||
DepthFunc = less;
|
||||
};
|
||||
|
||||
DepthStencilState DSS_Effect
|
||||
{
|
||||
DepthEnable = true;
|
||||
|
||||
@@ -26,6 +26,7 @@ float g_fFarBlurStart;
|
||||
float g_fFarBlurEnd;
|
||||
float g_fDOFBlurMultiplier;
|
||||
float g_fSSAO_BIAS;
|
||||
float g_fSSAOStrength;
|
||||
|
||||
Texture2D g_Texture;
|
||||
Texture2D g_SSAONoiseTexture;
|
||||
@@ -219,10 +220,10 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||
|
||||
float2 uv = In.vTexcoord;
|
||||
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
float fViewZ = vDepth.y * g_fFar;
|
||||
|
||||
@@ -278,12 +279,12 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
|
||||
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
|
||||
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
|
||||
|
||||
return Out;
|
||||
}
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 디렉셔널
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -342,7 +343,7 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
|
||||
float fLightDistance = length(vFinalLightPosition - vWorldPosition.xyz);
|
||||
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀에서 카메라로
|
||||
float3 vToLight = normalize(vFinalLightPosition - vWorldPosition.xyz); // 픽셀에서 라이트로
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
if (g_bUsePowerLightAttenuation)
|
||||
{
|
||||
@@ -390,13 +391,13 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vSpecular = fAttenuation * ((g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f));
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 점광원
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -429,7 +430,7 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
|
||||
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
|
||||
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
|
||||
float fAmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
|
||||
|
||||
float fViewZ = vDepth.y * g_fFar;
|
||||
|
||||
@@ -518,12 +519,12 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
|
||||
}
|
||||
else // basic Lighting(phong blinn) // if you were here, you miss some assets.
|
||||
{
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fAmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vShade = fAttenuation * (g_vLightDiffuse * saturate(max(dot(vToLight * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient)));
|
||||
Out.vSpecular = fAttenuation * ((g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f));
|
||||
|
||||
return Out;
|
||||
}
|
||||
float fTotalOcclusion = saturate(fOcclusion * fAmbientOcclusion);
|
||||
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
|
||||
|
||||
{ // 수치조정 // 점광원
|
||||
float fMinRoughness = 0.05f;
|
||||
@@ -606,7 +607,7 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
|
||||
/* 광원의 NDC에서 샘플링 */
|
||||
float fVisibility_Dynamic_Near = ShadowVisibility_hwPCF(g_ShadowNearTexture, vNearShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.x);
|
||||
float fVisibility_Dynamic_Middle = ShadowVisibility_hwPCF(g_ShadowMiddleTexture, vMiddleShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.y);
|
||||
float fVisibility_Dynamic_Far = ShadowVisibility_hwPCF(g_ShadowFarTexture, vFarShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.z);
|
||||
//float fVisibility_Dynamic_Far = ShadowVisibility_hwPCF(g_ShadowFarTexture, vFarShadowPos, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.z);
|
||||
float fVisibility_Static = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, float2(g_iMaxShadowWidth, g_iMaxShadowHeight), g_vShadowBias.w);
|
||||
|
||||
////////////////////////////
|
||||
@@ -619,17 +620,17 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
|
||||
// 경계 주변 부드럽게 할 비중
|
||||
float fCascadeBlend_NearToMiddle = smoothstep(g_fCascadeSplitRatioNear - fShadowCascadeBlendWidthRatio,
|
||||
g_fCascadeSplitRatioNear + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
|
||||
g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
//float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
|
||||
// g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
|
||||
|
||||
// Near -> Middle
|
||||
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_NearToMiddle);
|
||||
// Middle -> Far 경계 부드럽게
|
||||
fVisibilityDynamic = lerp(fVisibilityDynamic, fVisibility_Dynamic_Far, fCascadeBlend_MiddleToFar);
|
||||
//fVisibilityDynamic = lerp(fVisibilityDynamic, fVisibility_Dynamic_Far, fCascadeBlend_MiddleToFar);
|
||||
|
||||
// PreShadow(Static)로 넘어가는 구간(원하는 대로 조절)
|
||||
float fStaticShadowBlendStartRatio = 0.15f;
|
||||
float fStaticShadowBlendEndRatio = 0.25f;
|
||||
// PreShadow로 넘어가는 구간
|
||||
float fStaticShadowBlendStartRatio = g_fCascadeSplitRatioFar;
|
||||
float fStaticShadowBlendEndRatio = 1.f;
|
||||
|
||||
float fStaticShadowBlendWeight = smoothstep(fStaticShadowBlendStartRatio, fStaticShadowBlendEndRatio, fDepthRatio);
|
||||
float fVisibilityCombined = lerp(fVisibilityDynamic, fVisibility_Static, fStaticShadowBlendWeight);
|
||||
@@ -1126,7 +1127,7 @@ PS_OUT_SSAO_AMBIENT_OCCLUSION PS_SSAO_AMBIENT_OCCLUSION(PS_IN In)
|
||||
fIsOccluded *= fRangeCheck;
|
||||
fOcclusion += fIsOccluded;
|
||||
}
|
||||
fOcclusion = (1.f - (fOcclusion / g_iKernelSize) * fRatio);
|
||||
fOcclusion = saturate(1.f - (fOcclusion * g_fSSAOStrength / g_iKernelSize) * fRatio);
|
||||
Out.fOcclusion = fOcclusion ;
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -74,21 +74,20 @@ pair<_bool, _ubyte> CPipeLine::IsIn_ShadowViewFrustum(_fvector vWorldCenter, _fl
|
||||
// 월드 센터를 셰도우뷰 센터로 바꿈
|
||||
_vector vShadowViewCenter = XMVectorSetW(XMVector3Rotate(vWorldCenter, XMLoadFloat4(&m_vShadowInvDirectionalRPYQuat)), 1.f);
|
||||
|
||||
_float fSafeRadius = fRadius; // 인스턴싱된 객체 고려해서 좀 더 넓게 탐색
|
||||
_float fSafeRadius = (fRadius + m_fSafe_RadiusMargin) * m_fSafe_RadiusMultiplier; // 그림자임을 고려해서 객체 부피보다 좀 더 넓게 탐색
|
||||
|
||||
for (_uint iCascadeIndex = 0; iCascadeIndex < ENUM_CLASS(SHADOW::END); ++iCascadeIndex) {
|
||||
const _float4* pTargetPlanes = nullptr;
|
||||
if (iCascadeIndex == 2) {
|
||||
continue;
|
||||
// 게임 특성 상 Far가 너무 멀어서 프리베이크랑 차이가 안남
|
||||
pTargetPlanes = m_vFarShadowViewBoxPlane;
|
||||
}
|
||||
if (iCascadeIndex == 0) {
|
||||
pTargetPlanes = m_vNearShadowViewBoxPlane;
|
||||
fSafeRadius = fRadius;
|
||||
}
|
||||
if (iCascadeIndex == 1) {
|
||||
pTargetPlanes = m_vMiddleShadowViewBoxPlane;
|
||||
fSafeRadius = fRadius;
|
||||
}
|
||||
if (iCascadeIndex == 2) {
|
||||
pTargetPlanes = m_vFarShadowViewBoxPlane;
|
||||
fSafeRadius = fRadius;
|
||||
}
|
||||
|
||||
_bool bIsInside = true;
|
||||
@@ -306,6 +305,11 @@ void CPipeLine::Make_LightBoxes()
|
||||
if (iIndex == 1) targetPlanes = m_vMiddleShadowViewBoxPlane;
|
||||
if (iIndex == 2) targetPlanes = m_vFarShadowViewBoxPlane;
|
||||
|
||||
if (fMinZ > fMaxZ)
|
||||
{
|
||||
swap(fMinZ, fMaxZ);
|
||||
}
|
||||
|
||||
targetPlanes[0] = _float4(-1.f, 0.f, 0.f, fMinX); // Left
|
||||
targetPlanes[1] = _float4(1.f, 0.f, 0.f, -fMaxX); // Right
|
||||
targetPlanes[2] = _float4(0.f, -1.f, 0.f, fMinY); // Bottom
|
||||
@@ -418,6 +422,8 @@ void CPipeLine::Describe_Entity()
|
||||
_bool bModified = { false };
|
||||
_float fNear = m_fShadowNearBoxRatio;
|
||||
_float fFar = m_fShadowFarBoxRatio;
|
||||
_float fSafe_RadiusMultiplier = m_fSafe_RadiusMultiplier;
|
||||
_float fSafe_RadiusMargin = m_fSafe_RadiusMargin;
|
||||
_float4 vShadowBias = m_vShadowBias;
|
||||
if (GUI::DragFloat("m_fShadowNearBoxRatio", &fNear, 0.01f, 0.01f, 0.999f, "%.2f")) {
|
||||
bModified = true;
|
||||
@@ -425,6 +431,12 @@ void CPipeLine::Describe_Entity()
|
||||
if (GUI::DragFloat("m_fShadowFarBoxRatio", &fFar, 0.01f, 0.01f, 0.999f, "%.2f")) {
|
||||
bModified = true;
|
||||
}
|
||||
if (GUI::DragFloat("m_fSafe_RadiusMultiplier", &fSafe_RadiusMultiplier, 0.01f, 1.f, 3.f, "%.2f")) {
|
||||
bModified = true;
|
||||
}
|
||||
if (GUI::DragFloat("m_fSafe_RadiusMargin", &fSafe_RadiusMargin, 1.f, 10.f, 40.f, "%.2f")) {
|
||||
bModified = true;
|
||||
}
|
||||
GUI::PushItemWidth(150.f);
|
||||
if (GUI::DragFloat4("ShadowBiasNMFS", (_float*)&vShadowBias, 0.0001f, 0.0001f, 1.f, "%.4f")) {
|
||||
bModified = true;
|
||||
@@ -434,6 +446,8 @@ void CPipeLine::Describe_Entity()
|
||||
m_fShadowNearBoxRatio = fNear;
|
||||
m_fShadowFarBoxRatio = fFar;
|
||||
m_vShadowBias = vShadowBias;
|
||||
m_fSafe_RadiusMultiplier = fSafe_RadiusMultiplier;
|
||||
m_fSafe_RadiusMargin = fSafe_RadiusMargin;
|
||||
}
|
||||
}
|
||||
GUI::End();
|
||||
|
||||
@@ -713,6 +713,11 @@ void CRenderer::Render_SSAO()
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShader->Bind_RawValue("g_fSSAOStrength", &m_fSSAOStrength, sizeof(_float)))) {
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
{
|
||||
// Bind_Targets
|
||||
|
||||
@@ -551,7 +551,6 @@ void CRenderer::Describe_Entitiy()
|
||||
{
|
||||
GUI::Begin("SYSTEM", 0, IMGUI_GLOBAL_BEGIN_FLAG);
|
||||
if (GUI::CollapsingHeader("RENDERER")) {
|
||||
GUI::PushItemWidth(80);
|
||||
if (GUI::CollapsingHeader("PostProcessing_Bloom"))
|
||||
{
|
||||
GUI::BeginChild("PostProcessing_Bloom");
|
||||
@@ -586,6 +585,7 @@ void CRenderer::Describe_Entitiy()
|
||||
GUI::BeginChild("SSAO_Setting", ImVec2(0, 0), true);
|
||||
GUI::DragFloat("fSSAORadius ", &m_fSSAO_Radius, 0.001f, -3.f, 3.f, "%.5f");
|
||||
GUI::DragFloat("fSSAO_BIAS", &m_fSSAO_BIAS, 0.001f, -2.f, 2.f, "%.5f");
|
||||
GUI::DragFloat("fSSAOStrength", &m_fSSAOStrength, 0.01f, 1.f, 4.f, "%.5f");
|
||||
GUI::EndChild();
|
||||
}
|
||||
if (GUI::CollapsingHeader("ToneMapping")) {
|
||||
@@ -594,6 +594,8 @@ void CRenderer::Describe_Entitiy()
|
||||
GUI::SliderFloat("m_fExposure", &m_fExposure, 0.5f, 2.f, "%.3f");
|
||||
GUI::EndChild();
|
||||
}
|
||||
if (GUI::CollapsingHeader("End_Padding")) {
|
||||
}
|
||||
}
|
||||
GUI::End();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ class CPipeLine final : public CBase
|
||||
_float4 m_vCamPosition = {};
|
||||
|
||||
_float m_fShadowNearBoxRatio = { 0.07f };
|
||||
_float m_fShadowFarBoxRatio = { 0.35f };
|
||||
_float m_fShadowFarBoxRatio = { 0.15f };
|
||||
_float m_fSafe_RadiusMultiplier = { 2.3f };
|
||||
_float m_fSafe_RadiusMargin = { 10.f };
|
||||
_float4 m_vShadowBias = { 0.0018f, 0.0018f, 0.0018f, 0.0018f };
|
||||
|
||||
_float4 m_vOriginalRenderFrustumPoints[8] = {};
|
||||
|
||||
@@ -68,8 +68,9 @@ class CRenderer final : public CBase
|
||||
_float m_fDOF_ENV_AmountRadius = { 1.f };
|
||||
|
||||
// SSAO
|
||||
_float m_fSSAO_Radius = { 1.6300f };
|
||||
_float m_fSSAO_BIAS = { 0.234f };
|
||||
_float m_fSSAO_Radius = { 1.6300f };
|
||||
_float m_fSSAO_BIAS = { 0.234f };
|
||||
_float m_fSSAOStrength = { 2.83f };
|
||||
|
||||
SSAO_GEOMETRY_HEMISPHERE m_tagSSAOGeometry = {};
|
||||
SSAO_GEOMETRYDIRECTIONS_RANDOM_REAL m_tagSSAOGeometryDirections = {};
|
||||
|
||||
Reference in New Issue
Block a user