[add] MB DownSAmpler
This commit is contained in:
@@ -17,6 +17,7 @@ float g_fCascadeSplitRatioFar;
|
|||||||
uint g_iMaxShadowWidth;
|
uint g_iMaxShadowWidth;
|
||||||
uint g_iMaxShadowHeight;
|
uint g_iMaxShadowHeight;
|
||||||
float2 g_vResolution;
|
float2 g_vResolution;
|
||||||
|
float2 g_vSrcResolution;
|
||||||
float4 g_vShadowBias;
|
float4 g_vShadowBias;
|
||||||
|
|
||||||
uint g_iBloomEmbossingPass;
|
uint g_iBloomEmbossingPass;
|
||||||
@@ -78,6 +79,7 @@ int g_iMBSampleCount;
|
|||||||
int g_iMBMaxSampleCount;
|
int g_iMBMaxSampleCount;
|
||||||
float g_fMBBlurRadius;
|
float g_fMBBlurRadius;
|
||||||
int g_iMBType;
|
int g_iMBType;
|
||||||
|
int g_iMBTileSize;
|
||||||
float g_fMBSampleBias;
|
float g_fMBSampleBias;
|
||||||
|
|
||||||
vector g_vLightDiffuse;
|
vector g_vLightDiffuse;
|
||||||
@@ -151,6 +153,10 @@ struct PS_OUT_VELOCITYBLUR
|
|||||||
float4 vColor : SV_TARGET0;
|
float4 vColor : SV_TARGET0;
|
||||||
float2 vVelocity : SV_TARGET1;
|
float2 vVelocity : SV_TARGET1;
|
||||||
};
|
};
|
||||||
|
struct PS_OUT_VELOCITYTILE
|
||||||
|
{
|
||||||
|
float2 vVelocity : SV_TARGET0;
|
||||||
|
};
|
||||||
VS_OUT VS_MAIN(VS_IN In)
|
VS_OUT VS_MAIN(VS_IN In)
|
||||||
{
|
{
|
||||||
VS_OUT Out;
|
VS_OUT Out;
|
||||||
@@ -237,151 +243,181 @@ struct PS_OUT_SSAO_BLUR
|
|||||||
// g_iMBSampleCount
|
// g_iMBSampleCount
|
||||||
// g_iMBMaxSampleCount
|
// g_iMBMaxSampleCount
|
||||||
// g_iMBType
|
// g_iMBType
|
||||||
PS_OUT_VELOCITYBLUR PS_MOTIONBLURX(PS_IN In)
|
PS_OUT_VELOCITYBLUR PS_MOTIONBLUR(PS_IN In)
|
||||||
{
|
{
|
||||||
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
|
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;
|
|
||||||
|
|
||||||
float2 uv = In.vTexcoord;
|
|
||||||
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y; // 해당 셀의 깊이
|
|
||||||
float2 vCenterVelocityUV = (g_VelocityTexture.Sample(PointSampler, uv).xy * 2.f - 1.f);
|
|
||||||
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, g_iMBMaxSampleCount); /* 최대 속도 */
|
|
||||||
|
|
||||||
float fPixelToSampleUnitsScale = (float) iMaxMotionBlurSampleCount / max(g_fMBBlurRadius, FLT_EPSILON5);
|
float2 centerUV = In.vTexcoord;
|
||||||
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;
|
|
||||||
|
|
||||||
// [UVTest]
|
|
||||||
if (false == IsValidUV(vDestUV))
|
|
||||||
{ // UV밖에서 샘플링 해오려 하면 스킵
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y;
|
|
||||||
vSampledVelocityUV = (g_VelocityTexture.Sample(PointSampler, vDestUV).xy * 2.f - 1.f);
|
|
||||||
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);
|
float4 centerColor = g_ColorTexture.Sample(ClampLinearSampler, centerUV);
|
||||||
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
|
float centerDepth = g_DepthTexture.Sample(PointSampler, centerUV).y;
|
||||||
|
|
||||||
//Out.vColor = float4(vBlurColor.rgb, fCoverage);
|
// encoded(0..1) -> signed(-1..1)
|
||||||
Out.vColor = vBlurColor;
|
float2 centerVelocitySignedUV = g_VelocityTexture.Sample(PointSampler, centerUV).xy * 2.0f - 1.0f;
|
||||||
Out.vVelocity = vBlurVelocity * 0.5f + 0.5f;
|
|
||||||
float2 vBlurVelocityPixels = vBlurVelocity * g_vResolution.xy;
|
// UV -> pixels
|
||||||
if (length(vBlurVelocityPixels) < 0.5f) // 0.5px 이하면 정지 취급
|
float2 centerVelocityPixels = centerVelocitySignedUV * g_vResolution.xy;
|
||||||
|
float centerSpeedPixels = length(centerVelocityPixels);
|
||||||
|
|
||||||
|
// **정지 데드존**
|
||||||
|
if (centerSpeedPixels < 0.5f)
|
||||||
{
|
{
|
||||||
Out.vColor = g_ColorTexture.Sample(ClampLinearSampler, uv);
|
Out.vColor = centerColor;
|
||||||
Out.vVelocity = float2(0.5f, 0.5f);
|
Out.vVelocity = float2(0.5f, 0.5f);
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// **방향(정규화)**
|
||||||
|
float2 velocityDirectionPixels = centerVelocityPixels / max(centerSpeedPixels, FLT_EPSILON5);
|
||||||
|
|
||||||
|
// **최대 블러 반경(픽셀)**
|
||||||
|
float blurRadiusPixels = min(centerSpeedPixels, g_fMBBlurRadius);
|
||||||
|
|
||||||
|
int maximumSampleCount = min(g_iMBSampleCount, g_iMBMaxSampleCount);
|
||||||
|
int tapRadius = min(maximumSampleCount, (int) ceil(blurRadiusPixels)); // 옵션: 속도에 따라 탭 줄이기
|
||||||
|
|
||||||
|
float sampleStepPixels = blurRadiusPixels / max((float) tapRadius, 1.0f);
|
||||||
|
|
||||||
|
// SpreadCompare용 스케일 (픽셀 -> 샘플단위)
|
||||||
|
float pixelToSampleUnitsScale = (float) tapRadius / max(blurRadiusPixels, FLT_EPSILON5);
|
||||||
|
|
||||||
|
float depthScale = 0.5f / max(g_fMBSampleBias, FLT_EPSILON5);
|
||||||
|
|
||||||
|
float4 weightedColorSum = float4(0, 0, 0, 0);
|
||||||
|
float2 weightedVelocitySum = float2(0, 0);
|
||||||
|
float weightSum = 0.0f;
|
||||||
|
|
||||||
|
// 픽셀 오프셋 -> UV 오프셋
|
||||||
|
float2 pixelToUV = 1.0f / g_vResolution.xy;
|
||||||
|
|
||||||
|
// center spread는 "반경"으로 잡는 편이 안정적
|
||||||
|
float centerSpreadLength = blurRadiusPixels;
|
||||||
|
|
||||||
|
[loop]
|
||||||
|
for (int i = -tapRadius; i <= tapRadius; ++i)
|
||||||
|
{
|
||||||
|
float offsetLengthSamples = (float) abs(i);
|
||||||
|
|
||||||
|
float2 offsetPixels = velocityDirectionPixels * ((float) i * sampleStepPixels);
|
||||||
|
float2 sampleUV = centerUV + offsetPixels * pixelToUV;
|
||||||
|
|
||||||
|
// Clamp 샘플러를 쓰면 굳이 IsValidUV가 필수는 아니지만, 남겨도 됩니다.
|
||||||
|
if (false == IsValidUV(sampleUV))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float sampleDepth = g_DepthTexture.Sample(PointSampler, sampleUV).y;
|
||||||
|
|
||||||
|
float2 sampleVelocitySignedUV = g_VelocityTexture.Sample(PointSampler, sampleUV).xy * 2.0f - 1.0f;
|
||||||
|
float2 sampleVelocityPixels = sampleVelocitySignedUV * g_vResolution.xy;
|
||||||
|
|
||||||
|
float sampleSpreadLength = clamp(length(sampleVelocityPixels), 0.0f, g_fMBBlurRadius);
|
||||||
|
|
||||||
|
float weightCalculated = SampleWeight(
|
||||||
|
centerDepth, sampleDepth,
|
||||||
|
offsetLengthSamples,
|
||||||
|
centerSpreadLength, sampleSpreadLength,
|
||||||
|
pixelToSampleUnitsScale,
|
||||||
|
depthScale
|
||||||
|
);
|
||||||
|
|
||||||
|
if (weightCalculated <= 0.0f)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float4 sampleColor = g_ColorTexture.Sample(ClampLinearSampler, sampleUV);
|
||||||
|
|
||||||
|
weightedColorSum += sampleColor * weightCalculated;
|
||||||
|
weightedVelocitySum += sampleVelocitySignedUV * weightCalculated;
|
||||||
|
weightSum += weightCalculated;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 blurColor = weightedColorSum / max(weightSum, FLT_EPSILON5);
|
||||||
|
float2 blurVelocitySignedUV = weightedVelocitySum / max(weightSum, FLT_EPSILON5);
|
||||||
|
|
||||||
|
Out.vColor = blurColor;
|
||||||
|
Out.vVelocity = blurVelocitySignedUV * 0.5f + 0.5f; // 다시 encode
|
||||||
|
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
PS_OUT_VELOCITYBLUR PS_MOTIONBLURY(PS_IN In)
|
PS_OUT_VELOCITYTILE PS_MOTIONBLUR_TILESAMPLE(PS_IN In)
|
||||||
{
|
{
|
||||||
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
|
PS_OUT_VELOCITYTILE Out = (PS_OUT_VELOCITYTILE) 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;
|
float2 uv = In.vTexcoord;
|
||||||
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y; // 해당 셀의 깊이
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float2 vCenterVelocityUV = (g_VelocityTexture.Sample(PointSampler, uv).xy * 2.f - 1.f);
|
|
||||||
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
|
int2 vTilePixelIndex = int2(uv * g_vResolution);
|
||||||
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.y), 0.0f, g_fMBBlurRadius);
|
vTilePixelIndex = clamp(vTilePixelIndex, int2(0, 0), int2(g_vResolution) - 1);
|
||||||
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
|
|
||||||
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
|
int2 vTileStartSourcePixel = vTilePixelIndex * g_iMBTileSize;
|
||||||
|
|
||||||
|
float2 vMaxVel = float2(0.5f, 0.5f);
|
||||||
|
float fMaxSpeed = 0.f;
|
||||||
|
float2 vSampleVel;
|
||||||
|
float2 vSampleUV;
|
||||||
|
float2 vSampleDiff;
|
||||||
|
float fSampleSpeed;
|
||||||
|
|
||||||
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]
|
[loop]
|
||||||
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
|
for (int iY = 0; iY < g_iMBTileSize; ++iY)
|
||||||
{
|
{
|
||||||
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
|
[loop]
|
||||||
vDestUV.x = uv.x;
|
for (int iX = 0; iX < g_iMBTileSize; ++iX)
|
||||||
vDestUV.y = uv.y + (i * vSrcTexelSize.y) * fSampleStepPixels;
|
{
|
||||||
|
int2 vSourcePixel = vTileStartSourcePixel + int2(iX, iY);
|
||||||
// [UVTest]
|
|
||||||
if (false == IsValidUV(vDestUV))
|
if (vSourcePixel.x < 0 || vSourcePixel.y < 0 || vSourcePixel.x >= (int) g_vSrcResolution.x || vSourcePixel.y >= (int) g_vSrcResolution.y)
|
||||||
{ // UV밖에서 샘플링 해오려 하면 스킵
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float2 vSourceUV = (float2(vSourcePixel) + 0.5f) * vSrcTexelSize;
|
||||||
|
|
||||||
|
vSampleVel = g_VelocityTexture.SampleLevel(ClampSampler, vSourceUV, 0).xy;
|
||||||
|
|
||||||
|
vSampleUV = vSampleVel * 2.0f - 1.0f;
|
||||||
|
|
||||||
|
fSampleSpeed = length(vSampleUV * g_vSrcResolution);
|
||||||
|
|
||||||
|
if (fSampleSpeed > fMaxSpeed)
|
||||||
|
{
|
||||||
|
fMaxSpeed = fSampleSpeed;
|
||||||
|
vMaxVel = vSampleVel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y;
|
|
||||||
vSampledVelocityUV = (g_VelocityTexture.Sample(PointSampler, vDestUV).xy * 2.f - 1.f);
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Out.vVelocity = vMaxVel;
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
PS_OUT_VELOCITYTILE PS_MOTIONBLUR_TENTSAMPLE(PS_IN In)
|
||||||
|
{
|
||||||
|
PS_OUT_VELOCITYTILE Out = (PS_OUT_VELOCITYTILE) 0;
|
||||||
|
|
||||||
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
|
float2 uv = In.vTexcoord;
|
||||||
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
|
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
|
||||||
|
float2 vMaxVel = float2(0.5f, 0.5f);
|
||||||
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
|
float vMaxSpeed = 0.f;
|
||||||
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
|
float2 vSampleVel;
|
||||||
|
float2 vSampleUV;
|
||||||
//Out.vColor = float4(vBlurColor.rgb, fCoverage);
|
float2 vSampleDiff;
|
||||||
Out.vColor = vBlurColor;
|
float fSampleSpeed;
|
||||||
Out.vVelocity = vBlurVelocity * 0.5f + 0.5f;
|
|
||||||
float2 vBlurVelocityPixels = vBlurVelocity * g_vResolution.xy;
|
for (int i = -1; i <= 1; ++i)
|
||||||
if (length(vBlurVelocityPixels) < 0.5f) // 0.5px 이하면 정지 취급
|
|
||||||
{
|
{
|
||||||
Out.vColor = g_ColorTexture.Sample(ClampLinearSampler, uv);
|
for (int j = -1; j <= 1; ++j)
|
||||||
Out.vVelocity = float2(0.5f, 0.5f);
|
{
|
||||||
return Out;
|
vSampleUV.x = uv.x + vSrcTexelSize.x * i;
|
||||||
|
vSampleUV.y = uv.y + vSrcTexelSize.y * j;
|
||||||
|
vSampleVel = g_VelocityTexture.Sample(ClampSampler, vSampleUV);
|
||||||
|
vSampleDiff = vSampleVel *2.f - 1.f;
|
||||||
|
fSampleSpeed = length(vSampleDiff * g_vResolution * g_iMBTileSize);
|
||||||
|
if (fSampleSpeed > vMaxSpeed) {
|
||||||
|
vMaxSpeed = fSampleSpeed;
|
||||||
|
vMaxVel = vSampleVel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Out.vVelocity = vMaxVel;
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||||
@@ -931,10 +967,10 @@ PS_OUT_FLT4_SINGLE PS_MAIN_EMBOSS(PS_IN In)
|
|||||||
PS_OUT_FLT4_SINGLE Out;
|
PS_OUT_FLT4_SINGLE Out;
|
||||||
float2 uv = In.vTexcoord;
|
float2 uv = In.vTexcoord;
|
||||||
float fSrcAlpha = g_DiffuseTexture.Sample(PointSampler, uv).a;
|
float fSrcAlpha = g_DiffuseTexture.Sample(PointSampler, uv).a;
|
||||||
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float3 vColor = (0.f, 0.f, 0.f);
|
float3 vColor = (0.f, 0.f, 0.f);
|
||||||
|
|
||||||
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
|
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vSrcResolution);
|
||||||
|
|
||||||
float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f));
|
float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f));
|
||||||
fIntensity = max(FLT_EPSILON3, fIntensity);
|
fIntensity = max(FLT_EPSILON3, fIntensity);
|
||||||
@@ -952,10 +988,10 @@ PS_OUT_FLT4_SINGLE PS_MAIN_DOWNSAMPLE(PS_IN In)
|
|||||||
PS_OUT_FLT4_SINGLE Out;
|
PS_OUT_FLT4_SINGLE Out;
|
||||||
float2 uv = In.vTexcoord;
|
float2 uv = In.vTexcoord;
|
||||||
float fSrcAlpha = 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);
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float3 vColor = (0.f, 0.f, 0.f);
|
float3 vColor = (0.f, 0.f, 0.f);
|
||||||
|
|
||||||
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
|
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vSrcResolution);
|
||||||
|
|
||||||
Out.vFirstTarget = float4(vColor, fSrcAlpha);
|
Out.vFirstTarget = float4(vColor, fSrcAlpha);
|
||||||
|
|
||||||
@@ -1519,14 +1555,14 @@ technique11 DefaultTechnique
|
|||||||
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
|
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
|
||||||
}
|
}
|
||||||
|
|
||||||
pass MotionBlurXPass // 18
|
pass MotionBlurPass // 18
|
||||||
{
|
{
|
||||||
SetRasterizerState(RS_Default);
|
SetRasterizerState(RS_Default);
|
||||||
SetDepthStencilState(DSS_None, 0);
|
SetDepthStencilState(DSS_None, 0);
|
||||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||||
VertexShader = compile vs_5_0 VS_MAIN();
|
VertexShader = compile vs_5_0 VS_MAIN();
|
||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MOTIONBLURX();
|
PixelShader = compile ps_5_0 PS_MOTIONBLUR();
|
||||||
}
|
}
|
||||||
pass DownSamplePass // 19
|
pass DownSamplePass // 19
|
||||||
{
|
{
|
||||||
@@ -1537,13 +1573,22 @@ technique11 DefaultTechnique
|
|||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
|
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
|
||||||
}
|
}
|
||||||
pass MotionBlurYPass // 20
|
pass MotionBlurTileSamplePass // 20
|
||||||
{
|
{
|
||||||
SetRasterizerState(RS_Default);
|
SetRasterizerState(RS_Default);
|
||||||
SetDepthStencilState(DSS_None, 0);
|
SetDepthStencilState(DSS_None, 0);
|
||||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||||
VertexShader = compile vs_5_0 VS_MAIN();
|
VertexShader = compile vs_5_0 VS_MAIN();
|
||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MOTIONBLURY();
|
PixelShader = compile ps_5_0 PS_MOTIONBLUR_TILESAMPLE();
|
||||||
|
}
|
||||||
|
pass MotionBlurTentSamplePass // 21
|
||||||
|
{
|
||||||
|
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_TENTSAMPLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ float g_fCascadeSplitRatioFar;
|
|||||||
uint g_iMaxShadowWidth;
|
uint g_iMaxShadowWidth;
|
||||||
uint g_iMaxShadowHeight;
|
uint g_iMaxShadowHeight;
|
||||||
float2 g_vResolution;
|
float2 g_vResolution;
|
||||||
|
float2 g_vSrcResolution;
|
||||||
float4 g_vShadowBias;
|
float4 g_vShadowBias;
|
||||||
|
|
||||||
uint g_iBloomEmbossingPass;
|
uint g_iBloomEmbossingPass;
|
||||||
@@ -78,6 +79,7 @@ int g_iMBSampleCount;
|
|||||||
int g_iMBMaxSampleCount;
|
int g_iMBMaxSampleCount;
|
||||||
float g_fMBBlurRadius;
|
float g_fMBBlurRadius;
|
||||||
int g_iMBType;
|
int g_iMBType;
|
||||||
|
int g_iMBTileSize;
|
||||||
float g_fMBSampleBias;
|
float g_fMBSampleBias;
|
||||||
|
|
||||||
vector g_vLightDiffuse;
|
vector g_vLightDiffuse;
|
||||||
@@ -151,6 +153,10 @@ struct PS_OUT_VELOCITYBLUR
|
|||||||
float4 vColor : SV_TARGET0;
|
float4 vColor : SV_TARGET0;
|
||||||
float2 vVelocity : SV_TARGET1;
|
float2 vVelocity : SV_TARGET1;
|
||||||
};
|
};
|
||||||
|
struct PS_OUT_VELOCITYTILE
|
||||||
|
{
|
||||||
|
float2 vVelocity : SV_TARGET0;
|
||||||
|
};
|
||||||
VS_OUT VS_MAIN(VS_IN In)
|
VS_OUT VS_MAIN(VS_IN In)
|
||||||
{
|
{
|
||||||
VS_OUT Out;
|
VS_OUT Out;
|
||||||
@@ -237,7 +243,7 @@ struct PS_OUT_SSAO_BLUR
|
|||||||
// g_iMBSampleCount
|
// g_iMBSampleCount
|
||||||
// g_iMBMaxSampleCount
|
// g_iMBMaxSampleCount
|
||||||
// g_iMBType
|
// g_iMBType
|
||||||
PS_OUT_VELOCITYBLUR PS_MOTIONBLURX(PS_IN In)
|
PS_OUT_VELOCITYBLUR PS_MOTIONBLUR(PS_IN In)
|
||||||
{
|
{
|
||||||
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
|
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
|
||||||
float2 vSumVelocity = float2(0.f, 0.f);
|
float2 vSumVelocity = float2(0.f, 0.f);
|
||||||
@@ -311,77 +317,86 @@ PS_OUT_VELOCITYBLUR PS_MOTIONBLURX(PS_IN In)
|
|||||||
|
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
PS_OUT_VELOCITYBLUR PS_MOTIONBLURY(PS_IN In)
|
PS_OUT_VELOCITYTILE PS_MOTIONBLUR_TILESAMPLE(PS_IN In)
|
||||||
{
|
{
|
||||||
PS_OUT_VELOCITYBLUR Out = (PS_OUT_VELOCITYBLUR) 0;
|
PS_OUT_VELOCITYTILE Out = (PS_OUT_VELOCITYTILE) 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;
|
float2 uv = In.vTexcoord;
|
||||||
float fCenterDepth = g_DepthTexture.Sample(PointSampler, uv).y; // 해당 셀의 깊이
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float2 vCenterVelocityUV = (g_VelocityTexture.Sample(PointSampler, uv).xy * 2.f - 1.f);
|
|
||||||
float2 vCenterVelocityPixels = vCenterVelocityUV * g_vResolution.xy; // UV -> 픽셀
|
int2 vTilePixelIndex = int2(uv * g_vResolution);
|
||||||
float fCenterSpreadLength = clamp(abs(vCenterVelocityPixels.y), 0.0f, g_fMBBlurRadius);
|
vTilePixelIndex = clamp(vTilePixelIndex, int2(0, 0), int2(g_vResolution) - 1);
|
||||||
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y); // 소스 셀 사이즈 g_vResolution-> 현재는 colortexture 해상도
|
|
||||||
int iMaxMotionBlurSampleCount = min(g_iMBSampleCount, 7); /* 최대 속도 */
|
int2 vTileStartSourcePixel = vTilePixelIndex * g_iMBTileSize;
|
||||||
|
|
||||||
|
float2 vMaxVel = float2(0.5f, 0.5f);
|
||||||
|
float fMaxSpeed = 0.f;
|
||||||
|
float2 vSampleVel;
|
||||||
|
float2 vSampleUV;
|
||||||
|
float2 vSampleDiff;
|
||||||
|
float fSampleSpeed;
|
||||||
|
|
||||||
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]
|
[loop]
|
||||||
for (int i = -iMaxMotionBlurSampleCount; i <= iMaxMotionBlurSampleCount; ++i)
|
for (int iY = 0; iY < g_iMBTileSize; ++iY)
|
||||||
{
|
{
|
||||||
// 대상이 되는 셀은 센터uv + 임의값*셀사이즈*갯수
|
[loop]
|
||||||
vDestUV.x = uv.x;
|
for (int iX = 0; iX < g_iMBTileSize; ++iX)
|
||||||
vDestUV.y = uv.y + (i * vSrcTexelSize.y) * fSampleStepPixels;
|
{
|
||||||
|
int2 vSourcePixel = vTileStartSourcePixel + int2(iX, iY);
|
||||||
// [UVTest]
|
|
||||||
if (false == IsValidUV(vDestUV))
|
if (vSourcePixel.x < 0 || vSourcePixel.y < 0 || vSourcePixel.x >= (int) g_vSrcResolution.x || vSourcePixel.y >= (int) g_vSrcResolution.y)
|
||||||
{ // UV밖에서 샘플링 해오려 하면 스킵
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
float2 vSourceUV = (float2(vSourcePixel) + 0.5f) * vSrcTexelSize;
|
||||||
|
|
||||||
|
vSampleVel = g_VelocityTexture.SampleLevel(ClampSampler, vSourceUV, 0).xy;
|
||||||
|
|
||||||
|
vSampleUV = vSampleVel * 2.0f - 1.0f;
|
||||||
|
|
||||||
|
fSampleSpeed = length(vSampleUV * g_vSrcResolution);
|
||||||
|
|
||||||
|
if (fSampleSpeed > fMaxSpeed)
|
||||||
|
{
|
||||||
|
fMaxSpeed = fSampleSpeed;
|
||||||
|
vMaxVel = vSampleVel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fSampledDepth = g_DepthTexture.Sample(PointSampler, vDestUV).y;
|
|
||||||
vSampledVelocityUV = (g_VelocityTexture.Sample(PointSampler, vDestUV).xy * 2.f - 1.f);
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Out.vVelocity = vMaxVel;
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
PS_OUT_VELOCITYTILE PS_MOTIONBLUR_TENTSAMPLE(PS_IN In)
|
||||||
|
{
|
||||||
|
PS_OUT_VELOCITYTILE Out = (PS_OUT_VELOCITYTILE) 0;
|
||||||
|
|
||||||
float4 vBlurColor = vSumColor / max(fWeight, FLT_EPSILON5);
|
float2 uv = In.vTexcoord;
|
||||||
float2 vBlurVelocity = vSumVelocity / max(fWeight, FLT_EPSILON5);
|
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
|
||||||
|
float2 vMaxVel = float2(0.5f, 0.5f);
|
||||||
float fTapCount = (float) (2 * iMaxMotionBlurSampleCount + 1);
|
float vMaxSpeed = 0.f;
|
||||||
float fCoverage = saturate(fWeight / max(fTapCount, 1.0f));
|
float2 vSampleVel;
|
||||||
|
float2 vSampleUV;
|
||||||
//Out.vColor = float4(vBlurColor.rgb, fCoverage);
|
float2 vSampleDiff;
|
||||||
Out.vColor = vBlurColor;
|
float fSampleSpeed;
|
||||||
Out.vVelocity = vBlurVelocity * 0.5f + 0.5f;
|
|
||||||
float2 vBlurVelocityPixels = vBlurVelocity * g_vResolution.xy;
|
for (int i = -1; i <= 1; ++i)
|
||||||
if (length(vBlurVelocityPixels) < 0.5f) // 0.5px 이하면 정지 취급
|
|
||||||
{
|
{
|
||||||
Out.vColor = g_ColorTexture.Sample(ClampLinearSampler, uv);
|
for (int j = -1; j <= 1; ++j)
|
||||||
Out.vVelocity = float2(0.5f, 0.5f);
|
{
|
||||||
return Out;
|
vSampleUV.x = uv.x + vSrcTexelSize.x * i;
|
||||||
|
vSampleUV.y = uv.y + vSrcTexelSize.y * j;
|
||||||
|
vSampleVel = g_VelocityTexture.Sample(ClampSampler, vSampleUV);
|
||||||
|
vSampleDiff = vSampleVel *2.f - 1.f;
|
||||||
|
fSampleSpeed = length(vSampleDiff * g_vResolution * g_iMBTileSize);
|
||||||
|
if (fSampleSpeed > vMaxSpeed) {
|
||||||
|
vMaxSpeed = fSampleSpeed;
|
||||||
|
vMaxVel = vSampleVel;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Out.vVelocity = vMaxVel;
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
|
||||||
@@ -931,10 +946,10 @@ PS_OUT_FLT4_SINGLE PS_MAIN_EMBOSS(PS_IN In)
|
|||||||
PS_OUT_FLT4_SINGLE Out;
|
PS_OUT_FLT4_SINGLE Out;
|
||||||
float2 uv = In.vTexcoord;
|
float2 uv = In.vTexcoord;
|
||||||
float fSrcAlpha = g_DiffuseTexture.Sample(PointSampler, uv).a;
|
float fSrcAlpha = g_DiffuseTexture.Sample(PointSampler, uv).a;
|
||||||
float2 vSrcTexelSize = float2(1.f / g_vResolution.x, 1.f / g_vResolution.y);
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float3 vColor = (0.f, 0.f, 0.f);
|
float3 vColor = (0.f, 0.f, 0.f);
|
||||||
|
|
||||||
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
|
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vSrcResolution);
|
||||||
|
|
||||||
float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f));
|
float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f));
|
||||||
fIntensity = max(FLT_EPSILON3, fIntensity);
|
fIntensity = max(FLT_EPSILON3, fIntensity);
|
||||||
@@ -952,10 +967,10 @@ PS_OUT_FLT4_SINGLE PS_MAIN_DOWNSAMPLE(PS_IN In)
|
|||||||
PS_OUT_FLT4_SINGLE Out;
|
PS_OUT_FLT4_SINGLE Out;
|
||||||
float2 uv = In.vTexcoord;
|
float2 uv = In.vTexcoord;
|
||||||
float fSrcAlpha = 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);
|
float2 vSrcTexelSize = float2(1.f / g_vSrcResolution.x, 1.f / g_vSrcResolution.y);
|
||||||
float3 vColor = (0.f, 0.f, 0.f);
|
float3 vColor = (0.f, 0.f, 0.f);
|
||||||
|
|
||||||
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vResolution);
|
vColor = DownSampleFast(g_DiffuseTexture, In.vTexcoord, vSrcTexelSize, g_vSrcResolution);
|
||||||
|
|
||||||
Out.vFirstTarget = float4(vColor, fSrcAlpha);
|
Out.vFirstTarget = float4(vColor, fSrcAlpha);
|
||||||
|
|
||||||
@@ -1519,14 +1534,14 @@ technique11 DefaultTechnique
|
|||||||
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
|
PixelShader = compile ps_5_0 PS_SSAO_BLUR();
|
||||||
}
|
}
|
||||||
|
|
||||||
pass MotionBlurXPass // 18
|
pass MotionBlurPass // 18
|
||||||
{
|
{
|
||||||
SetRasterizerState(RS_Default);
|
SetRasterizerState(RS_Default);
|
||||||
SetDepthStencilState(DSS_None, 0);
|
SetDepthStencilState(DSS_None, 0);
|
||||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||||
VertexShader = compile vs_5_0 VS_MAIN();
|
VertexShader = compile vs_5_0 VS_MAIN();
|
||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MOTIONBLURX();
|
PixelShader = compile ps_5_0 PS_MOTIONBLUR();
|
||||||
}
|
}
|
||||||
pass DownSamplePass // 19
|
pass DownSamplePass // 19
|
||||||
{
|
{
|
||||||
@@ -1537,13 +1552,22 @@ technique11 DefaultTechnique
|
|||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
|
PixelShader = compile ps_5_0 PS_MAIN_DOWNSAMPLE();
|
||||||
}
|
}
|
||||||
pass MotionBlurYPass // 20
|
pass MotionBlurTileSamplePass // 20
|
||||||
{
|
{
|
||||||
SetRasterizerState(RS_Default);
|
SetRasterizerState(RS_Default);
|
||||||
SetDepthStencilState(DSS_None, 0);
|
SetDepthStencilState(DSS_None, 0);
|
||||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||||
VertexShader = compile vs_5_0 VS_MAIN();
|
VertexShader = compile vs_5_0 VS_MAIN();
|
||||||
GeometryShader = NULL;
|
GeometryShader = NULL;
|
||||||
PixelShader = compile ps_5_0 PS_MOTIONBLURY();
|
PixelShader = compile ps_5_0 PS_MOTIONBLUR_TILESAMPLE();
|
||||||
|
}
|
||||||
|
pass MotionBlurTentSamplePass // 21
|
||||||
|
{
|
||||||
|
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_TENTSAMPLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,6 +360,11 @@ HRESULT CRenderTarget_Manager::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CSh
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vResolution = { vp.Width, vp.Height };
|
||||||
|
if (FAILED(pShader->Bind_RawValue("g_vSrcResolution", &vResolution, sizeof(_float2)))) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
pOutput->Clear();
|
pOutput->Clear();
|
||||||
|
|
||||||
{ // Bind RTVs
|
{ // Bind RTVs
|
||||||
@@ -386,6 +391,12 @@ HRESULT CRenderTarget_Manager::Refit_RenderTarget(CVIBuffer_Rect* pVIBuffer, CSh
|
|||||||
case Engine::SHADER_PASS_DEFERRED::DOWNSAMPLE:
|
case Engine::SHADER_PASS_DEFERRED::DOWNSAMPLE:
|
||||||
pConstantName = "g_DiffuseTexture";
|
pConstantName = "g_DiffuseTexture";
|
||||||
break;
|
break;
|
||||||
|
case Engine::SHADER_PASS_DEFERRED::MOTIONBLURTENT:
|
||||||
|
pConstantName = "g_VelocityTexture";
|
||||||
|
break;
|
||||||
|
case Engine::SHADER_PASS_DEFERRED::MOTIONBLURTILE:
|
||||||
|
pConstantName = "g_VelocityTexture";
|
||||||
|
break;
|
||||||
case Engine::SHADER_PASS_DEFERRED::BLOOM_BLURY:
|
case Engine::SHADER_PASS_DEFERRED::BLOOM_BLURY:
|
||||||
pConstantName = "g_BlurXTexture";
|
pConstantName = "g_BlurXTexture";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -849,21 +849,15 @@ void CRenderer::Render_PostProcessing()
|
|||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
SAFE_RELEASE(pBackBuffer);
|
SAFE_RELEASE(pBackBuffer);
|
||||||
|
if (FAILED(m_pShader->Bind_RawValue("g_iMBTileSize", &m_iMBTileSize, sizeof(_int)))) {
|
||||||
|
assert(false); return;
|
||||||
|
}
|
||||||
m_pGameInstance->Copy_RenderTargetAToB(TEXT("Target_AfterBlend"), TEXT("Target_MotionBlur"));
|
m_pGameInstance->Copy_RenderTargetAToB(TEXT("Target_AfterBlend"), TEXT("Target_MotionBlur"));
|
||||||
|
m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_VelocityMap"), TEXT("Target_VelocityTile"), SHADER_PASS_DEFERRED::MOTIONBLURTILE);
|
||||||
|
m_pGameInstance->Refit_RenderTarget(m_pVIBuffer, m_pShader, TEXT("Target_VelocityTile"), TEXT("Target_VelocityTent"), SHADER_PASS_DEFERRED::MOTIONBLURTENT);
|
||||||
}
|
}
|
||||||
/* MotionBlur */
|
/* MotionBlur */
|
||||||
D3D11_VIEWPORT vpOld = {};
|
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_MotionBlur")))) {
|
||||||
_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);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_MotionBlur_X")))) {
|
|
||||||
assert(false); return;
|
assert(false); return;
|
||||||
}
|
}
|
||||||
{ // Bind_Resorces
|
{ // Bind_Resorces
|
||||||
@@ -914,35 +908,13 @@ void CRenderer::Render_PostProcessing()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::MOTIONBLURX));
|
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::MOTIONBLUR));
|
||||||
|
|
||||||
m_pVIBuffer->Bind_Resources();
|
m_pVIBuffer->Bind_Resources();
|
||||||
m_pVIBuffer->Render();
|
m_pVIBuffer->Render();
|
||||||
if (FAILED(m_pGameInstance->End_MRT())) {
|
if (FAILED(m_pGameInstance->End_MRT())) {
|
||||||
return;
|
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")))) {
|
if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_Bloom")))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,19 +281,6 @@ HRESULT CRenderer::Initialize()
|
|||||||
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
|
DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
|
||||||
return E_FAIL;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target_Color*/
|
/* Target_Color*/
|
||||||
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Color"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Color"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
||||||
DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
|
DXGI_FORMAT_R32G32B32A32_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) {
|
||||||
@@ -367,15 +354,15 @@ HRESULT CRenderer::Initialize()
|
|||||||
|
|
||||||
/* Target_VelocityMap */
|
/* Target_VelocityMap */
|
||||||
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMap"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMap"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
||||||
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
|
DXGI_FORMAT_R32G32_FLOAT, _float4(0.5f, 0.5f, 0.f, 0.f)))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMapX"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityTile"), (_uint)(Viewport.Width / (_float)m_iMBTileSize), (_uint)(Viewport.Height / (_float)m_iMBTileSize),
|
||||||
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
|
DXGI_FORMAT_R32G32_FLOAT, _float4(0.5f, 0.5f, 0.f, 0.f)))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityMapY"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_VelocityTent"), (_uint)(Viewport.Width / (_float)m_iMBTileSize), (_uint)(Viewport.Height / (_float)m_iMBTileSize),
|
||||||
DXGI_FORMAT_R32G32_FLOAT, _float4(0.0f, 0.f, 0.f, 0.f)))) {
|
DXGI_FORMAT_R32G32_FLOAT, _float4(0.5f, 0.5f, 0.f, 0.f)))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_BeforeNormal"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_BeforeNormal"), (_uint)Viewport.Width, (_uint)Viewport.Height,
|
||||||
@@ -523,19 +510,8 @@ HRESULT CRenderer::Initialize()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MRT_Distortion */
|
/* MRT_MotionBlur */
|
||||||
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur_X"), TEXT("Target_MotionBlurX")))) {
|
if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_MotionBlur"), TEXT("Target_MotionBlur")))) {
|
||||||
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;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ enum class SHADER_PASS_CELL { DEBUG, END };
|
|||||||
|
|
||||||
enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT,
|
enum class SHADER_PASS_DEFERRED { DEBUG, DIRECTIONAL, POINT, COMBINED, BLUR, SPOT,
|
||||||
UPSAMPLE, BLOOM_BLURX, BLOOM_BLURY, EMBOSSING, BLOOM_ACCUM, BLOOM_FINISH, BLURX_ENVIRONMENT,
|
UPSAMPLE, BLOOM_BLURX, BLOOM_BLURY, EMBOSSING, BLOOM_ACCUM, BLOOM_FINISH, BLURX_ENVIRONMENT,
|
||||||
POSTCOMBINED, FOG, TONE_MAPPING, SSAO_OCCLUSION, SSAO_BLUR, MOTIONBLURX, DOWNSAMPLE, MOTIONBLURY,
|
POSTCOMBINED, FOG, TONE_MAPPING, SSAO_OCCLUSION, SSAO_BLUR, MOTIONBLUR, DOWNSAMPLE, MOTIONBLURTILE, MOTIONBLURTENT,
|
||||||
END };
|
END };
|
||||||
|
|
||||||
enum class TEXTURE_MOUNT_SLOT0 { NOT_DEFINED, METALLIC, SPECULAR, HEIGHT, END };
|
enum class TEXTURE_MOUNT_SLOT0 { NOT_DEFINED, METALLIC, SPECULAR, HEIGHT, END };
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class CRenderer final : public CBase
|
|||||||
_float m_fMBSampleBias = { 0.005f };
|
_float m_fMBSampleBias = { 0.005f };
|
||||||
_int m_iMBMaxSampleCount = { 28 };
|
_int m_iMBMaxSampleCount = { 28 };
|
||||||
_int m_iMBSampleCount = { m_iMBMaxSampleCount };
|
_int m_iMBSampleCount = { m_iMBMaxSampleCount };
|
||||||
|
_int m_iMBTileSize = { 20 };
|
||||||
_int m_iMBType = { 0 };
|
_int m_iMBType = { 0 };
|
||||||
_bool m_bMB = { true };
|
_bool m_bMB = { true };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user