[add] MotionTrail 주석추가 MB 주석추

This commit is contained in:
kimnuri
2026-02-08 16:35:23 +09:00
parent 93e259e711
commit 9af481e66a
2 changed files with 30 additions and 11 deletions
@@ -323,21 +323,36 @@ float3 DecodeNormalFromRG(Texture2D NormalMap, SamplerState Samp, float2 uv)
}
// BackGround ForeGround 합은 1
float2 DepthCompare(float fCenterDepth, float fSampleDepth, float fDepthScale)
float2 ComputeDepthWeights(float fCenterDepth, float fSampleDepth, float fDepthScale)
{
return saturate(0.5f + float2(fDepthScale, -fDepthScale) * (fSampleDepth - fCenterDepth));
}
float delta = fSampleDepth - fCenterDepth;
float2 SpreadCompare(float fOffsetLength, float2 fSpreadLength, float fPixelToSampleUnitsScale)
// backgroundWeight: sample이 더 멀수록 증가
float backgroundWeight = saturate(0.5f + fDepthScale * delta);
float foregroundWeight = 1.0f - backgroundWeight;
return float2(backgroundWeight, foregroundWeight);
}
float ComputeSpreadWeight(float fOffsetLength, float fSpreadLength, float fPixelToSampleUnitsScale)
{
return saturate(fPixelToSampleUnitsScale * fSpreadLength - fOffsetLength + 1.f);
}
float SampleWeight(float fCenterDepth, float fSampleDepth, float fOffsetLength, float fCenterSpreadLength, float fSampleSpreadLength, float fPixelToSampleUnitsScale, float fDepthScale)
// 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)
{
float2 vDepthCompare = DepthCompare(fCenterDepth, fSampleDepth, fDepthScale);
float2 vSpreadCompare = SpreadCompare(fOffsetLength, float2(fCenterSpreadLength, fSampleSpreadLength), fPixelToSampleUnitsScale);
return dot(vDepthCompare, vSpreadCompare);
float2 vDepthCompare = ComputeDepthWeights(fCenterDepth, fSampleDepth, fDepthScale);
float fSpreadCenter = ComputeSpreadWeight(fOffsetLength, fCenterSpreadLength, fPixelToSampleUnitsScale);
float fSpreadSample = ComputeSpreadWeight(fOffsetLength, fSampleSpreadLength, fPixelToSampleUnitsScale);
return vDepthCompare.x * fSpreadCenter + vDepthCompare.y * fSpreadSample;
}
float4x4 RotateX(float fAngle)
@@ -28,6 +28,7 @@ HRESULT CMotion_Trail::Update_Capture(_float fDeltaTime)
CAPTUREINFO* pInfo = (*iter);
pInfo->vCaptureLifeTime.x += fDeltaTime;
if (m_fMaxCaptureLifeTime < pInfo->vCaptureLifeTime.x) {
// LifeTime이 종료된 Capture는 정보를 지우고 보관
if (FAILED(ClearInfos(*pInfo))) {
return E_FAIL;
}
@@ -84,9 +85,11 @@ HRESULT CMotion_Trail::Render(CShader* pShader)
return S_OK;
}
// dispatch 전에 호출할 해야 합니다
HRESULT CMotion_Trail::Capture_Model(ID3D11Buffer* pBoneBuffer, const _float4x4& matCurrentWorld)
{
CAPTUREINFO* pInfo = { nullptr };
// 남은리소스가 있는지 검사하고 없다면 가장 마지막 캡쳐를 사용
if (m_RemainingInfos->empty()) {
pInfo = m_CaptureInfos->front();
if (FAILED(ClearInfos(*pInfo))) {
@@ -98,6 +101,7 @@ HRESULT CMotion_Trail::Capture_Model(ID3D11Buffer* pBoneBuffer, const _float4x4&
pInfo = m_RemainingInfos->front();
m_RemainingInfos->pop();
}
// 캡쳐되는 상황의 월드 트랜스폼과 본버퍼 기록
m_pContext->CopyResource(pInfo->pBoneMatrixBuffer, pBoneBuffer);
pInfo->WorldMatrix = matCurrentWorld;
m_CaptureInfos->emplace_back(pInfo);
@@ -118,8 +122,8 @@ HRESULT CMotion_Trail::Initialize_Prototype(MODELCAPTURE_DESC* pDesc)
m_fMaxCaptureLifeTime = pDesc->fMaxCaptureLifeTime;
m_iMaximumCapture = pDesc->iMaximumCapture;
m_iNumBones = pDesc->iNumBones;
m_CaptureInfos = new list<CAPTUREINFO*>;
m_RemainingInfos = new queue<CAPTUREINFO*>;
m_CaptureInfos = new list<CAPTUREINFO*>;
m_RemainingInfos = new queue<CAPTUREINFO*>;
vector<CAPTUREINFO*> Infos = {};
for (_uint i = 0; i < m_iMaximumCapture; ++i) {
CAPTUREINFO* pInfo = new CAPTUREINFO();