파일명, 함수명 수정
This commit is contained in:
+2
-1
@@ -39,4 +39,5 @@ enc_temp_folder/
|
||||
Jusin154_Team3D/Client/Bin/Resources/
|
||||
|
||||
# Imgui 임시 파일
|
||||
imgui.ini
|
||||
imgui.ini
|
||||
/Jusin154_Team3D/Editor/Bin/Resources/Models/MapMesh/Game/Levels/Overland/SubLevels/HS_AI_Feature_CastleRuin_01LOD/ProxyAssets/SM_MERGED_SM_GobMine_CoalPile_HS_AI_LOD1/T_SM_MERGED_SM_GobMine_CoalPile_HS_AI_LOD1_Diffuse.dds
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
@@ -322,37 +322,28 @@ float3 DecodeNormalFromRG(Texture2D NormalMap, SamplerState Samp, float2 uv)
|
||||
return normalize(n);
|
||||
}
|
||||
|
||||
// BackGround ForeGround 합은 1
|
||||
float2 ComputeDepthWeights(float fCenterDepth, float fSampleDepth, float fDepthScale)
|
||||
{
|
||||
float delta = fSampleDepth - fCenterDepth;
|
||||
|
||||
// backgroundWeight: sample이 더 멀수록 증가
|
||||
float fBackgroundWeight = saturate(0.5f + fDepthScale * delta);
|
||||
float fForegroundWeight = 1.0f - fBackgroundWeight;
|
||||
|
||||
return float2(fBackgroundWeight, fForegroundWeight);
|
||||
}
|
||||
float ComputeSpreadWeight(float fOffsetLength, float fSpreadLength, float fPixelToSampleUnitsScale)
|
||||
float ComputeSpreadWeight(float fStepOffset, float fSpreadLength, float fVelocityScale)
|
||||
{
|
||||
return saturate(fPixelToSampleUnitsScale * fSpreadLength - fOffsetLength + 1.f);
|
||||
return saturate(fVelocityScale * fSpreadLength - fStepOffset + 1.f);
|
||||
}
|
||||
// fCenterDepth : 현재 중심 픽셀의 깊이
|
||||
// fSampleDepth : 샘플 픽셀의 깊이
|
||||
// fOffsetLength : 중심에서 샘플까지의 거리
|
||||
// fCenterSpreadLength : 중심 픽셀의 블러 반경
|
||||
// fSampleSpreadLength : 샘플 픽셀의 블러 반경
|
||||
// fPixelToSampleUnitsScale : spread/offset 단위
|
||||
// fDepthScale : 깊이 차이에 얼마나 민감하게 전경/배경을 나눌지
|
||||
float SampleWeight(float fCenterDepth, float fSampleDepth, float fOffsetLength, float fCenterSpreadLength,
|
||||
float fSampleSpreadLength, float fPixelToSampleUnitsScale, float fDepthScale)
|
||||
float SampleWeight(float fCenterDepth, float fSampleDepth, float fStepOffset, float fCenterSpreadLength,
|
||||
float fSampleSpreadLength, float fVelocityScale, float fDepthScale)
|
||||
{
|
||||
float2 vDepthCompare = ComputeDepthWeights(fCenterDepth, fSampleDepth, fDepthScale);
|
||||
|
||||
float fSpreadCenter = ComputeSpreadWeight(fOffsetLength, fCenterSpreadLength, fPixelToSampleUnitsScale);
|
||||
float fSpreadSample = ComputeSpreadWeight(fOffsetLength, fSampleSpreadLength, fPixelToSampleUnitsScale);
|
||||
float fCenter = ComputeSpreadWeight(fStepOffset, fCenterSpreadLength, fVelocityScale);
|
||||
float fSample = ComputeSpreadWeight(fStepOffset, fSampleSpreadLength, fVelocityScale);
|
||||
|
||||
return vDepthCompare.x * fSpreadCenter + vDepthCompare.y * fSpreadSample;
|
||||
return vDepthCompare.x * fCenter + vDepthCompare.y * fSample;
|
||||
}
|
||||
|
||||
float4x4 RotateX(float fAngle)
|
||||
@@ -598,24 +589,26 @@ float4 BlendDiffuse(float4 vDiffuseA, Texture2D DiffuseBlendTexture, float2 vTex
|
||||
float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos, float fIntensity = 1.f)
|
||||
{
|
||||
float2 vReturnVelocity = float2(0.5f, 0.5f);
|
||||
if (vCurrentProjPos.w <= FLT_EPSILON5 || vPreviousProjPos.w <= FLT_EPSILON5)
|
||||
{
|
||||
if (vCurrentProjPos.w <= FLT_EPSILON5 || vPreviousProjPos.w <= FLT_EPSILON5) {
|
||||
return vReturnVelocity;
|
||||
}
|
||||
|
||||
{
|
||||
float2 currentNDC = vCurrentProjPos.xy / vCurrentProjPos.w;
|
||||
float2 previousNDC = vPreviousProjPos.xy / vPreviousProjPos.w;
|
||||
|
||||
float2 currentNDC = vCurrentProjPos.xy / vCurrentProjPos.w;
|
||||
float2 previousNDC = vPreviousProjPos.xy / vPreviousProjPos.w;
|
||||
currentNDC.y *= -1.f;
|
||||
previousNDC.y *= -1.f;
|
||||
|
||||
currentNDC.y *= -1.f;
|
||||
previousNDC.y *= -1.f;
|
||||
float2 velocityUV = (currentNDC - previousNDC) * 0.5f;
|
||||
velocityUV *= fIntensity;
|
||||
velocityUV = clamp(velocityUV, -1.0f, 1.0f);
|
||||
|
||||
// UV 델타
|
||||
float2 velocityUV = (currentNDC - previousNDC) * 0.5f;
|
||||
velocityUV *= fIntensity;
|
||||
velocityUV = clamp(velocityUV, -1.0f, 1.0f);
|
||||
|
||||
return velocityUV * 0.5f + 0.5f; // 0 속도 -> 0.5
|
||||
vReturnVelocity = velocityUV * 0.5f + 0.5f;
|
||||
}
|
||||
return vReturnVelocity;
|
||||
}
|
||||
|
||||
float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos)
|
||||
{
|
||||
return CalcVelocityUV(vCurrentProjPos, vPreviousProjPos, 1.0f);
|
||||
|
||||
@@ -269,33 +269,34 @@ PS_OUT_VELOCITYBLUR PS_MOTIONBLUR(PS_IN In)
|
||||
|
||||
float2 vCenterUV = In.vTexcoord;
|
||||
float2 vFullResolutionTexelSize = 1.f / g_vResolution;
|
||||
float fCenterDepth = g_DepthTexture.Sample(PointSampler, vCenterUV).y;
|
||||
float2 vCenterVelo = g_VelocityTexture.Sample(PointSampler, vCenterUV).xy * 2.f - 1.f; // 0~1 -> -1~+1
|
||||
float2 vCenterVeloPixel = vCenterVelo * g_vResolution.xy;
|
||||
bool bBorrowedVelocityFromTile = false;
|
||||
float fCenterDepth = g_DepthTexture.Sample(PointSampler, vCenterUV).y * g_fFar;
|
||||
float2 vCenterVelocity = g_VelocityTexture.Sample(PointSampler, vCenterUV).xy * 2.f - 1.f; // 0~1 -> -1~+1
|
||||
float2 vCenterVeloPixel = vCenterVelocity * g_vResolution.xy;
|
||||
bool bBorrowedVelocity = false;
|
||||
|
||||
float2 vBlurVelo = vCenterVelo;
|
||||
float2 vBlurVeloPixel = vCenterVeloPixel; // 프레임당 픽셀 이동량
|
||||
float2 vBlurVelocity = vCenterVelocity;
|
||||
float2 vBlurVelocityPixel = vCenterVelocity * g_vResolution.xy; // 프레임당 픽셀 이동량
|
||||
|
||||
float fVelocityEpsilon = 0.5f;
|
||||
|
||||
if (length(vBlurVeloPixel) < fVelocityEpsilon)
|
||||
if (length(vBlurVelocityPixel) < fVelocityEpsilon)
|
||||
{
|
||||
// 사실상 정지해 있던 픽셀이면 텐트벨로시티맵에서 빌려옴
|
||||
vBlurVelo = g_TileVelocityTexture.Sample(PointSampler, vCenterUV).xy * 2.f - 1.f;
|
||||
vBlurVeloPixel = vBlurVelo * g_vResolution.xy;
|
||||
bBorrowedVelocityFromTile = true;
|
||||
vBlurVelocity = g_TileVelocityTexture.Sample(PointSampler, vCenterUV).xy * 2.f - 1.f;
|
||||
vBlurVelocityPixel = vBlurVelocity * g_vResolution.xy;
|
||||
bBorrowedVelocity = true;
|
||||
}
|
||||
|
||||
if (length(vBlurVeloPixel) < fVelocityEpsilon) {
|
||||
if (length(vBlurVelocityPixel) < fVelocityEpsilon)
|
||||
{
|
||||
// 텐트벨로시티맵에서 빌려온 픽셀또한 정지해 있었으면 원본 그대로 반환
|
||||
Out.vColor = g_ColorTexture.Sample(ClampLinearSampler, vCenterUV);
|
||||
Out.vVelocity = float2(0.5f, 0.5f);
|
||||
return Out;
|
||||
}
|
||||
float fPixelSpeed = length(vBlurVeloPixel);
|
||||
float fPixelSpeed = length(vBlurVelocityPixel);
|
||||
|
||||
float2 vBlurDirPixel = (vBlurVeloPixel / max(fPixelSpeed, FLT_EPSILON5));
|
||||
float2 vBlurDirPixel = (vBlurVelocityPixel / max(fPixelSpeed, FLT_EPSILON5));
|
||||
|
||||
// 픽셀의 속도로 블러 반경을 가변적으로 돌림
|
||||
float fBlurRadiusPixel = clamp(fPixelSpeed * 0.4f , 0.f, g_fMBMaxBlurRadius);
|
||||
@@ -308,39 +309,40 @@ PS_OUT_VELOCITYBLUR PS_MOTIONBLUR(PS_IN In)
|
||||
float fSamplePixelSpeed = fBlurRadiusPixel / max((float) iMaxRadius, 1.f);
|
||||
|
||||
// 샘플유닛의 크기
|
||||
float fScalePixelToSampleUnit = (float) iMaxRadius / max(fBlurRadiusPixel, FLT_EPSILON5);
|
||||
float fScaleDepth = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
|
||||
float fVelocityScale = (float) iMaxRadius / max(fBlurRadiusPixel, FLT_EPSILON5);
|
||||
float fDepthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
|
||||
float4 vAccColorSum = float4(0.f, 0.f, 0.f, 0.f);
|
||||
float2 vAccVeloSum = float2(0.f, 0.f);
|
||||
float fAccWeight = 0.f;
|
||||
|
||||
// 센터의 스프레드 길이
|
||||
float2 vReferenceVelocityPixel = bBorrowedVelocityFromTile ? vBlurVeloPixel : vCenterVeloPixel; // 빌린놈이면 빌린 타일이 속도 레퍼런스, 아니면 센터가 속도 레퍼런스가 됨
|
||||
float fCenterSpreadLengthPixel = clamp(abs(dot(vReferenceVelocityPixel, vBlurDirPixel)), 0.f, fBlurRadiusPixel); // fSampleSpreadLengthPixel 랑 비교하게 될 짝꿍
|
||||
float2 vReferenceVelocityPixel = bBorrowedVelocity ? vBlurVelocityPixel : vCenterVeloPixel; // 빌린놈이면 빌린 타일이 속도 레퍼런스, 아니면 센터가 속도 레퍼런스가 됨
|
||||
float fCurrentVelocityVector = clamp(abs(dot(vReferenceVelocityPixel, vBlurDirPixel)), 0.f, fBlurRadiusPixel); // fSampleSpreadLengthPixel 랑 비교하게 될 짝꿍
|
||||
|
||||
[loop]
|
||||
for (int iInterval = -iMaxRadius; iInterval <= iMaxRadius; ++iInterval) {
|
||||
float fOffset = (float) abs(iInterval);
|
||||
float2 vOffsetPixel = vBlurDirPixel * ((float) iInterval * fSamplePixelSpeed);
|
||||
for (int iStep = -iMaxRadius; iStep <= iMaxRadius; ++iStep)
|
||||
{
|
||||
float fOffset = (float) abs(iStep);
|
||||
float2 vOffsetPixel = vBlurDirPixel * ((float) iStep * fSamplePixelSpeed);
|
||||
float2 vSamplingUV = vCenterUV + vOffsetPixel * vFullResolutionTexelSize;
|
||||
if (false == IsValidUV(vSamplingUV)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float fSampledDepth = g_DepthTexture.Sample(PointSampler, vSamplingUV).y;
|
||||
float2 vSampledVelo = g_VelocityTexture.Sample(PointSampler, vSamplingUV).xy * 2.f - 1.f;
|
||||
float2 vSampledVeloPixel = vSampledVelo * g_vResolution.xy;
|
||||
float fSampleDepth = g_DepthTexture.Sample(PointSampler, vSamplingUV).y * g_fFar;
|
||||
float2 vSampledVelocity = g_VelocityTexture.Sample(PointSampler, vSamplingUV).xy * 2.f - 1.f;
|
||||
float2 vSampledVelocityPixel = vSampledVelocity * g_vResolution.xy;
|
||||
|
||||
// 샘플의 스프레드 길이
|
||||
float fBlurSampleAccurate = abs(dot(vSampledVeloPixel, vBlurDirPixel));
|
||||
float fSampleSpreadLengthPixel = clamp(fBlurSampleAccurate, 0.f, fBlurRadiusPixel);
|
||||
if (true == bBorrowedVelocityFromTile)
|
||||
float fSampleVelocityVector = clamp(abs(dot(vSampledVelocityPixel, vBlurDirPixel)), 0.f, fBlurRadiusPixel);
|
||||
if (true == bBorrowedVelocity)
|
||||
{
|
||||
fSampleSpreadLengthPixel = max(fSampleSpreadLengthPixel, fCenterSpreadLengthPixel);
|
||||
fSampleVelocityVector = max(fSampleVelocityVector, fCurrentVelocityVector);
|
||||
}
|
||||
|
||||
// 샘플과 센터의 (깊이테스트 + 스프레드테스트)
|
||||
float fWeightCalculated = SampleWeight(fCenterDepth, fSampledDepth, fOffset, fCenterSpreadLengthPixel, fSampleSpreadLengthPixel, fScalePixelToSampleUnit, fScaleDepth);
|
||||
float fWeightCalculated = SampleWeight(fCenterDepth, fSampleDepth, fOffset,
|
||||
fCurrentVelocityVector, fSampleVelocityVector, fVelocityScale, fDepthScale);
|
||||
|
||||
if (fWeightCalculated <= 0.f) {
|
||||
continue;
|
||||
@@ -348,7 +350,7 @@ PS_OUT_VELOCITYBLUR PS_MOTIONBLUR(PS_IN In)
|
||||
|
||||
float4 vSampledColor = g_ColorTexture.Sample(ClampLinearSampler, vSamplingUV);
|
||||
vAccColorSum += vSampledColor * fWeightCalculated;
|
||||
vAccVeloSum += vSampledVelo * fWeightCalculated;
|
||||
vAccVeloSum += vSampledVelocity * fWeightCalculated;
|
||||
fAccWeight += fWeightCalculated;
|
||||
}
|
||||
float4 vBlurredColor = vAccColorSum / max(fAccWeight, FLT_EPSILON5);
|
||||
@@ -1324,42 +1326,43 @@ PS_OUT_SSAO_AMBIENT_OCCLUSION PS_SSAO_AMBIENT_OCCLUSION(PS_IN In)
|
||||
vCenterViewPosition /= vCenterViewPosition.w;
|
||||
}
|
||||
float3 vNormal = normalize(g_NormalTexture.Sample(PointSampler, uv).xyz * 2.f - 1.f);
|
||||
float3 vCenterViewNormal = mul(vNormal, (float3x3)g_ViewMatrix);
|
||||
float3 vCenterNormal = mul(vNormal, (float3x3) g_ViewMatrix);
|
||||
|
||||
float2 vNoiseScale = g_vResolution / 4.f;
|
||||
float3 vNoise = g_SSAONoiseTexture.Sample(SSAODataSampler, uv * vNoiseScale).xyz;
|
||||
|
||||
float3 vTangent = normalize(vNoise - vCenterViewNormal * dot(vNoise, vCenterViewNormal));
|
||||
float3 vBiNormal = cross(vCenterViewNormal, vTangent);
|
||||
float3x3 toViewTBNMatrix = float3x3(vTangent, vBiNormal, vCenterViewNormal);
|
||||
float3 vTangent = normalize(vNoise - vCenterNormal * dot(vNoise, vCenterNormal));
|
||||
float3 vBiNormal = cross(vCenterNormal, vTangent);
|
||||
float3x3 TBNMatrix = float3x3(vTangent, vBiNormal, vCenterNormal);
|
||||
|
||||
float fOcclusion = 0.f;
|
||||
[loop]
|
||||
for (uint i = 0; i < g_iKernelSize; ++i)
|
||||
{
|
||||
float3 vViewSamplePosVec = mul(g_SamplePos[i].xyz, toViewTBNMatrix); // TANSPACE -> VIEW
|
||||
float4 vViewSamplePos = vCenterViewPosition + float4(vViewSamplePosVec * g_fSSAORadius, 0.f);
|
||||
float4 vNDCSampleOffset = mul(vViewSamplePos, g_ProjMatrix);
|
||||
float3 vSampleVector= mul(g_SamplePos[i].xyz, TBNMatrix);
|
||||
float4 vSampleViewPosition = vCenterViewPosition + float4(vSampleVector * g_fSSAORadius, 0.f);
|
||||
float4 vNDCSampleOffset = mul(vSampleViewPosition, g_ProjMatrix);
|
||||
vNDCSampleOffset /= vNDCSampleOffset.w;
|
||||
|
||||
float2 sampleUV;
|
||||
sampleUV.x = vNDCSampleOffset.x * 0.5f + 0.5f;
|
||||
sampleUV.y = vNDCSampleOffset.y * -0.5f + 0.5f;
|
||||
float2 vSampleUV;
|
||||
vSampleUV.x = vNDCSampleOffset.x * 0.5f + 0.5f;
|
||||
vSampleUV.y = vNDCSampleOffset.y * -0.5f + 0.5f;
|
||||
|
||||
if (sampleUV.x < 0 || sampleUV.x > 1
|
||||
|| sampleUV.y < 0 || sampleUV.y > 1) {
|
||||
if (vSampleUV.x < 0 || vSampleUV.x > 1
|
||||
|| vSampleUV.y < 0 || vSampleUV.y > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float fRecordedSampleViewPosDepth = g_DepthTexture.Sample(PointSampler, sampleUV).y * g_fFar;
|
||||
float fIsOccluded = (fRecordedSampleViewPosDepth < vViewSamplePos.z - g_fSSAO_BIAS) ? 1.0f : 0.0f;
|
||||
float fRecordedDepth = g_DepthTexture.Sample(PointSampler, vSampleUV).y * g_fFar;
|
||||
float fIsOccluded = (fRecordedDepth < vSampleViewPosition.z - g_fSSAO_BIAS) ? 1.0f : 0.0f;
|
||||
|
||||
float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vViewSamplePos.z - fRecordedSampleViewPosDepth));
|
||||
float fRangeCheck = smoothstep(0.f, 1.f, g_fSSAORadius / abs(vSampleViewPosition.z - fRecordedDepth));
|
||||
fIsOccluded *= fRangeCheck;
|
||||
fOcclusion += fIsOccluded;
|
||||
}
|
||||
fOcclusion = saturate(1.f - (fOcclusion * g_fSSAOStrength / g_iKernelSize) * fRatio);
|
||||
Out.fOcclusion = fOcclusion ;
|
||||
Out.fOcclusion = fOcclusion;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -23,23 +23,23 @@ void CPipeLine::Set_Environment(_float2 vNFBoxRatio, _float2 vSafeRadius, _float
|
||||
|
||||
m_vShadowBias = vShadowBias;
|
||||
m_vShadowRadius = vShadowRadius;
|
||||
m_vShadowBoxMarginMin = vShadowBoxMarginMin;
|
||||
m_vShadowBoxMarginMax = vShadowBoxMarginMax;
|
||||
m_vShadowMarginMin = vShadowBoxMarginMin;
|
||||
m_vShadowMarginMax = vShadowBoxMarginMax;
|
||||
}
|
||||
|
||||
void CPipeLine::Set_Transform(D3DTS eState, _fmatrix TransformStateMatrix)
|
||||
{
|
||||
XMStoreFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(eState)], TransformStateMatrix);
|
||||
XMStoreFloat4x4(&m_TransformMatrices[ENUM_CLASS(eState)], TransformStateMatrix);
|
||||
}
|
||||
|
||||
const _float4x4* CPipeLine::Get_Transform_Float4x4(D3DTS eState)
|
||||
{
|
||||
return &m_TransformStateMatrices[ENUM_CLASS(eState)];
|
||||
return &m_TransformMatrices[ENUM_CLASS(eState)];
|
||||
}
|
||||
|
||||
_matrix CPipeLine::Get_Transform_Matrix(D3DTS eState)
|
||||
{
|
||||
return XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(eState)]);
|
||||
return XMLoadFloat4x4(&m_TransformMatrices[ENUM_CLASS(eState)]);
|
||||
}
|
||||
|
||||
_matrix CPipeLine::Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType)
|
||||
@@ -56,7 +56,7 @@ _matrix CPipeLine::Get_ShadowTransform_Matrix(D3DTS eState, SHADOW eShadowType)
|
||||
}
|
||||
assert(iPass != UINT_MAX);
|
||||
|
||||
return XMLoadFloat4x4(&m_ShadowTransformStateMatrices[iPass][ENUM_CLASS(eState)]);
|
||||
return XMLoadFloat4x4(&m_ShadowTransformMatrices[iPass][ENUM_CLASS(eState)]);
|
||||
}
|
||||
|
||||
const _float4* CPipeLine::Get_CamPosition()
|
||||
@@ -107,7 +107,7 @@ pair<_bool, _ubyte> CPipeLine::IsIn_ShadowViewFrustum(_fvector vWorldCenter, _fl
|
||||
{
|
||||
pair<_bool, _ubyte> pairResult = { false, 0 };
|
||||
// 월드 센터를 셰도우뷰 센터로 바꿈
|
||||
_vector vShadowViewCenter = XMVectorSetW(XMVector3Rotate(vWorldCenter, XMLoadFloat4(&m_vShadowInvDirectionalRPYQuat)), 1.f);
|
||||
_vector vShadowViewCenter = XMVectorSetW(XMVector3Rotate(vWorldCenter, XMLoadFloat4(&m_vShadowInvQuat)), 1.f);
|
||||
|
||||
_float fSafeRadius = (fRadius + m_fSafe_RadiusMargin) * m_fSafe_RadiusMultiplier; // 그림자임을 고려해서 객체 부피보다 좀 더 넓게 탐색
|
||||
|
||||
@@ -208,8 +208,8 @@ HRESULT CPipeLine::End_OutLine_Write()
|
||||
HRESULT CPipeLine::Ready_Shadow_Light(const _float4& vShadowDirRPYQuat)
|
||||
{
|
||||
_vector vShadowQuat = XMQuaternionNormalize(XMLoadFloat4(&vShadowDirRPYQuat));
|
||||
XMStoreFloat4(&m_vShadowDirectionalRPYQuat, vShadowQuat);
|
||||
XMStoreFloat4(&m_vShadowInvDirectionalRPYQuat, XMQuaternionInverse(vShadowQuat));
|
||||
XMStoreFloat4(&m_vShadowQuat, vShadowQuat);
|
||||
XMStoreFloat4(&m_vShadowInvQuat, XMQuaternionInverse(vShadowQuat));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -230,12 +230,12 @@ HRESULT CPipeLine::Bind_Shadow_Resource(CShader* pShader, const _char* pConstant
|
||||
}
|
||||
assert(iPass != UINT_MAX);
|
||||
|
||||
return pShader->Bind_Matrix(pConstantName, &m_ShadowTransformStateMatrices[iPass][ENUM_CLASS(eType)]);
|
||||
return pShader->Bind_Matrix(pConstantName, &m_ShadowTransformMatrices[iPass][ENUM_CLASS(eType)]);
|
||||
}
|
||||
|
||||
const _float4x4* CPipeLine::Get_ShadowMatricesPtr(_uint iShadowBoxIndex)
|
||||
{
|
||||
return m_ShadowTransformStateMatrices[iShadowBoxIndex];
|
||||
return m_ShadowTransformMatrices[iShadowBoxIndex];
|
||||
}
|
||||
|
||||
_float CPipeLine::Get_ShadowBoxFar(_uint iShadowBoxIndex)
|
||||
@@ -265,16 +265,16 @@ void CPipeLine::Update()
|
||||
#endif // RELEASE_DEBUGGER
|
||||
Update_ShadowDepthNdcZ();
|
||||
|
||||
XMStoreFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)], XMMatrixInverse(nullptr, Get_Transform_Matrix(D3DTS::VIEW)));
|
||||
XMStoreFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, Get_Transform_Matrix(D3DTS::PROJ)));
|
||||
XMStoreFloat4x4(&m_TransformMatrices[ENUM_CLASS(D3DTS::VIEW_INV)], XMMatrixInverse(nullptr, Get_Transform_Matrix(D3DTS::VIEW)));
|
||||
XMStoreFloat4x4(&m_TransformMatrices[ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, Get_Transform_Matrix(D3DTS::PROJ)));
|
||||
|
||||
|
||||
memcpy(&m_vCamPosition, &m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)].m[3], sizeof(_float4));
|
||||
_matrix ProjInvMatrix = XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::PROJ_INV)]);
|
||||
_matrix ViewInvMatrix = XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)]);
|
||||
memcpy(&m_vCamPosition, &m_TransformMatrices[ENUM_CLASS(D3DTS::VIEW_INV)].m[3], sizeof(_float4));
|
||||
_matrix ProjInvMatrix = XMLoadFloat4x4(&m_TransformMatrices[ENUM_CLASS(D3DTS::PROJ_INV)]);
|
||||
_matrix ViewInvMatrix = XMLoadFloat4x4(&m_TransformMatrices[ENUM_CLASS(D3DTS::VIEW_INV)]);
|
||||
_matrix WorldFromClipMatrix = XMMatrixMultiply(ProjInvMatrix, ViewInvMatrix);
|
||||
|
||||
_vector vShadowInvQuat = XMLoadFloat4(&m_vShadowInvDirectionalRPYQuat);
|
||||
_vector vShadowInvQuat = XMLoadFloat4(&m_vShadowInvQuat);
|
||||
for (size_t i = 0; i < 8; ++i)
|
||||
{
|
||||
XMStoreFloat4(&m_vWorldPoints[i], XMVector3TransformCoord(XMLoadFloat4(&m_vOriginalRenderFrustumPoints[i]), WorldFromClipMatrix));
|
||||
@@ -314,7 +314,7 @@ HRESULT CPipeLine::Initialize()
|
||||
m_vOriginalShadowFrustumPoints[15] = m_vOriginalRenderFrustumPoints[7] = _float4(-1.f, -1.f, 1.f, 1.f); // LB
|
||||
|
||||
for (_uint i = ENUM_CLASS(D3DTS::VIEW); i < ENUM_CLASS(D3DTS::END); ++i) {
|
||||
XMStoreFloat4x4(&m_TransformStateMatrices[i], XMMatrixIdentity());
|
||||
XMStoreFloat4x4(&m_TransformMatrices[i], XMMatrixIdentity());
|
||||
}
|
||||
|
||||
if (nullptr == m_pDSS_OutLineWrite) {
|
||||
@@ -356,16 +356,17 @@ void CPipeLine::Make_Planes(const _float4* pPoints, _float4* pPlanes)
|
||||
|
||||
void CPipeLine::Make_LightBoxes()
|
||||
{
|
||||
// AABB Lighting space
|
||||
_vector vShadowInvQuat = XMLoadFloat4(&m_vShadowInvDirectionalRPYQuat);
|
||||
_matrix ViewMatrix = XMMatrixRotationQuaternion(vShadowInvQuat);
|
||||
// Directional Light 기준 View Matrix
|
||||
_matrix ViewMatrix = XMMatrixRotationQuaternion(XMLoadFloat4(&m_vShadowInvQuat));
|
||||
_matrix ViewInvMatrix = XMMatrixInverse(nullptr, ViewMatrix);
|
||||
|
||||
// Cascaded Shadow Map (3단계: Near / Middle / Far)
|
||||
for (_uint iIndex = 0; iIndex < 3; ++iIndex)
|
||||
{
|
||||
_float4 vCascadePoints8[8] = {};
|
||||
Get_CascadePoints8(m_vShadowViewPoints, iIndex, vCascadePoints8);
|
||||
|
||||
// AABB 초기값 설정 (첫 번째 점 기준)
|
||||
_float fMinX = vCascadePoints8[0].x;
|
||||
_float fMinY = vCascadePoints8[0].y;
|
||||
_float fMinZ = vCascadePoints8[0].z;
|
||||
@@ -374,6 +375,7 @@ void CPipeLine::Make_LightBoxes()
|
||||
_float fMaxY = vCascadePoints8[0].y;
|
||||
_float fMaxZ = vCascadePoints8[0].z;
|
||||
|
||||
// 8개의 점을 순회하면서 AABB 계산 (Bounding Box 생성)
|
||||
for (_uint iPointIndex = 1; iPointIndex < 8; ++iPointIndex)
|
||||
{
|
||||
fMinX = min(fMinX, vCascadePoints8[iPointIndex].x);
|
||||
@@ -385,18 +387,21 @@ void CPipeLine::Make_LightBoxes()
|
||||
fMaxZ = max(fMaxZ, vCascadePoints8[iPointIndex].z);
|
||||
}
|
||||
|
||||
// 각 Cascade 별로 결과를 저장할 Plane 배열 선택
|
||||
_float4* targetPlanes = nullptr;
|
||||
if (iIndex == 0) targetPlanes = m_vNearShadowViewBoxPlane;
|
||||
if (iIndex == 1) targetPlanes = m_vMiddleShadowViewBoxPlane;
|
||||
if (iIndex == 2) targetPlanes = m_vFarShadowViewBoxPlane;
|
||||
|
||||
fMinX += m_vShadowBoxMarginMin.x;
|
||||
fMaxX += m_vShadowBoxMarginMax.x;
|
||||
fMinY += m_vShadowBoxMarginMin.y;
|
||||
fMaxY += m_vShadowBoxMarginMax.y;
|
||||
fMinZ += m_vShadowBoxMarginMin.z;
|
||||
fMaxZ += m_vShadowBoxMarginMax.z;
|
||||
// Shadow Box 여유 공간 추가 (Shadow clipping 방지 / 안정성 확보)
|
||||
fMinX += m_vShadowMarginMin.x;
|
||||
fMaxX += m_vShadowMarginMax.x;
|
||||
fMinY += m_vShadowMarginMin.y;
|
||||
fMaxY += m_vShadowMarginMax.y;
|
||||
fMinZ += m_vShadowMarginMin.z;
|
||||
fMaxZ += m_vShadowMarginMax.z;
|
||||
|
||||
// Cascade 별 Shadow Map 해상도 설정
|
||||
_uint iShadowWidth = { 0 };
|
||||
_uint iShadowHeight = { 0 };
|
||||
switch (iIndex)
|
||||
@@ -419,6 +424,9 @@ void CPipeLine::Make_LightBoxes()
|
||||
|
||||
Adjust_ShadowTexcel(fMinX, fMinY, fMaxX, fMaxY, iShadowWidth, iShadowHeight);
|
||||
|
||||
// Light-Space AABB를 Plane 형태로 변환 (Frustum 형태)
|
||||
// 물체는 그대로 World 좌표 사용
|
||||
// Plane vs Bounding Volume 테스트만 수행
|
||||
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
|
||||
@@ -426,14 +434,16 @@ void CPipeLine::Make_LightBoxes()
|
||||
targetPlanes[4] = _float4(0.f, 0.f, -1.f, fMinZ); // Near
|
||||
targetPlanes[5] = _float4(0.f, 0.f, 1.f, -fMaxZ); // Far
|
||||
|
||||
XMStoreFloat4x4(&m_ShadowTransformStateMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW)], ViewMatrix);
|
||||
XMStoreFloat4x4(&m_ShadowTransformStateMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW_INV)], ViewInvMatrix);
|
||||
|
||||
// Orthographic Projection 생성 Off-Center 방식 사용
|
||||
_matrix ProjMatrix = XMMatrixOrthographicOffCenterLH(fMinX, fMaxX, fMinY, fMaxY, fMinZ, fMaxZ);
|
||||
XMStoreFloat4x4(&m_ShadowTransformStateMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ)], ProjMatrix);
|
||||
XMStoreFloat4x4(&m_ShadowTransformStateMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, ProjMatrix));
|
||||
}
|
||||
|
||||
// Light View / View Inverse 저장
|
||||
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW)], ViewMatrix);
|
||||
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW_INV)], ViewInvMatrix);
|
||||
// Light Projection / Projection Inverse 저장
|
||||
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ)], ProjMatrix);
|
||||
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, ProjMatrix));
|
||||
}
|
||||
}
|
||||
|
||||
void CPipeLine::Get_CascadePoints8(const _float4* pShadowViewPoints16, _uint iIndexCascade, _float4* pOutPoints8)
|
||||
@@ -565,8 +575,8 @@ void CPipeLine::Describe_Entity()
|
||||
_float fSafe_RadiusMargin = m_fSafe_RadiusMargin;
|
||||
_float4 vShadowBias = m_vShadowBias;
|
||||
_float4 vShadowRadius = m_vShadowRadius;
|
||||
_float3 vShadowBoxMarginMin = m_vShadowBoxMarginMin;
|
||||
_float3 vShadowBoxMarginMax = m_vShadowBoxMarginMax;
|
||||
_float3 vShadowBoxMarginMin = m_vShadowMarginMin;
|
||||
_float3 vShadowBoxMarginMax = m_vShadowMarginMax;
|
||||
if (GUI::DragFloat("m_fShadowNearBoxRatio", &fNear, 0.001f, 0.001f, 0.999f, "%.3f")) {
|
||||
bModified = true;
|
||||
}
|
||||
@@ -598,8 +608,8 @@ void CPipeLine::Describe_Entity()
|
||||
m_vShadowRadius = vShadowRadius;
|
||||
m_fSafe_RadiusMultiplier = fSafe_RadiusMultiplier;
|
||||
m_fSafe_RadiusMargin = fSafe_RadiusMargin;
|
||||
m_vShadowBoxMarginMin = vShadowBoxMarginMin;
|
||||
m_vShadowBoxMarginMax = vShadowBoxMarginMax;
|
||||
m_vShadowMarginMin = vShadowBoxMarginMin;
|
||||
m_vShadowMarginMax = vShadowBoxMarginMax;
|
||||
}
|
||||
}
|
||||
GUI::End();
|
||||
|
||||
@@ -59,16 +59,16 @@ class CPipeLine final : public CBase
|
||||
ID3D11Device* m_pDevice = { nullptr };
|
||||
ID3D11DeviceContext* m_pContext = { nullptr };
|
||||
class CGameInstance* m_pGameInstance = { nullptr };
|
||||
_float4x4 m_TransformStateMatrices[ENUM_CLASS(D3DTS::END)] = {};
|
||||
_float4x4 m_ShadowTransformStateMatrices[3][ENUM_CLASS(D3DTS::END)] = {};
|
||||
_float4x4 m_TransformMatrices[ENUM_CLASS(D3DTS::END)] = {};
|
||||
_float4x4 m_ShadowTransformMatrices[3][ENUM_CLASS(D3DTS::END)] = {};
|
||||
_float4 m_vCamPosition = {};
|
||||
|
||||
_float m_fShadowNearBoxRatio = { 0.075f };
|
||||
_float m_fShadowFarBoxRatio = { 0.15f };
|
||||
_float m_fSafe_RadiusMultiplier = { 2.3f };
|
||||
_float m_fSafe_RadiusMargin = { 10.f };
|
||||
_float3 m_vShadowBoxMarginMin = { 0.f, 0.f, -25.f };
|
||||
_float3 m_vShadowBoxMarginMax = { 0.f, 0.f, 25.f };
|
||||
_float3 m_vShadowMarginMin = { 0.f, 0.f, -25.f };
|
||||
_float3 m_vShadowMarginMax = { 0.f, 0.f, 25.f };
|
||||
|
||||
_float4 m_vShadowBias = { 0.0047f, 0.0018f, 0.0018f, 0.0018f };
|
||||
_float4 m_vShadowRadius = { 2.f, 1.f, 1.f, 1.f };
|
||||
@@ -87,8 +87,8 @@ class CPipeLine final : public CBase
|
||||
_float4 m_vLocalNearShadowViewBoxPlane[6] = {};
|
||||
_float4 m_vLocalMiddleShadowViewBoxPlane[6] = {};
|
||||
_float4 m_vLocalFarShadowViewBoxPlane[6] = {};
|
||||
_float4 m_vShadowDirectionalRPYQuat = { 0.f, 0.f, 0.f, 1.f };
|
||||
_float4 m_vShadowInvDirectionalRPYQuat = { 0.f, 0.f, 0.f, 1.f };
|
||||
_float4 m_vShadowQuat = { 0.f, 0.f, 0.f, 1.f };
|
||||
_float4 m_vShadowInvQuat = { 0.f, 0.f, 0.f, 1.f };
|
||||
|
||||
unordered_map<_wstring, ID3D11ShaderResourceView*> m_mapGlobalSRV = {};
|
||||
ID3D11DepthStencilState* m_pDSS_OutLineWrite = { nullptr };
|
||||
|
||||
Reference in New Issue
Block a user