From acdeda80b14a106ca3f92903f33db7ffa22bd7c4 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Sun, 14 Dec 2025 16:36:58 +0900 Subject: [PATCH] =?UTF-8?q?[add]=20bilinear=20=EB=B3=B4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShaderFiles/Engine_Shader_Functions.hlsli | 10 ++++---- .../ShaderFiles/Shader_Deferred.hlsl | 25 +++++++++---------- .../ShaderFiles/Engine_Shader_Functions.hlsli | 10 ++++---- .../ShaderFiles/Shader_Deferred.hlsl | 25 +++++++++---------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli index 9582cf4fa..6edb266b5 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -413,27 +413,27 @@ float4 BilinearFetches(float2 vGlobalTexelSize, Texture2D SrcTexture2D, float2 v float3 fRBColor = float3(0.f, 0.f, 0.f); { if (true == IsValidUV(uv)) { - vCenterColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + vCenterColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.5f; } uv = vCenterTexCoord + vSrcTexelSize * float2(-1.0, -1.0); if (true == IsValidUV(uv)) { - fLTColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fLTColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(+1.0, -1.0); if (true == IsValidUV(uv)) { - fRTColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fRTColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(-1.0, +1.0); if (true == IsValidUV(uv)) { - fLBColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fLBColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(+1.0, +1.0); if (true == IsValidUV(uv)) { - fRBColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fRBColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index d3f595993..31516fa97 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -683,35 +683,34 @@ PS_OUT_FLT4_SINGLE PS_MAIN_EMBOSS(PS_IN In) { PS_OUT_FLT4_SINGLE Out; float2 uv = In.vTexcoord; - float fMask = g_DiffuseTexture.Sample(BorderZeroSampler, In.vTexcoord).a; + float fMask = 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); uint iMask = (uint) round(fMask * 255.f); // int a = 1 -> // vBloom.a = (enum / 255); - if (true) + if (0 != iMask) { // 주변 4개 셀(LT RT LB RB)및 중앙을 이중선형샘플링, 이후 자체적으로 이중선형샘플링 - float3 vCenterColor = g_DiffuseTexture.Sample(BorderZeroSampler, In.vTexcoord); - uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, -1.0); + float3 vCenterColor = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0); + uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, -1.0); float3 fLTColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, -1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, -1.0); float3 fRTColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, +1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, +1.0); float3 fLBColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, +1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, +1.0); float3 fRBColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); // vSample /= fWeight 이중선형샘플러가 자체적으로 웨이츠 계싼해주기 때문에 안해도 상관없을듯 vColor = vCenterColor * 0.5f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.125f; - if (iMask == 2) { + if (iMask == 2) + { vColor *= 3.f; } } - float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); // 대략적인 밝기 - if (fIntensity <= FLT_EPSILON5) { - Out.vFirstTarget = float4(0.f, 0.f, 0.f, 1.f); - return Out; - } + float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); + fIntensity = max(FLT_EPSILON3, fIntensity); + float fBloomIntensity = GetBloomCurve(fIntensity, g_fBloomThreshold, g_iBloomEmbossingPass); float3 bloomColor = (vColor * fBloomIntensity) / fIntensity; diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli index 9582cf4fa..6edb266b5 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Engine_Shader_Functions.hlsli @@ -413,27 +413,27 @@ float4 BilinearFetches(float2 vGlobalTexelSize, Texture2D SrcTexture2D, float2 v float3 fRBColor = float3(0.f, 0.f, 0.f); { if (true == IsValidUV(uv)) { - vCenterColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + vCenterColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.5f; } uv = vCenterTexCoord + vSrcTexelSize * float2(-1.0, -1.0); if (true == IsValidUV(uv)) { - fLTColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fLTColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(+1.0, -1.0); if (true == IsValidUV(uv)) { - fRTColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fRTColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(-1.0, +1.0); if (true == IsValidUV(uv)) { - fLBColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fLBColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } uv = vCenterTexCoord + vSrcTexelSize * float2(+1.0, +1.0); if (true == IsValidUV(uv)) { - fRBColor = SrcTexture2D.Sample(samplerLinear, uv).rgb; + fRBColor = SrcTexture2D.SampleLevel(samplerLinear, uv, 0).rgb; fWeight += 0.125f; } } diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index d3f595993..31516fa97 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -683,35 +683,34 @@ PS_OUT_FLT4_SINGLE PS_MAIN_EMBOSS(PS_IN In) { PS_OUT_FLT4_SINGLE Out; float2 uv = In.vTexcoord; - float fMask = g_DiffuseTexture.Sample(BorderZeroSampler, In.vTexcoord).a; + float fMask = 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); uint iMask = (uint) round(fMask * 255.f); // int a = 1 -> // vBloom.a = (enum / 255); - if (true) + if (0 != iMask) { // 주변 4개 셀(LT RT LB RB)및 중앙을 이중선형샘플링, 이후 자체적으로 이중선형샘플링 - float3 vCenterColor = g_DiffuseTexture.Sample(BorderZeroSampler, In.vTexcoord); - uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, -1.0); + float3 vCenterColor = g_DiffuseTexture.SampleLevel(BorderZeroSampler, uv, 0); + uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, -1.0); float3 fLTColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, -1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, -1.0); float3 fRTColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, +1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(-1.0, +1.0); float3 fLBColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); - uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, +1.0); + uv = In.vTexcoord + vSrcTexelSize * float2(+1.0, +1.0); float3 fRBColor = BilinearFetches(g_vResolution, g_DiffuseTexture, uv, BorderZeroLinearSampler); // vSample /= fWeight 이중선형샘플러가 자체적으로 웨이츠 계싼해주기 때문에 안해도 상관없을듯 vColor = vCenterColor * 0.5f + (fLTColor + fRTColor + fLBColor + fRBColor) * 0.125f; - if (iMask == 2) { + if (iMask == 2) + { vColor *= 3.f; } } - float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); // 대략적인 밝기 - if (fIntensity <= FLT_EPSILON5) { - Out.vFirstTarget = float4(0.f, 0.f, 0.f, 1.f); - return Out; - } + float fIntensity = dot(vColor, float3(0.2126f, 0.7152f, 0.0722f)); + fIntensity = max(FLT_EPSILON3, fIntensity); + float fBloomIntensity = GetBloomCurve(fIntensity, g_fBloomThreshold, g_iBloomEmbossingPass); float3 bloomColor = (vColor * fBloomIntensity) / fIntensity;