Merge pull request #43 from SpicyGangjeong/Effect

Effect
This commit is contained in:
jinwoo0522
2025-11-10 12:29:50 +09:00
committed by GitHub
29 changed files with 549 additions and 109 deletions
@@ -29,7 +29,7 @@ Texture2D g_ShadowTexture;
Texture2D g_PreShadowTexture;
Texture2D g_BlurTexture;
Texture2D g_BlurXTexture;
Texture2D g_ColorTexture;
vector g_vLightDiffuse;
@@ -72,6 +72,7 @@ struct PS_OUT_BACKBUFFER
{
float4 vBackBuffer : SV_TARGET0;
};
PS_OUT_BACKBUFFER PS_MAIN_DEBUG(PS_IN In)
{
PS_OUT_BACKBUFFER Out;
@@ -307,37 +308,6 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
Out.vBackBuffer += vColor;
/* Color_Target */
vector ColorTexture = g_ColorTexture.Sample(DefaultSampler, vTexcoord);
int iOption = ColorTexture.a * 10;
if (iOption == 0) // 0이면 수행하지 않음
return Out;
switch (iOption)
{
case 1:
Out.vBackBuffer.rgb += ColorTexture.rgb;
break;
case 2:
Out.vBackBuffer.rgb *= ColorTexture.rgb;
break;
case 3:
Out.vBackBuffer.rgb -= ColorTexture.rgb;
break;
case 4:
Out.vBackBuffer.rgb /= ColorTexture.rgb;
break;
case 5:
Out.vBackBuffer.rgb = ColorTexture.rgb;
break;
default:
break;
}
return Out;
}
@@ -0,0 +1,99 @@
#include "Engine_Shader_Defines.hlsli"
matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix;
Texture2D g_ColorTexture;
struct VS_IN
{
float3 vPosition : POSITION;
float2 vTexcoord : TEXCOORD0;
};
struct VS_OUT
{
float4 vPosition : SV_POSITION;
float2 vTexcoord : TEXCOORD0;
};
VS_OUT VS_MAIN(VS_IN In)
{
VS_OUT Out;
matrix matWV, matWVP;
matWV = mul(g_WorldMatrix, g_ViewMatrix);
matWVP = mul(matWV, g_ProjMatrix);
Out.vPosition = mul(vector(In.vPosition, 1.f), matWVP);
Out.vTexcoord = In.vTexcoord;
return Out;
}
struct PS_IN
{
float4 vPosition : SV_POSITION;
float2 vTexcoord : TEXCOORD0;
};
struct PS_OUT_BACKBUFFER
{
float4 vBackBuffer : SV_TARGET0;
};
PS_OUT_BACKBUFFER PS_OUT_LASTCOLOR(PS_IN In)
{
PS_OUT_BACKBUFFER Out;
Out.vBackBuffer = float4(0.f, 0.f, 0.f, 0.f);
vector ColorTexture = g_ColorTexture.Sample(DefaultSampler, In.vTexcoord);
if (0.f == ColorTexture.a)
{
discard;
}
int iOption = ColorTexture.a * 10;
switch (iOption)
{
case 1:
Out.vBackBuffer.rgb += ColorTexture.rgb;
break;
case 2:
Out.vBackBuffer.rgb *= ColorTexture.rgb;
break;
case 3:
Out.vBackBuffer.rgb -= ColorTexture.rgb;
break;
case 4:
Out.vBackBuffer.rgb /= ColorTexture.rgb;
break;
case 5:
Out.vBackBuffer.rgb = ColorTexture.rgb;
break;
default:
break;
}
return Out;
}
technique11 DefaultTechnique
{
pass Default
{
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_OUT_LASTCOLOR();
}
}
@@ -44,7 +44,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableASAN>false</EnableASAN>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -507,6 +507,12 @@
<None Include="..\Public\fMod\fmod_errors.cs" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="..\Bin\Resources\ShaderFiles\Shader_LastColor.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Effect</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">5.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Effect</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">5.0</ShaderModel>
</FxCompile>
<FxCompile Include="..\Bin\Resources\ShaderFiles\Shader_Cell.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Effect</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">5.0</ShaderModel>
@@ -1080,5 +1080,8 @@
<FxCompile Include="..\Bin\Resources\ShaderFiles\Shader_Particle_Compute.hlsl">
<Filter>99.Define\01.SHADER</Filter>
</FxCompile>
<FxCompile Include="..\Bin\Resources\ShaderFiles\Shader_LastColor.hlsl">
<Filter>99.Define\01.SHADER</Filter>
</FxCompile>
</ItemGroup>
</Project>
@@ -106,6 +106,12 @@ HRESULT CPrototype_Manager::Ready_EngineAssets()
VTXPOSTEX::Elements, VTXPOSTEX::iNumElements)))) {
return E_FAIL;
}
if (FAILED(Add_Asset_Prototype(g_iStaticLevel, TEXT("FX_LASTCOLOR"),
CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_LastColor.hlsl"),
VTXPOSTEX::Elements, VTXPOSTEX::iNumElements)))) {
return E_FAIL;
}
return S_OK;
}
+34 -3
View File
@@ -113,6 +113,7 @@ void CRenderer::Render()
Render_NonLight();
Render_Blend();
Render_UI();
Render_LastColor();
#ifdef _DEBUG
if(m_pGameInstance->Key_Pressing(DIK_F10))
@@ -299,9 +300,7 @@ void CRenderer::Render_Combined()
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Blur_X"), m_pShader, "g_BlurXTexture"))) {
return;
}
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Color"), m_pShader, "g_ColorTexture"))) {
return;
}
}
@@ -414,6 +413,28 @@ void CRenderer::Render_UI()
m_RenderObjects[ENUM_CLASS(RENDER::UI)].clear();
}
void CRenderer::Render_LastColor()
{
// Bind_Resorces
m_pShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix);
m_pShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix);
m_pShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix);
m_pShader->Bind_Matrix("g_invMatView", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV));
m_pShader->Bind_Matrix("g_invmatProj", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ_INV));
if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Color"), m_pShader, "g_ColorTexture"))) {
return;
}
m_pShader->Begin(ENUM_CLASS(0));
m_pVIBuffer->Bind_Resources();
m_pVIBuffer->Render();
}
HRESULT CRenderer::Ready_DepthStencilView(_uint iSizeX, _uint iSizeY)
{
ID3D11Texture2D* pDepthStencilTexture = nullptr;
@@ -617,6 +638,15 @@ HRESULT CRenderer::Initialize()
return E_FAIL;
}
m_pLastColorShader = (CShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, TEXT("FX_LASTCOLOR"), nullptr, nullptr);
if (nullptr == m_pLastColorShader) {
return E_FAIL;
}
m_pVIBuffer = CVIBuffer_Rect::Create(m_pDevice, m_pContext);
if (nullptr == m_pVIBuffer) {
return E_FAIL;
@@ -701,6 +731,7 @@ void CRenderer::Free()
SAFE_RELEASE(m_pShadowDSV);
SAFE_RELEASE(m_pShader);
SAFE_RELEASE(m_pLastColorShader);
SAFE_RELEASE(m_pVIBuffer);
SAFE_RELEASE(m_pDevice);
SAFE_RELEASE(m_pContext);
+1
View File
@@ -132,6 +132,7 @@ class ENGINE_DLL CModel final : public CComponent
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix = XMMatrixIdentity());
//
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr);
virtual void Free(); public:
void Describe_Entity() override;
};
+2
View File
@@ -31,6 +31,7 @@ class CRenderer final : public CBase
#endif
private:
class CShader* m_pShader = { nullptr };
class CShader* m_pLastColorShader = { nullptr };
class CVIBuffer_Rect* m_pVIBuffer = { nullptr };
private:
@@ -60,6 +61,7 @@ class CRenderer final : public CBase
void Render_NonLight();
void Render_Blend();
void Render_UI();
void Render_LastColor();
#ifdef _DEBUG
private: