This commit is contained in:
GiJungSUk
2025-12-31 11:11:31 +09:00
parent f32de8c88c
commit 6f4aeebde8
7 changed files with 138 additions and 138 deletions
@@ -70,54 +70,70 @@ float2 Get_MovedUV(float2 vOriginalUV, float fDeltaU, float fDeltaV, uint iIndex
float2 vOffset = float2(iIndexU * fDeltaU, iIndexV * fDeltaV);
return vOriginalUV * vDelta + vOffset;
}
float2 UV_Cutting(float2 originalUV, float2 uvCuttingCountFloat, int currentFrameIndex)
float2 UV_Cutting(float2 vUV, float2 vUVCutting, int iCurrentFrame)
{
// (1) 칸 개수는 정수로 취급 (0 방지)
int uvCuttingCountX = max((int) uvCuttingCountFloat.x, 1);
int uvCuttingCountY = max((int) uvCuttingCountFloat.y, 1);
int totalFrameCount = uvCuttingCountX * uvCuttingCountY;
// (2) currentFrameIndex를 [0, totalFrameCount)로 래핑 (정수 % 제거)
int wrappedFrameIndex = currentFrameIndex;
if (totalFrameCount > 0)
{
float inverseTotalFrameCount = 1.0f / (float) totalFrameCount;
// loopCount = floor(currentFrameIndex / totalFrameCount)
int loopCount = (int) floor((float) currentFrameIndex * inverseTotalFrameCount);
wrappedFrameIndex = currentFrameIndex - loopCount * totalFrameCount;
// 음수 프레임까지 방어(선택)
if (wrappedFrameIndex < 0)
{
wrappedFrameIndex += totalFrameCount;
}
}
else
{
wrappedFrameIndex = 0;
}
// (3) 가로 기준으로 행/열 구하기 (정수 /, % 제거)
float inverseCuttingCountX = 1.0f / (float) uvCuttingCountX;
float inverseCuttingCountY = 1.0f / (float) uvCuttingCountY;
// frameIndexY = floor(wrappedFrameIndex / uvCuttingCountX)
int frameIndexY = (int) floor((float) wrappedFrameIndex * inverseCuttingCountX);
// frameIndexX = wrappedFrameIndex - frameIndexY * uvCuttingCountX (% 대체)
int frameIndexX = wrappedFrameIndex - frameIndexY * uvCuttingCountX;
// (4) UV 변환
float2 resultUV = originalUV;
resultUV.x = resultUV.x * inverseCuttingCountX + (float) frameIndexX * inverseCuttingCountX;
resultUV.y = resultUV.y * inverseCuttingCountY + (float) frameIndexY * inverseCuttingCountY;
return resultUV;
float2 UV = vUV; // 이미지의 UV값
int iTotalFrame = vUVCutting.x * vUVCutting.y; // 이미지의 최대 프레임 (몇 곱하기 몇인지)
int iFrameX = iCurrentFrame % (int) vUVCutting.x; // 현재 x축의 위치(현재 이미지의 몇번째 칸을 보여줄 지)
int iFrameY = iCurrentFrame / (int) vUVCutting.x; // 현재 y축의 위치(현재 이미지의 몇번째 줄을 보여줄 지)
float fFreamWidth = 1.0 / vUVCutting.x; // 1.0 나누기 이미지 갯수를 해서 한칸에 얼마나 갈지 정해준다.
float fFreamHeight = 1.0 / vUVCutting.y; // 1.0 나누기 이미지 갯수를 해서 한줄에 얼마나 갈지 정해준다.
UV.x = UV.x * fFreamWidth + iFrameX * fFreamWidth; // 먼저 uv를 0~1이 아닌 0~fFrameWidth로 만든 다음에 한칸씩 옆으로 밀어준다.
UV.y = UV.y * fFreamHeight + iFrameY * fFreamHeight; // 먼저 uv를 0~1이 아닌 0~fFrameHeight로 만든 다음에 한줄씩 밑으로 내려준다.
return UV;
}
//float2 UV_Cutting(float2 originalUV, float2 uvCuttingCountFloat, int currentFrameIndex)
//{
// // (1) 칸 개수는 정수로 취급 (0 방지)
// int uvCuttingCountX = max((int) uvCuttingCountFloat.x, 1);
// int uvCuttingCountY = max((int) uvCuttingCountFloat.y, 1);
// int totalFrameCount = uvCuttingCountX * uvCuttingCountY;
// // (2) currentFrameIndex를 [0, totalFrameCount)로 래핑 (정수 % 제거)
// int wrappedFrameIndex = currentFrameIndex;
// if (totalFrameCount > 0)
// {
// float inverseTotalFrameCount = 1.0f / (float) totalFrameCount;
// // loopCount = floor(currentFrameIndex / totalFrameCount)
// int loopCount = (int) floor((float) currentFrameIndex * inverseTotalFrameCount);
// wrappedFrameIndex = currentFrameIndex - loopCount * totalFrameCount;
// // 음수 프레임까지 방어(선택)
// if (wrappedFrameIndex < 0)
// {
// wrappedFrameIndex += totalFrameCount;
// }
// }
// else
// {
// wrappedFrameIndex = 0;
// }
// // (3) 가로 기준으로 행/열 구하기 (정수 /, % 제거)
// float inverseCuttingCountX = 1.0f / (float) uvCuttingCountX;
// float inverseCuttingCountY = 1.0f / (float) uvCuttingCountY;
// // frameIndexY = floor(wrappedFrameIndex / uvCuttingCountX)
// int frameIndexY = (int) floor((float) wrappedFrameIndex * inverseCuttingCountX);
// // frameIndexX = wrappedFrameIndex - frameIndexY * uvCuttingCountX (% 대체)
// int frameIndexX = wrappedFrameIndex - frameIndexY * uvCuttingCountX;
// // (4) UV 변환
// float2 resultUV = originalUV;
// resultUV.x = resultUV.x * inverseCuttingCountX + (float) frameIndexX * inverseCuttingCountX;
// resultUV.y = resultUV.y * inverseCuttingCountY + (float) frameIndexY * inverseCuttingCountY;
// return resultUV;
//}
// (Kd F(Lambert)) + (Ks F(cook-torrance))
@@ -51,7 +51,9 @@ PS_OUT PS_MAIN(PS_IN In)
vector vMixedDiffuse = g_MixedDiffuseTexture.Sample(PointSampler, In.vTexcoord);
float fRevealage = g_RevealageTexture.Sample(PointSampler, In.vTexcoord).r;
float fRevealage = clamp(g_RevealageTexture.Sample(PointSampler, In.vTexcoord).r, 0.f ,1.f);
Out.vBackBuffer = vector(vMixedDiffuse.rgb / fRevealage , fRevealage);
+2 -2
View File
@@ -569,7 +569,7 @@ void CRenderer::Render_Fog()
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Fog"), m_pShader, "g_Texture"))) {
return;
}
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::DEBUG));
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::PRINT_BACKBUFFER));
m_pVIBuffer->Bind_Resources();
m_pVIBuffer->Render();
@@ -585,7 +585,7 @@ void CRenderer::Render_Fog()
return;
}
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::PRINT_BACKBUFFER));
m_pShader->Begin(ENUM_CLASS(SHADER_PASS_DEFERRED::FOG));
m_pVIBuffer->Bind_Resources();
m_pVIBuffer->Render();