[add] Basic MB

This commit is contained in:
kimnuri
2025-12-18 22:19:45 +09:00
parent 0903d8cd20
commit 512da5fa14
20 changed files with 556 additions and 119 deletions
@@ -38,6 +38,11 @@ void CLevel_Loading::Update(_float fTimeDelta)
{
if (true == m_pLoader->isFinished())
{
#ifdef _DEBUG
#ifdef 기무리
m_bNextLevel = true;
#endif // 기무리
#endif // _DEBUG
if (m_eNextLevelID != LEVEL::LOGO)
m_bNextLevel = true;
else
@@ -26,9 +26,11 @@ HRESULT CLevel_Logo::Initialize()
void CLevel_Logo::Update(_float fTimeDelta)
{
//#ifdef 기무리
// m_pGameInstance->Set_LevelToChange();
//#endif // 기무리
#ifdef _DEBUG
#ifdef 기무리
m_pGameInstance->Set_LevelToChange();
#endif // 기무리
#endif // _DEBUG
if (m_pGameInstance->Key_Down(DIK_F1))
{
@@ -51,6 +51,7 @@ HRESULT CTerrain::Initialize(void* pArg)
void CTerrain::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
}
void CTerrain::Update(_float fTimeDelta)
@@ -169,6 +170,15 @@ HRESULT CTerrain::Bind_ShaderResources()
return E_FAIL;
}
if (FAILED(m_pShaderCom->Bind_Matrix("g_PrevWorldMatrix", m_pTransformCom->Get_PrevWorldMatrixPtr()))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevViewMatrix", D3DTS::VIEW))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Bind_PrevMatrix(m_pShaderCom, "g_PrevProjMatrix", D3DTS::PROJ))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
return E_FAIL;
}
@@ -480,30 +480,30 @@ float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos)
currentUV.y *= -1.f;
previousUV.y *= -1.f;
return currentUV - previousUV;
return (currentUV - previousUV) * 0.5f + 0.5f;
}
float3 DownSampleFast(Texture2D SrcTexture2D, float2 vCenterTexcoord, float2 vSrcTexelSize, float2 vResolution)
{
float2 uv = float2(0.f, 0.f);
float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, -1.0);
float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, -1.0);
float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, -1.0);
float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, 0.0);
float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(1.0, 0.0);
float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, +1.0);
float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, 1.0);
float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, +1.0);
float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
return vCenterColor * 0.25f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.0625f + (fTColor + fLColor + fRColor + fBColor) * 0.125f;
}
@@ -27,6 +27,13 @@ sampler ClampSampler = sampler_state
AddressV = clamp;
};
sampler ClampLinearSampler = sampler_state
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = clamp;
AddressV = clamp;
};
sampler MirrorSampler = sampler_state
{
Filter = MIN_MAG_MIP_LINEAR;
@@ -75,8 +75,9 @@ Texture2D g_ColorTexture;
Texture2D g_VelocityTexture;
int g_iMBSampleCount;
int g_fMBBlurRadius;
float g_iMBType;
float g_fMBBlurRadius;
int g_iMBType;
float g_fMBSampleBias;
vector g_vLightDiffuse;
vector g_vLightAmbient;
@@ -147,6 +148,7 @@ struct VS_OUT
struct PS_OUT_VELOCITYBLUR
{
float4 vColor : SV_TARGET0;
float2 vVelocity : SV_TARGET1;
};
VS_OUT VS_MAIN(VS_IN In)
{
@@ -227,25 +229,142 @@ struct PS_OUT_SSAO_BLUR
// g_ColorTexture;
// g_DepthTexture;
// g_VelocityTexture;
// g_DiffuseTexture;
// g_fFar
// g_fMBSampleBias
// g_fMBBlurRadius
// g_iMBType
// g_iMBSampleCount
PS_OUT_VELOCITYBLUR PS_MOTIONBLUR_X(PS_IN In)
PS_OUT_VELOCITYBLUR PS_MOTIONBLURX(PS_IN In)
{
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR)0;
//float2 uv = In.vTexcoord;
//float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
//float3 vColor = (0.f, 0.f, 0.f);
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
float2 vSumVelocity = float2(0.f, 0.f);
float4 vSumColor = float4(0.f, 0.f, 0.f, 0.f);
float4 vSampledColor = float4(0.f, 0.f, 0.f, 0.f);
float fSampledDepth = 1.f;
float fWeight = 0.f;
float2 vSampledVelocityUV;
float2 vSampledVelocityPixels;
float2 vDestUV;
float fSampleSpreadLength;
//for (int i = -g_iMBSampleCount; i < g_iMBSampleCount; ++i)
//{
// vTexcoord.x = In.vTexcoord.x + (float) i / g_vResolution.x;
// vTexcoord.y = In.vTexcoord.y;
float2 uv = In.vTexcoord;
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y * g_fFar; // 해당 셀의 깊이
float2 vCenterVelocityUV = g_VelocityTexture.Sample(PointSampler, uv).xy;
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.x), 0.0f, g_fMBBlurRadius);
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
float fPixelToSampleUnitsScale = (float) iMaxMotionBlurSampleCount / max(g_fMBBlurRadius, FLT_EPSILON5);
float fDepthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
float fSampleStepPixels = g_fMBBlurRadius / max((float) iMaxMotionBlurSampleCount, 1.0f);
[loop]
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
{
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
vDestUV.x = uv.x + (i * vSrcTexelSize.x) * fSampleStepPixels;
vDestUV.y = uv.y;
// vColor += g_fWeights_32[i + 15] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
//}
// [UVTest]
if (false == IsValidUV(vDestUV))
{ // UV밖에서 샘플링 해오려 하면 스킵
continue;
}
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y * g_fFar;
vSampledVelocityUV = g_VelocityTexture.Sample(PointSampler, vDestUV).xy;
vSampledVelocityPixels = vSampledVelocityUV * g_vResolution.xy;
fSampleSpreadLength = clamp(abs(vSampledVelocityPixels.x), 0.0f, g_fMBBlurRadius);
// [Sample]
float fWeightCalculated = SampleWeight(fCenterDepth, fSampledDepth, float(abs(i)), fCenterSpreadLength, fSampleSpreadLength, fPixelToSampleUnitsScale, fDepthScale);
if (fWeightCalculated <= 0.0f)
{
continue;
}
vSampledColor = g_ColorTexture.Sample(ClampLinearSampler, vDestUV);
vSumColor += vSampledColor * fWeightCalculated;
vSumVelocity += vSampledVelocityUV * fWeightCalculated;
fWeight += fWeightCalculated;
}
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
Out.vColor = float4(vBlurColor.rgb, fCoverage);
//Out.vColor = vBlurColor;
Out.vVelocity = vBlurVelocity;
return Out;
}
PS_OUT_VELOCITYBLUR PS_MOTIONBLURY(PS_IN In)
{
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
float2 vSumVelocity = float2(0.f, 0.f);
float4 vSumColor = float4(0.f, 0.f, 0.f, 0.f);
float4 vSampledColor = float4(0.f, 0.f, 0.f, 0.f);
float fSampledDepth = 1.f;
float fWeight = 0.f;
float2 vSampledVelocityPixels;
float2 vSampledVelocityUV;
float2 vDestUV;
float fSampleSpreadLength;
float2 uv = In.vTexcoord;
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y * g_fFar; // 해당 셀의 깊이
float2 vCenterVelocityUV = g_VelocityTexture.Sample(PointSampler, uv).xy;
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.y), 0.0f, g_fMBBlurRadius);
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
float fPixelToSampleUnitsScale = (float) iMaxMotionBlurSampleCount / max(g_fMBBlurRadius, FLT_EPSILON5);
float fDepthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
float fSampleStepPixels = g_fMBBlurRadius / max((float) iMaxMotionBlurSampleCount, 1.0f);
[loop]
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
{
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
vDestUV.x = uv.x;
vDestUV.y = uv.y + (i * vSrcTexelSize.y) * fSampleStepPixels;
// [UVTest]
if (false == IsValidUV(vDestUV))
{ // UV밖에서 샘플링 해오려 하면 스킵
continue;
}
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y * g_fFar;
vSampledVelocityUV = g_VelocityTexture.Sample(PointSampler, vDestUV).xy;
vSampledVelocityPixels = vSampledVelocityUV * g_vResolution.xy;
fSampleSpreadLength = clamp(abs(vSampledVelocityPixels.y), 0.0f, g_fMBBlurRadius);
// [Sample]
float fWeightCalculated = SampleWeight(fCenterDepth, fSampledDepth, float(abs(i)), fCenterSpreadLength, fSampleSpreadLength, fPixelToSampleUnitsScale, fDepthScale);
if (fWeightCalculated <= 0.0f)
{
continue;
}
vSampledColor = g_ColorTexture.Sample(ClampLinearSampler, vDestUV);
vSumColor += vSampledColor * fWeightCalculated;
vSumVelocity += vSampledVelocityUV * fWeightCalculated;
fWeight += fWeightCalculated;
}
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
Out.vColor = float4(vBlurColor.rgb, fCoverage);
//Out.vColor = vBlurColor;
Out.vVelocity = vBlurVelocity;
return Out;
}
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
@@ -815,13 +934,13 @@ PS_OUT_FLT4_SINGLE PS_MAIN_DOWNSAMPLE(PS_IN In)
{
PS_OUT_FLT4_SINGLE Out;
float2 uv = In.vTexcoord;
float fMask = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0).a;
float fSrcAlpha = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0).a;
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
float3 vColor = (0.f, 0.f, 0.f);
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
Out.vFirstTarget = float4(vColor, 1.f);
Out.vFirstTarget = float4(vColor, fSrcAlpha);
return Out;
}
@@ -1383,14 +1502,14 @@ technique11 DefaultTechnique
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
}
pass MotionBlurPass // 18
pass MotionBlurXPass // 18
{
SetRasterizerState(RS_Default);
SetDepthStencilState(DSS_None, 0);
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
VertexShader = compile vs_5_0 VS_MAIN();
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MOTIONBLUR_X();
PixelShader = compile ps_5_0 PS_MOTIONBLURX();
}
pass DownSamplePass // 19
{
@@ -1401,5 +1520,13 @@ technique11 DefaultTechnique
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
}
pass MotionBlurYPass // 20
{
SetRasterizerState(RS_Default);
SetDepthStencilState(DSS_None, 0);
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
VertexShader = compile vs_5_0 VS_MAIN();
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MOTIONBLURY();
}
}
@@ -434,7 +434,7 @@ PS_OUT PS_GLASS_CUBE(PS_IN In)
Out.vNormal = float4(In.vNormal * 0.5f + 0.5f, 0.f);
Out.vDepth = float4(In.vProjPos.z / In.vProjPos.w, In.vProjPos.w / g_fFar, 15.f / 27.f, 1.f);
Out.vSurface = vSurface;
Out.vVelocityUV = CalcVelocityUV(In.vProjPos, In.vPrevProjPos);
Out.vVelocityUV = CalcVelocityUV(In.vProjPos, In.vPrevProjPos) * 0.5f + 0.5f;
return Out;
}
@@ -480,30 +480,30 @@ float2 CalcVelocityUV(float4 vCurrentProjPos, float4 vPreviousProjPos)
currentUV.y *= -1.f;
previousUV.y *= -1.f;
return currentUV - previousUV;
return (currentUV - previousUV) * 0.5f + 0.5f;
}
float3 DownSampleFast(Texture2D SrcTexture2D, float2 vCenterTexcoord, float2 vSrcTexelSize, float2 vResolution)
{
float2 uv = float2(0.f, 0.f);
float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
float3 vCenterColor = SrcTexture2D.SampleLevel(BorderZeroSampler, vCenterTexcoord, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, -1.0);
float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fLTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, -1.0);
float3 fTColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, -1.0);
float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fRTColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, 0.0);
float3 fLColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(1.0, 0.0);
float3 fRColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(-1.0, +1.0);
float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fLBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
uv = vCenterTexcoord + vSrcTexelSize * float2(0.0, 1.0);
float3 fBColor = SrcTexture2D.SampleLevel(BorderZeroSampler, uv, 0);
uv = vCenterTexcoord + vSrcTexelSize * float2(+1.0, +1.0);
float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroLinearSampler);
float3 fRBColor = BilinearFetches(vResolution, SrcTexture2D, uv, BorderZeroSampler);
return vCenterColor * 0.25f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.0625f + (fTColor + fLColor + fRColor + fBColor) * 0.125f;
}
@@ -27,6 +27,13 @@ sampler ClampSampler = sampler_state
AddressV = clamp;
};
sampler ClampLinearSampler = sampler_state
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = clamp;
AddressV = clamp;
};
sampler MirrorSampler = sampler_state
{
Filter = MIN_MAG_MIP_LINEAR;
@@ -75,8 +75,9 @@ Texture2D g_ColorTexture;
Texture2D g_VelocityTexture;
int g_iMBSampleCount;
int g_fMBBlurRadius;
float g_iMBType;
float g_fMBBlurRadius;
int g_iMBType;
float g_fMBSampleBias;
vector g_vLightDiffuse;
vector g_vLightAmbient;
@@ -147,6 +148,7 @@ struct VS_OUT
struct PS_OUT_VELOCITYBLUR
{
float4 vColor : SV_TARGET0;
float2 vVelocity : SV_TARGET1;
};
VS_OUT VS_MAIN(VS_IN In)
{
@@ -227,25 +229,142 @@ struct PS_OUT_SSAO_BLUR
// g_ColorTexture;
// g_DepthTexture;
// g_VelocityTexture;
// g_DiffuseTexture;
// g_fFar
// g_fMBSampleBias
// g_fMBBlurRadius
// g_iMBType
// g_iMBSampleCount
PS_OUT_VELOCITYBLUR PS_MOTIONBLUR_X(PS_IN In)
PS_OUT_VELOCITYBLUR PS_MOTIONBLURX(PS_IN In)
{
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR)0;
//float2 uv = In.vTexcoord;
//float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
//float3 vColor = (0.f, 0.f, 0.f);
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
float2 vSumVelocity = float2(0.f, 0.f);
float4 vSumColor = float4(0.f, 0.f, 0.f, 0.f);
float4 vSampledColor = float4(0.f, 0.f, 0.f, 0.f);
float fSampledDepth = 1.f;
float fWeight = 0.f;
float2 vSampledVelocityUV;
float2 vSampledVelocityPixels;
float2 vDestUV;
float fSampleSpreadLength;
//for (int i = -g_iMBSampleCount; i < g_iMBSampleCount; ++i)
//{
// vTexcoord.x = In.vTexcoord.x + (float) i / g_vResolution.x;
// vTexcoord.y = In.vTexcoord.y;
float2 uv = In.vTexcoord;
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y * g_fFar; // 해당 셀의 깊이
float2 vCenterVelocityUV = g_VelocityTexture.Sample(PointSampler, uv).xy;
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.x), 0.0f, g_fMBBlurRadius);
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
float fPixelToSampleUnitsScale = (float) iMaxMotionBlurSampleCount / max(g_fMBBlurRadius, FLT_EPSILON5);
float fDepthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
float fSampleStepPixels = g_fMBBlurRadius / max((float) iMaxMotionBlurSampleCount, 1.0f);
[loop]
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
{
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
vDestUV.x = uv.x + (i * vSrcTexelSize.x) * fSampleStepPixels;
vDestUV.y = uv.y;
// vColor += g_fWeights_32[i + 15] * g_BlurTexture.Sample(ClampSampler, vTexcoord);
//}
// [UVTest]
if (false == IsValidUV(vDestUV))
{ // UV밖에서 샘플링 해오려 하면 스킵
continue;
}
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y * g_fFar;
vSampledVelocityUV = g_VelocityTexture.Sample(PointSampler, vDestUV).xy;
vSampledVelocityPixels = vSampledVelocityUV * g_vResolution.xy;
fSampleSpreadLength = clamp(abs(vSampledVelocityPixels.x), 0.0f, g_fMBBlurRadius);
// [Sample]
float fWeightCalculated = SampleWeight(fCenterDepth, fSampledDepth, float(abs(i)), fCenterSpreadLength, fSampleSpreadLength, fPixelToSampleUnitsScale, fDepthScale);
if (fWeightCalculated <= 0.0f)
{
continue;
}
vSampledColor = g_ColorTexture.Sample(ClampLinearSampler, vDestUV);
vSumColor += vSampledColor * fWeightCalculated;
vSumVelocity += vSampledVelocityUV * fWeightCalculated;
fWeight += fWeightCalculated;
}
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
Out.vColor = float4(vBlurColor.rgb, fCoverage);
//Out.vColor = vBlurColor;
Out.vVelocity = vBlurVelocity;
return Out;
}
PS_OUT_VELOCITYBLUR PS_MOTIONBLURY(PS_IN In)
{
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
float2 vSumVelocity = float2(0.f, 0.f);
float4 vSumColor = float4(0.f, 0.f, 0.f, 0.f);
float4 vSampledColor = float4(0.f, 0.f, 0.f, 0.f);
float fSampledDepth = 1.f;
float fWeight = 0.f;
float2 vSampledVelocityPixels;
float2 vSampledVelocityUV;
float2 vDestUV;
float fSampleSpreadLength;
float2 uv = In.vTexcoord;
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y * g_fFar; // 해당 셀의 깊이
float2 vCenterVelocityUV = g_VelocityTexture.Sample(PointSampler, uv).xy;
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.y), 0.0f, g_fMBBlurRadius);
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
float fPixelToSampleUnitsScale = (float) iMaxMotionBlurSampleCount / max(g_fMBBlurRadius, FLT_EPSILON5);
float fDepthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
float fSampleStepPixels = g_fMBBlurRadius / max((float) iMaxMotionBlurSampleCount, 1.0f);
[loop]
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
{
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
vDestUV.x = uv.x;
vDestUV.y = uv.y + (i * vSrcTexelSize.y) * fSampleStepPixels;
// [UVTest]
if (false == IsValidUV(vDestUV))
{ // UV밖에서 샘플링 해오려 하면 스킵
continue;
}
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y * g_fFar;
vSampledVelocityUV = g_VelocityTexture.Sample(PointSampler, vDestUV).xy;
vSampledVelocityPixels = vSampledVelocityUV * g_vResolution.xy;
fSampleSpreadLength = clamp(abs(vSampledVelocityPixels.y), 0.0f, g_fMBBlurRadius);
// [Sample]
float fWeightCalculated = SampleWeight(fCenterDepth, fSampledDepth, float(abs(i)), fCenterSpreadLength, fSampleSpreadLength, fPixelToSampleUnitsScale, fDepthScale);
if (fWeightCalculated <= 0.0f)
{
continue;
}
vSampledColor = g_ColorTexture.Sample(ClampLinearSampler, vDestUV);
vSumColor += vSampledColor * fWeightCalculated;
vSumVelocity += vSampledVelocityUV * fWeightCalculated;
fWeight += fWeightCalculated;
}
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
Out.vColor = float4(vBlurColor.rgb, fCoverage);
//Out.vColor = vBlurColor;
Out.vVelocity = vBlurVelocity;
return Out;
}
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
@@ -815,13 +934,13 @@ PS_OUT_FLT4_SINGLE PS_MAIN_DOWNSAMPLE(PS_IN In)
{
PS_OUT_FLT4_SINGLE Out;
float2 uv = In.vTexcoord;
float fMask = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0).a;
float fSrcAlpha = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0).a;
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
float3 vColor = (0.f, 0.f, 0.f);
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
Out.vFirstTarget = float4(vColor, 1.f);
Out.vFirstTarget = float4(vColor, fSrcAlpha);
return Out;
}
@@ -1383,14 +1502,14 @@ technique11 DefaultTechnique
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
}
pass MotionBlurPass // 18
pass MotionBlurXPass // 18
{
SetRasterizerState(RS_Default);
SetDepthStencilState(DSS_None, 0);
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
VertexShader = compile vs_5_0 VS_MAIN();
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MOTIONBLUR_X();
PixelShader = compile ps_5_0 PS_MOTIONBLURX();
}
pass DownSamplePass // 19
{
@@ -1401,5 +1520,13 @@ technique11 DefaultTechnique
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
}
pass MotionBlurYPass // 20
{
SetRasterizerState(RS_Default);
SetDepthStencilState(DSS_None, 0);
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
VertexShader = compile vs_5_0 VS_MAIN();
GeometryShader = NULL;
PixelShader = compile ps_5_0 PS_MOTIONBLURY();
}
}
@@ -859,13 +859,17 @@ HRESULT CGameInstance::Bind_RenderTarget(const _wstring& strTargetTag, CShader*
return m_pRenderTarget_Manager->Bind_RenderTarget(strTargetTag, pShader, pConstantName);
}
HRESULT CGameInstance::Copy_RenderTargetTo(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D)
HRESULT CGameInstance::Copy_RenderTargetTo(const _wstring& strSrcTag, ID3D11Texture2D* pDst2D)
{
return m_pRenderTarget_Manager->Copy_RenderTargetTo(strTargetTag, pTexture2D);
return m_pRenderTarget_Manager->Copy_RenderTargetTo(strSrcTag, pDst2D);
}
HRESULT CGameInstance::Copy_RenderTargetFrom(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D)
HRESULT CGameInstance::Copy_RenderTargetFrom(const _wstring& strDstTag, ID3D11Texture2D* pSrc2D)
{
return m_pRenderTarget_Manager->Copy_RenderTargetFrom(strTargetTag, pTexture2D);
return m_pRenderTarget_Manager->Copy_RenderTargetFrom(strDstTag, pSrc2D);
}
HRESULT CGameInstance::Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag)
{
return m_pRenderTarget_Manager->Copy_RenderTargetAToB(strATag, strBTag);
}
HRESULT CGameInstance::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass)
{
@@ -883,6 +887,10 @@ HRESULT CGameInstance::Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTar
{
return m_pRenderTarget_Manager->Bind_CS_RenderTarget(iIndex, strTargetTag);
}
_float2 CGameInstance::Get_RenderTargetSize(const _wstring& wstrTargetKey)
{
return m_pRenderTarget_Manager->Get_RenderTargetSize(wstrTargetKey);
}
#ifdef _DEBUG
void CGameInstance::RenderTarget_Debuger()
{
@@ -12,11 +12,12 @@ CRenderTarget::CRenderTarget(ID3D11Device* pDevice, ID3D11DeviceContext* pContex
SAFE_ADDREF(m_pContext);
}
HRESULT CRenderTarget::Initialize(_uint iSizeX, _uint iSizeY, DXGI_FORMAT ePixelFormat, const _float4& vClearColor)
{
D3D11_TEXTURE2D_DESC TextureDesc{};
m_vTargetSize.x = (_float)iSizeX;
m_vTargetSize.y = (_float)iSizeY;
TextureDesc.Width = iSizeX;
TextureDesc.Height = iSizeY;
TextureDesc.MipLevels = 1;
@@ -63,7 +64,6 @@ HRESULT CRenderTarget::Bind_ShaderResource(CShader* pShader, const _char* pConst
return S_OK;
}
void CRenderTarget::Clear()
{
m_pContext->ClearRenderTargetView(m_pRTV, reinterpret_cast<_float*>(&m_vClearColor));
@@ -73,10 +73,19 @@ void CRenderTarget::Copy_ResourceTo(ID3D11Texture2D* pTexture2D)
{
m_pContext->CopyResource(pTexture2D, m_pTexture2D);
}
void CRenderTarget::Copy_ResourceTo(const CRenderTarget& Target)
{
m_pContext->CopyResource(Target.m_pTexture2D, m_pTexture2D);
}
void CRenderTarget::Copy_ResourceFrom(ID3D11Texture2D* pTexture2D)
{
m_pContext->CopyResource(m_pTexture2D, pTexture2D);
}
void CRenderTarget::Copy_ResourceFrom(const CRenderTarget& Target)
{
m_pContext->CopyResource(m_pTexture2D, Target.m_pTexture2D);
}
void CRenderTarget::Get_TextureDesc(D3D11_TEXTURE2D_DESC& Desc)
{
m_pTexture2D->GetDesc(&Desc);
@@ -175,26 +175,42 @@ HRESULT CRenderTarget_Manager::Begin_MRT_NO_DepthStencil(const _wstring& strMRTT
return S_OK;
}
HRESULT CRenderTarget_Manager::Copy_RenderTargetTo(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D)
HRESULT CRenderTarget_Manager::Copy_RenderTargetTo(const _wstring& strSrcTag, ID3D11Texture2D* pDst2D)
{
CRenderTarget* pRenderTarget = Find_RenderTarget(strTargetTag);
CRenderTarget* pRenderTarget = Find_RenderTarget(strSrcTag);
if (nullptr == pRenderTarget) {
return E_FAIL;
}
pRenderTarget->Copy_ResourceTo(pTexture2D);
pRenderTarget->Copy_ResourceTo(pDst2D);
return S_OK;
}
HRESULT CRenderTarget_Manager::Copy_RenderTargetFrom(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D)
HRESULT CRenderTarget_Manager::Copy_RenderTargetFrom(const _wstring& strDstTag, ID3D11Texture2D* pSrc2D)
{
CRenderTarget* pRenderTarget = Find_RenderTarget(strTargetTag);
CRenderTarget* pRenderTarget = Find_RenderTarget(strDstTag);
if (nullptr == pRenderTarget) {
return E_FAIL;
}
pRenderTarget->Copy_ResourceFrom(pTexture2D);
pRenderTarget->Copy_ResourceFrom(pSrc2D);
return S_OK;
}
HRESULT CRenderTarget_Manager::Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag)
{
CRenderTarget* pTargetA = Find_RenderTarget(strATag);
if (nullptr == pTargetA) {
return E_FAIL;
}
CRenderTarget* pTargetB = Find_RenderTarget(strBTag);
if (nullptr == pTargetB) {
return E_FAIL;
}
pTargetA->Copy_ResourceTo(*pTargetB);
return S_OK;
}
@@ -469,6 +485,16 @@ HRESULT CRenderTarget_Manager::Finish_RenderTarget(CVIBuffer_Rect* pVIBuffer, CS
return S_OK;
}
_float2 CRenderTarget_Manager::Get_RenderTargetSize(const _wstring& wstrTargetKey)
{
CRenderTarget* pRenderTarget = Find_RenderTarget(wstrTargetKey);
if (nullptr == pRenderTarget) {
return _float2();
}
return pRenderTarget->Get_TargetSize();
}
HRESULT CRenderTarget_Manager::End_MRT()
{
ID3D11RenderTargetView* pRenderTargets[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = { m_pBackBufferRTV };
+99 -37
View File
@@ -10,6 +10,9 @@ void CRenderer::Render()
D3D11_VIEWPORT vp = {};
m_pContext->RSGetViewports(&iNumViewPort, &vp);
_float2 vResolution = { vp.Width, vp.Height };
if (FAILED(m_pShader->Bind_RawValue("g_vResolution", &vResolution, sizeof(_float2)))) {
assert(false);
}
Render_Priority();
Render_Shadow();
@@ -824,45 +827,104 @@ void CRenderer::Render_PostProcessing()
{
/* POSTPROCESSING */
COMPUTE_TIMEDELTA("Timer_Render_PostProcessing");
//{
// ID3D11Texture2D* pBackBuffer = { nullptr };
// m_pGameInstance->Get_BackBufferPTR(&pBackBuffer);
// if (FAILED(m_pGameInstance->Copy_RenderTargetTo(TEXT("Target_AfterBlend"), pBackBuffer))) {
// assert(false);
// }
// m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_AfterBlend"), TEXT("Target_AfterBlend2x2"), SHADER_PASS_DEFERRED::DOWNSAMPLE);
{
ID3D11Texture2D* pBackBuffer = { nullptr };
m_pGameInstance->Get_BackBufferPTR(&pBackBuffer);
if (FAILED(m_pGameInstance->Copy_RenderTargetFrom(TEXT("Target_AfterBlend"), pBackBuffer))) {
assert(false);
}
SAFE_RELEASE(pBackBuffer);
m_pGameInstance->Copy_RenderTargetAToB(TEXT("Target_AfterBlend"), TEXT("Target_MotionBlur"));
}
/* MotionBlur */
D3D11_VIEWPORT vpOld = {};
_uint iVPOldNum = 1;
m_pContext->RSGetViewports(&iVPOldNum, &vpOld);
D3D11_VIEWPORT vpNew = vpOld;
_float2 vTaretSize = m_pGameInstance->Get_RenderTargetSize(TEXT("Target_MotionBlur"));
vpNew.Width = vTaretSize.x;
vpNew.Height = vTaretSize.y;
//if (FAILED(m_pShader->Bind_RawValue("g_vResolution", &vTaretSize, sizeof(_float2)))) {
// assert(false);
//}
///* MotionBlur */
//
//{ // Bind_Resorces
// m_pShader->Bind_Matrix("g_WorldMatrix", &m_ScreenWorldMatrix);
// m_pShader->Bind_Matrix("g_ViewMatrix", &m_ScreenViewMatrix);
// m_pShader->Bind_Matrix("g_ProjMatrix", &m_ScreenProjMatrix);
// m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float));
// m_pShader->Bind_RawValue("g_fMBBlurRadius", &m_fMBBlurRadius, sizeof(_float));
// m_pShader->Bind_RawValue("g_iMBSampleCount", &m_iMBSampleCount, sizeof(_int));
// m_pShader->Bind_RawValue("g_iMBType", &m_iMBType, sizeof(_int));
//}
//{
// // Bind_Targets
// if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_AfterBlend2x2"), m_pShader, "g_ColorTexture"))) {
// assert(false);
// return;
// }
// if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShader, "g_DepthTexture"))) {
// assert(false);
// return;
// }
// if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_VelocityMap"), m_pShader, "g_VelocityTexture"))) {
// assert(false);
// return;
// }
//}
//m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::MOTIONBLUR));
//m_pVIBuffer->Bind_Resources();
//m_pVIBuffer->Render();
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_MotionBlur_X")))) {
assert(false); return;
}
{ // Bind_Resorces
if (FAILED(m_pShader->Bind_Matrix("g_WorldMatrix", &m_ScreenWorldMatrix))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_Matrix("g_ViewMatrix", &m_ScreenViewMatrix))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_Matrix("g_ProjMatrix", &m_ScreenProjMatrix))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_RawValue("g_fMBBlurRadius", &m_fMBBlurRadius, sizeof(_float)))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_RawValue("g_fMBSampleBias", &m_fMBSampleBias, sizeof(_float)))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_RawValue("g_iMBSampleCount", &m_iMBSampleCount, sizeof(_int)))) {
assert(false); return;
}
if (FAILED(m_pShader->Bind_RawValue("g_iMBType", &m_iMBType, sizeof(_int)))) {
assert(false); return;
}
}
{
// Bind_Targets
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_AfterBlend"), m_pShader, "g_DiffuseTexture"))) {
assert(false);
return;
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_MotionBlur"), m_pShader, "g_ColorTexture"))) {
assert(false);
return;
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Depth"), m_pShader, "g_DepthTexture"))) {
assert(false);
return;
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_VelocityMap"), m_pShader, "g_VelocityTexture"))) {
assert(false);
return;
}
}
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::MOTIONBLURX));
m_pVIBuffer->Bind_Resources();
m_pVIBuffer->Render();
if (FAILED(m_pGameInstance->End_MRT())) {
return;
}
if (false == m_bMB) {
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_MotionBlur_Y")))) {
assert(false); return;
}
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_MotionBlurX"), m_pShader, "g_ColorTexture"))) {
assert(false);
return;
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_VelocityMapX"), m_pShader, "g_VelocityTexture"))) {
assert(false);
return;
}
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::MOTIONBLURY));
m_pVIBuffer->Bind_Resources();
m_pVIBuffer->Render();
if (false == m_bMB) {
if (FAILED(m_pGameInstance->End_MRT())) {
return;
}
}
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_Bloom")))) {
return;
}
@@ -1111,7 +1173,7 @@ void CRenderer::Render_Debug()
return;
}
/* 렌더타겟을 디버그로 직교투영을 통해 그려라. */
/* 렌더타겟을 디버그로 직교투영 */
if (FAILED(m_pGameInstance->Render_RenderTarget_Debug(m_pShader, m_pVIBuffer))) {
return;
}
@@ -269,11 +269,23 @@ HRESULT CRenderer::Initialize()
/* Target_AfterBlend */
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_AfterBlend"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0, 1.0f)))) {
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_AfterBlend_2x2"), (_uint)(Viewport.Width * 0.5f), (_uint)(Viewport.Height * 0.5f),
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0, 1.0f)))) {
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_MotionBlur"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_MotionBlurX"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_MotionBlurY"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_MotionBlur_UpSample"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
return E_FAIL;
}
@@ -353,6 +365,14 @@ HRESULT CRenderer::Initialize()
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMapX"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMapY"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_BeforeNormal"), (_uint)Viewport.Width, (_uint)Viewport.Height,
DXGI_FORMAT_R16G16B16A16_UNORM, _float4(0.0f, 0.f, 0.f, 0.f)))) {
return E_FAIL;
@@ -498,9 +518,21 @@ HRESULT CRenderer::Initialize()
return E_FAIL;
}
/* MRT_Distortion */
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur_X"), TEXT("Target_MotionBlurX")))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur_X"), TEXT("Target_VelocityMapX")))) {
return E_FAIL;
}
/* MRT_MotionBlur_Y */
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur_Y"), TEXT("Target_MotionBlurY")))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur_Y"), TEXT("Target_VelocityMapY")))) {
return E_FAIL;
}
}
m_pShader = (CShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, FX_DEFERRED, nullptr, nullptr);
@@ -639,6 +671,12 @@ void CRenderer::Describe_Entitiy()
GUI::SliderFloat("m_fExposure", &m_fExposure, 0.5f, 2.f, "%.3f");
GUI::EndChild();
}
if (GUI::CollapsingHeader("MotionBlurr")) {
GUI::Checkbox("m_bMB", &m_bMB);
GUI::SliderFloat("g_fMBSampleBias", &m_fMBSampleBias, -1.f, 1.f, "%.3f");
GUI::SliderFloat("g_fMBBlurRadius", &m_fMBBlurRadius, 0.1f, 16.f, "%.1f");
GUI::SliderInt("g_iMBSampleCount", &m_iMBSampleCount, 0, 28, "%d");
}
if (GUI::CollapsingHeader("End_Padding")) {
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ enum class SHADER_PASS_CELL { DEBUG, END };
enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT,
UPSAMPLE, BLOOM_BLURX, BLOOM_BLURY, EMBOSSING, BLOOM_ACCUM, BLOOM_FINISH, BLURX_ENVIRONMENT,
POSTCOMBINED, FOG, TONE_MAPPING, SSAO_OCCLUSION, SSAO_BLUR, MOTIONBLUR, DOWNSAMPLE,
POSTCOMBINED, FOG, TONE_MAPPING, SSAO_OCCLUSION, SSAO_BLUR, MOTIONBLURX, DOWNSAMPLE, MOTIONBLURY,
END };
enum class TEXTURE_MOUNT_SLOT0 { NOT_DEFINED, METALLIC, SPECULAR, HEIGHT, END };
+4 -2
View File
@@ -172,12 +172,14 @@ class ENGINE_DLL CGameInstance final : public CBase
HRESULT Begin_MRT_NO_DepthStencil(const _wstring& strMRTTag);
HRESULT End_MRT();
HRESULT Bind_RenderTarget(const _wstring& strTargetTag, class CShader* pShader, const _char* pConstantName);
HRESULT Copy_RenderTargetTo(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D);
HRESULT Copy_RenderTargetFrom(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D);
HRESULT Copy_RenderTargetTo(const _wstring& strSrcTag, ID3D11Texture2D* pDst2D);
HRESULT Copy_RenderTargetFrom(const _wstring& strDstTag, ID3D11Texture2D* pSrc2D);
HRESULT Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag);
HRESULT Accumulate_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass);
HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass);
HRESULT Finish_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass);
HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag);
_float2 Get_RenderTargetSize(const _wstring& wstrTargetKey);
#ifdef _DEBUG
void RenderTarget_Debuger();
HRESULT Render_RenderTarget_Debug(class CShader* pShader, class CVIBuffer_Rect* pVIBuffer);
+5 -2
View File
@@ -9,18 +9,20 @@ class CRenderTarget final : public CBase
private:
CRenderTarget(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual ~CRenderTarget() = default;
public:
ID3D11RenderTargetView* Get_RTV() const { return m_pRTV; }
ID3D11ShaderResourceView* Get_SRV() const { return m_pSRV; }
public:
HRESULT Initialize(_uint iSizeX, _uint iSizeY, DXGI_FORMAT ePixelFormat, const _float4& vClearColor);
HRESULT Bind_ShaderResource(class CShader* pShader, const _char* pConstantName);
void Clear();
void Copy_ResourceTo(ID3D11Texture2D* pTexture2D);
void Copy_ResourceTo(const CRenderTarget& Target);
void Copy_ResourceFrom(ID3D11Texture2D* pTexture2D);
void Copy_ResourceFrom(const CRenderTarget& Target);
void Get_TextureDesc(D3D11_TEXTURE2D_DESC& Desc);
ID3D11ShaderResourceView* Get_SRV() const { return m_pSRV; }
_float2 Get_TargetSize() { return m_vTargetSize; };
#ifdef _DEBUG
public:
@@ -43,6 +45,7 @@ class CRenderTarget final : public CBase
private:
_float4x4 m_WorldMatrix = {};
_point m_ptWindowSize = {};
_float2 m_vTargetSize = {};
_bool m_isDraw = { false };
#endif
@@ -18,8 +18,9 @@ class CRenderTarget_Manager final : public CBase
HRESULT Begin_MRT_NO_DepthStencil(const _wstring& strMRTTag);
HRESULT End_MRT();
HRESULT Bind_RenderTarget(const _wstring& strTargetTag, class CShader* pShader, const _char* pConstantName);
HRESULT Copy_RenderTargetTo(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D);
HRESULT Copy_RenderTargetFrom(const _wstring& strTargetTag, ID3D11Texture2D* pTexture2D);
HRESULT Copy_RenderTargetTo(const _wstring& strSrcTag, ID3D11Texture2D* pDst2D);
HRESULT Copy_RenderTargetFrom(const _wstring& strDstTag, ID3D11Texture2D* pSrc2D);
HRESULT Copy_RenderTargetAToB(const _wstring& strATag, const _wstring& strBTag);
HRESULT Bind_CS_RenderTarget(_uint iIndex, const _wstring& strTargetTag);
@@ -28,6 +29,7 @@ class CRenderTarget_Manager final : public CBase
// 랜더 타겟의 크기를 dest로 다시 맞춤
HRESULT Refit_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetInput, const _wstring& wstrRenderTargetOutput, SHADER_PASS_DEFERRED ePass);
HRESULT Finish_RenderTarget(class CVIBuffer_Rect* pVIBuffer, class CShader* pShader, const _wstring& wstrRenderTargetOriginal, const _wstring& wstrRenderTargetBloomed, SHADER_PASS_DEFERRED ePass);
_float2 Get_RenderTargetSize(const _wstring& wstrRenderTargetOriginal);
#ifdef _DEBUG
public:
@@ -38,8 +40,8 @@ class CRenderTarget_Manager final : public CBase
#ifdef _DEBUG
private:
_int m_iSizeX = { 200 };
_int m_iSizeY = { 200 };
_int m_iSizeX = { 16 * 14 };
_int m_iSizeY = { 9 * 14 };
#endif // _DEBUG
private:
+4 -2
View File
@@ -62,9 +62,11 @@ class CRenderer final : public CBase
/* TunningParam */
// MotionBlur
_float m_fMBBlurRadius = { 1.f };
_int m_iMBSampleCount = { 3 };
_float m_fMBBlurRadius = { 8.f };
_float m_fMBSampleBias = { 0.005f };
_int m_iMBSampleCount = { 14 };
_int m_iMBType = { 0 };
_bool m_bMB = { true };
// ToneMapping
_int m_iToneMappingType = { 2 };