diff --git a/Jusin154_Team3D/Client/Private/Broom.cpp b/Jusin154_Team3D/Client/Private/Broom.cpp index add7aee9a..7aae1c143 100644 --- a/Jusin154_Team3D/Client/Private/Broom.cpp +++ b/Jusin154_Team3D/Client/Private/Broom.cpp @@ -124,7 +124,7 @@ void CBroom::Update(_float fTimeDelta) m_pWindEffect->Set_Visible(true); m_pWindEffect->Get_Component()->Set_TimeMult(0.5f + m_fSpeed / 20.f); - m_pWindEffect->Get_Effect_Info()->fSoftMask = 1.f + m_fSpeed / 10.f; + m_pWindEffect->Get_Effect_Info()->fBlurIntensity = m_fSpeed / 30.f; } @@ -144,7 +144,7 @@ void CBroom::Late_Update(_float fTimeDelta) WindTransform->Set_WorldMatrix(WorldMat); _vector vCameraLook = XMVector3Normalize(m_pGameInstance->Get_CameraLook()); - WindTransform->Set_State(STATE::POSITION, m_pGameInstance->Get_CamXMPosition() + vCameraLook * m_fCameraOffset + XMVectorSet(0.f ,m_fYOffset , 0.f ,0.f)); + WindTransform->Set_State(STATE::POSITION, m_pGameInstance->Get_CamXMPosition() + vCameraLook * m_fCameraOffset); #if _DEBUG #if 진우 @@ -153,7 +153,6 @@ void CBroom::Late_Update(_float fTimeDelta) m_pWindEffect->Get_Component()->Describe_Entity(); GUI::Checkbox("BillBoard", &m_pWindEffect->Get_Effect_Info()->isBillboard); GUI::DragFloat("Offset", &m_fCameraOffset); - GUI::DragFloat("Offset Y", &m_fYOffset); GUI::End(); #endif #endif diff --git a/Jusin154_Team3D/Client/Public/Broom.h b/Jusin154_Team3D/Client/Public/Broom.h index adbc15591..624678d12 100644 --- a/Jusin154_Team3D/Client/Public/Broom.h +++ b/Jusin154_Team3D/Client/Public/Broom.h @@ -74,8 +74,7 @@ class CBroom final : public CUnit BroomInput m_Input; class CEffectParts* m_pWindEffect = { nullptr }; - _float m_fCameraOffset = { -10.f }; - _float m_fYOffset= { -5.f }; + _float m_fCameraOffset = { 10.f }; private: HRESULT Ready_Components(); HRESULT Bind_ShaderResources(); diff --git a/Jusin154_Team3D/Client/Public/Client_Enum.h b/Jusin154_Team3D/Client/Public/Client_Enum.h index a1dcd7a2f..316bb2dde 100644 --- a/Jusin154_Team3D/Client/Public/Client_Enum.h +++ b/Jusin154_Team3D/Client/Public/Client_Enum.h @@ -11,7 +11,7 @@ namespace Client enum class SHADER_PASS_NORTEX { DEFAULT, TERRAIN, ENV_TERRAIN_ANISO, SHADOW, END }; enum class SHADER_PASS_PARTICLE { EXPLOSION, END }; enum class SHADER_PASS_POSTEX { DEFAULT, SCISSOR, UI, UVMOVE, TRAIL, TRAIL_BLEND, TRAILWB_FOR_BLEND, TRAIL_BLUR, TRAIL_BLOOM, END }; - enum class SHADER_PASS_INSTANCE_MODEL { DEFAULT, NON_NOMALMAP, BLUR, WEIGHTBLEND, NON_WORLD, NON_WORLD_BLUR, BLEND, BLEND_NOWORLD, BLOOM, BLOOM_NOWORLD, BLUR_NO_EMMISVE, BLUR_NO_WORLD_NO_EMISSIVE, WEIGHTBLEND_FOR_BLEND, DEPTH_STOP, WB_CULLING, SCREEN_FX, END }; + enum class SHADER_PASS_INSTANCE_MODEL { DEFAULT, NON_NOMALMAP, BLUR, WEIGHTBLEND, NON_WORLD, NON_WORLD_BLUR, BLEND, BLEND_NOWORLD, BLOOM, BLOOM_NOWORLD, BLUR_NO_EMMISVE, BLUR_NO_WORLD_NO_EMISSIVE, WEIGHTBLEND_FOR_BLEND, DEPTH_STOP, WB_CULLING, SCREEN_FX, DISTORTION,END }; enum class SHADER_PASS_UIEDITOR { DEFAULT, LOGO, LOGO_TEXT, LOGO_GLOW, ALPHABLEND, CLAMP, CURSOR, LODING, HOLD_ROTATION, MISSION, QUESTTYPE, UVMULT, NINECLICE, diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Bombard/Bombard_Distortion.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Bombard/Bombard_Distortion.bin new file mode 100644 index 000000000..43a30e800 --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Bombard/Bombard_Distortion.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ea9f9d588814894473fe8a2e04ff2605d98bcaee9fd5f370da67ec73f3b0186 +size 990 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/DistortTest.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/DistortTest.bin new file mode 100644 index 000000000..25844f2cf --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/DistortTest.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20c722a5da44cfcca3ddfa687037f9c86235d603a4506e36321198dbceb1e656 +size 1045 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Package/Bombard.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Package/Bombard.bin index d0e5dc2c3..826e7f1a6 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Package/Bombard.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/Package/Bombard.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1aa176cc2a633eb12a2edcd82a34c80dc1e5bfcfbb79923361e960a94692919b -size 646 +oid sha256:561ed40eb850f6b15763b8c21409c7b4732457e0d1240cd8b5100c6e18734031 +size 788 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/ScreenFX/Wind.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/ScreenFX/Wind.bin index 24f971bee..70b3a2cc3 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/ScreenFX/Wind.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/ScreenFX/Wind.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:621033b2bae53361347bc874097141eac07edb5a97b890594f6c61eb30ed5df6 -size 1094 +oid sha256:47682961b204577154f85a68fb5b9041230e0739e67028ce473fe18f11f879c2 +size 1102 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S0.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S0.bin deleted file mode 100644 index d0ce54b0f..000000000 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S0.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ca58aadbab22436f5d072c2ad9acc8e9f7af8d00524458a51bcd0c16823a3d2a -size 996 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S1.bin b/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S1.bin deleted file mode 100644 index 6ae798b86..000000000 --- a/Jusin154_Team3D/Editor/Bin/Resources/Data/Effect/TP_Test_S1.bin +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2dc51483655b161aef6293d6950df6753902e46657916127768aa01e2ce813c9 -size 996 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.bin b/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.bin index d204263f0..c2b335b51 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.bin +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.bin @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:55c3b0542bad38b17b3f33c00d1b7f3cc84d4472a7a55db6f4353bd5d708e1cf +oid sha256:9b4c7278c7989b62104c137458e1bb35fdcb537f700f5e0908d5be6a8a086f70 size 94378 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.fbx b/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.fbx new file mode 100644 index 000000000..c1ac364be --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/Models/Effect/ParticleMesh/VFX_SM_TubeFlared_SquashUV_1m.001.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b616c0720d370835588dd918fa72604513092a23df804ac65877d3c7020b93d9 +size 68172 diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl new file mode 100644 index 000000000..8087f4a99 --- /dev/null +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl @@ -0,0 +1,100 @@ +#include "Engine_Shader_Defines.hlsli" + +matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix; + + +Texture2D g_DistortionTexture; +Texture2D g_SceneTexture; + +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 +{ + float4 vBackBuffer : SV_TARGET0; +}; + +PS_OUT PS_MAIN(PS_IN In) +{ + PS_OUT Out; + + + /* 디스토션 렌더타겟 텍스쳐 샘플링 */ + vector vMtrlDistortion = g_DistortionTexture.Sample(PointSampler, In.vTexcoord); + vector vMtrlBackBuffer = g_SceneTexture.Sample(PointSampler, In.vTexcoord); + + /* r 성분을 디스토션할 성분으로 잡아놨으니까, r이 0이라면 리턴. */ + + if (vMtrlDistortion.r == 0) + { + Out.vBackBuffer = vMtrlBackBuffer; + return Out; + } + + + // 0 ~ 1 -> -0.5 ~ 0.5 + float2 vCenteredUV = In.vTexcoord - float2(0.5f, 0.5f); + + + float fDistortR2 = vMtrlDistortion.r * vMtrlDistortion.r; + float fDistortR4 = fDistortR2 * fDistortR2; + float fDistortIntensity = vMtrlDistortion.g; + float fDistortionFactor = 1.0f + (fDistortIntensity * (fDistortR2 + fDistortR2 * fDistortR4)); + + //float fDistortionFactor = 1 + vMtrlDistortion.g * vMtrlDistortion.r * vMtrlDistortion.r; + //너무 낮은값 쓰면 찢어지는 효과 남. (같은 픽셀 계속 디스토션 돌려서) + //fDistortionFactor = clamp(fDistortionFactor, 0.2f, 2.0f); + + vCenteredUV *= fDistortionFactor; + vCenteredUV += float2(0.5f, 0.5f); + + float4 vResult = g_SceneTexture.Sample(MirrorSampler, vCenteredUV); + + Out.vBackBuffer = vResult; + + return Out; +} + +technique11 DefaultTechnique +{ + pass Distortion + { + 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_MAIN(); + } + +} diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxModelInstance.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxModelInstance.hlsl index 09cef3616..96ad09162 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxModelInstance.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxModelInstance.hlsl @@ -177,6 +177,10 @@ float g_fRimLightPower; float g_fRimLightStrength; float4 g_vRimLightColor; +/* 모델 디스토션 */ + +float g_fModelDistortIntensity; + struct VS_IN @@ -933,6 +937,35 @@ PS_OUT PS_NO_DEPTH_COMPARE(PS_IN In) return Out; } +PS_BLOOM_OUT PS_DISTORTION(PS_IN In) +{ + PS_BLOOM_OUT Out; + + vector vMtrlDiffuse; + + + Out.vDiffuse = DrawEffect(In); + + if (Out.vDiffuse.a == 0.f) + discard; + + /* b,a 성분은 0으로 밀어준다. */ + + + + /* 거리 기반으로 디스토션 할 객체 중점으로부터의 거리 구해냄. */ + /* 중점이라면 r은 1, 중점에서의 거리가 멀수록 1에서 r 성분의 크기가 줄어드는 형태. */ + Out.vDiffuse.r = 1 - length(In.vTexcoord - float2(0.5f, 0.5f)); + + /* 세기 */ + Out.vDiffuse.g = g_fModelDistortIntensity * Out.vDiffuse.a; + + Out.vDiffuse.ba = 0.f; + + return Out; +} + + technique11 DefaultTechnique { //0 @@ -1104,6 +1137,16 @@ technique11 DefaultTechnique GeometryShader = NULL; PixelShader = compile ps_5_0 PS_NO_DEPTH_COMPARE(); } +//16 + pass DISTORTION + { + SetRasterizerState(RS_Nocull); + SetDepthStencilState(DSS_None, 0); + SetBlendState(BS_WB_Acc, 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_DISTORTION(); + } } diff --git a/Jusin154_Team3D/Editor/Private/EditEffect.cpp b/Jusin154_Team3D/Editor/Private/EditEffect.cpp index 7f5a9ae32..32a1b32ca 100644 --- a/Jusin154_Team3D/Editor/Private/EditEffect.cpp +++ b/Jusin154_Team3D/Editor/Private/EditEffect.cpp @@ -430,11 +430,11 @@ void CEditEffect::Describe_Entity() //여기서 모델, 텍스쳐, 선택할 수 있도록 함 const char* pLerp[] = { "Linear" , "EaseInQuad", "EaseOutQuad", "EaseInCubic" , "EaseOutCubic" , "EaseInOutSin" , "EaseInBack" , "Expo" , "Circle" }; - const char* pRenderNames[] = { "PRIORITY" , "SHADOW_NEAR", "NONBLEND", "DECAL", "BLUR" , "NONLIGHT" ,"EFFECT", "BLEND" ,"BLOOM" , "UI", "OCCLUSION" , "PRESHADOW", "UI_OVERLAY"}; - const char* pEffectType[] = { "EFFECT" , "TRAIL" }; - const char* pShaderPass[] = { "DEFAULT" , "NON_NOMALMAP" , "BLUR" , "WEIGHTBLEND" , "NON_WORLD" , "NON_WORLD_BLUR", "BLEND", "BLEND_NOWORLD", "BLOOM" ,"BLOOM_NOWORLD" ,"BLUR_NO_EMMISVE", "BLUR_NO_WORLD_NO_EMISSIVE","WEIGHTBLEND_FOR_BLEND" , "DEPTH_STOP" , "WB_CULLING", "SCREEN_FX"}; - const char* pBloomType[] = { "NONE" , "BASIC" , "MUILTY"}; + const char* pRenderNames[] = { "PRIORITY" , "SHADOW_NEAR", "NONBLEND", "DECAL", "BLUR" , "NONLIGHT" ,"EFFECT", "BLEND" ,"BLOOM", "DISTORTION" , "UI", "OCCLUSION" , "SHADOW_MIDDLE", "SHADOW_FAR" , "PRESHADOW" , "UI_OVERLAY" }; + const char* pEffectType[] = { "EFFECT" , "TRAIL" }; + const char* pShaderPass[] = { "DEFAULT" , "NON_NOMALMAP" , "BLUR" , "WEIGHTBLEND" , "NON_WORLD" , "NON_WORLD_BLUR", "BLEND", "BLEND_NOWORLD", "BLOOM" ,"BLOOM_NOWORLD" ,"BLUR_NO_EMMISVE", "BLUR_NO_WORLD_NO_EMISSIVE","WEIGHTBLEND_FOR_BLEND" , "DEPTH_STOP" , "WB_CULLING", "SCREEN_FX" , "DISTORTION"}; + const char* pBloomType[] = { "NONE" , "BASIC" , "MUILTY"}; _int iCurrentItem = static_cast<_int>(m_EffectInfo.eRenderOrder); _int iCurrentType = static_cast<_int>(m_EffectInfo.eEffectType); _int iCurrentBloomType = static_cast<_int>(m_EffectInfo.eBloomType); @@ -488,6 +488,9 @@ void CEditEffect::Describe_Entity() GUI::Checkbox("Bloom", &m_EffectInfo.isBloom); GUI::Checkbox("Blur", &m_EffectInfo.isBlur); GUI::Checkbox("RimLight", &m_EffectInfo.isRimLight); + + + if (GUI::Checkbox("Billboard", &m_EffectInfo.isBillboard)) { @@ -502,6 +505,8 @@ void CEditEffect::Describe_Entity() ImGui::PopItemWidth(); + + if (m_EffectInfo.isBlur) { if (GUI::TreeNode("BLUR")) @@ -553,7 +558,12 @@ void CEditEffect::Describe_Entity() GUI::TreePop(); } } - + + if (GUI::TreeNode("MODEL DISTORTION")) + { + GUI::DragFloat("Distortion Intensity", &m_EffectInfo.fModelDistortIntensity, 0.005f, 0.f, 1.f); + GUI::TreePop(); + } if (GUI::TreeNode("EMISSIVE")) { diff --git a/Jusin154_Team3D/Editor/Private/EffectObject.cpp b/Jusin154_Team3D/Editor/Private/EffectObject.cpp index a8cdb6c5a..d1e06135a 100644 --- a/Jusin154_Team3D/Editor/Private/EffectObject.cpp +++ b/Jusin154_Team3D/Editor/Private/EffectObject.cpp @@ -1013,6 +1013,12 @@ HRESULT CEffectObject::Bind_ShaderResources() return E_FAIL; } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fModelDistortIntensity", &m_EffectInfo.fModelDistortIntensity, sizeof(_float)))) { + return E_FAIL; + } + + + if (m_pDiffuse_TextureCom != nullptr) { diff --git a/Jusin154_Team3D/Editor/Public/Editor_Define.h b/Jusin154_Team3D/Editor/Public/Editor_Define.h index 20b5c352d..02deee953 100644 --- a/Jusin154_Team3D/Editor/Public/Editor_Define.h +++ b/Jusin154_Team3D/Editor/Public/Editor_Define.h @@ -35,7 +35,7 @@ namespace Editor SPELL_HEADER_LINE, SPELL_DRAG, CAMERA_LOCKON, LODING_SCREEN, ENEMY_HPBAR, BOSS_HPBAR, QUEST_BORDER, QUEST_INFO, QUEST_STATUS, BROOMSTICK, ENEMY_DETECTION, INTERACTION_OBJECT, END }; - enum class SHADER_PASS_INSTANCE_MODEL { DEFAULT, NON_NOMALMAP, BLUR, WEIGHTBLEND, NON_WORLD, NON_WORLD_BLUR, BLEND, BLEND_NOWORLD, BLOOM, BLOOM_NOWORLD, BLUR_NO_EMMISVE, BLUR_NO_WORLD_NO_EMISSIVE, WEIGHTBLEND_FOR_BLEND, DEPTH_STOP, WB_CULLING, SCREEN_FX ,END }; + enum class SHADER_PASS_INSTANCE_MODEL { DEFAULT, NON_NOMALMAP, BLUR, WEIGHTBLEND, NON_WORLD, NON_WORLD_BLUR, BLEND, BLEND_NOWORLD, BLOOM, BLOOM_NOWORLD, BLUR_NO_EMMISVE, BLUR_NO_WORLD_NO_EMISSIVE, WEIGHTBLEND_FOR_BLEND, DEPTH_STOP, WB_CULLING, SCREEN_FX , DISTORTION ,END }; enum class SHADER_PASS_UIINTANCE { DEFAULT, ALPHABLEND, UVALPHABLEND, MAGIC_METER, SPELL_LIST, EESSENTIAL_SPELL_SOLT, EESSENTIAL_SPELL, COLOR, SPELL_HOVER, SPELL_SLOT_EFFECT, SPELL_SLOT, SPELL_LOCK,END }; diff --git a/Jusin154_Team3D/Editor/Public/EffectObject.h b/Jusin154_Team3D/Editor/Public/EffectObject.h index 2909bff79..70a36d075 100644 --- a/Jusin154_Team3D/Editor/Public/EffectObject.h +++ b/Jusin154_Team3D/Editor/Public/EffectObject.h @@ -106,8 +106,8 @@ class CEffectObject abstract : public CPartObject _float3 vDissolveValue = {}; - - _float2 vPadding0 = {}; + _float fModelDistortIntensity = {}; + _float vPadding0 = {}; _float fLightDeley = {}; _float fLightIntensity = {}; diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl new file mode 100644 index 000000000..8087f4a99 --- /dev/null +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Distortion.hlsl @@ -0,0 +1,100 @@ +#include "Engine_Shader_Defines.hlsli" + +matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix; + + +Texture2D g_DistortionTexture; +Texture2D g_SceneTexture; + +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 +{ + float4 vBackBuffer : SV_TARGET0; +}; + +PS_OUT PS_MAIN(PS_IN In) +{ + PS_OUT Out; + + + /* 디스토션 렌더타겟 텍스쳐 샘플링 */ + vector vMtrlDistortion = g_DistortionTexture.Sample(PointSampler, In.vTexcoord); + vector vMtrlBackBuffer = g_SceneTexture.Sample(PointSampler, In.vTexcoord); + + /* r 성분을 디스토션할 성분으로 잡아놨으니까, r이 0이라면 리턴. */ + + if (vMtrlDistortion.r == 0) + { + Out.vBackBuffer = vMtrlBackBuffer; + return Out; + } + + + // 0 ~ 1 -> -0.5 ~ 0.5 + float2 vCenteredUV = In.vTexcoord - float2(0.5f, 0.5f); + + + float fDistortR2 = vMtrlDistortion.r * vMtrlDistortion.r; + float fDistortR4 = fDistortR2 * fDistortR2; + float fDistortIntensity = vMtrlDistortion.g; + float fDistortionFactor = 1.0f + (fDistortIntensity * (fDistortR2 + fDistortR2 * fDistortR4)); + + //float fDistortionFactor = 1 + vMtrlDistortion.g * vMtrlDistortion.r * vMtrlDistortion.r; + //너무 낮은값 쓰면 찢어지는 효과 남. (같은 픽셀 계속 디스토션 돌려서) + //fDistortionFactor = clamp(fDistortionFactor, 0.2f, 2.0f); + + vCenteredUV *= fDistortionFactor; + vCenteredUV += float2(0.5f, 0.5f); + + float4 vResult = g_SceneTexture.Sample(MirrorSampler, vCenteredUV); + + Out.vBackBuffer = vResult; + + return Out; +} + +technique11 DefaultTechnique +{ + pass Distortion + { + 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_MAIN(); + } + +} diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index 589c53be1..6087a1cf1 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -639,6 +639,7 @@ call Update_Lib.bat + Effect 5.0 diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters index fc94737c2..96125127b 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters @@ -1314,5 +1314,8 @@ 99.Define\01.SHADER + + 99.Define\01.SHADER + \ No newline at end of file diff --git a/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp b/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp index f8a364bae..b45e90203 100644 --- a/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/Prototype_Manager.cpp @@ -126,6 +126,13 @@ HRESULT CPrototype_Manager::Ready_EngineAssets() return E_FAIL; } + if (FAILED(Add_Asset_Prototype(g_iStaticLevel, FX_DISTORTION, + CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_Distortion.hlsl"), + VTXPOSTEX::Elements, VTXPOSTEX::iNumElements)))) { + return E_FAIL; + } + + #pragma region COMPUTE_SHADER if (FAILED(Add_Asset_Prototype(g_iStaticLevel, CS_EFFECT, diff --git a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp index f12ca295e..f6325c93d 100644 --- a/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/RenderTarget_Manager.cpp @@ -216,6 +216,7 @@ HRESULT CRenderTarget_Manager::Bind_CS_RenderTarget(_uint iIndex, const _wstring return S_OK; } + HRESULT CRenderTarget_Manager::Accumulate_RenderTarget(CVIBuffer_Rect* pVIBuffer, CShader* pShader, const _wstring& wstrRenderTarget_SrcA, const _wstring& wstrRenderTarget_SrcB, const _wstring& wstrRenderTarget_Target, SHADER_PASS_DEFERRED ePass) diff --git a/Jusin154_Team3D/Engine/Private/Renderer.cpp b/Jusin154_Team3D/Engine/Private/Renderer.cpp index 7f097081d..18757d2c4 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer.cpp @@ -26,6 +26,8 @@ void CRenderer::Render() Render_Occlusion(); Render_EnvironmentPostProcess(); Render_Fog(); + Render_Distortion(); + Render_DistortionAcc(); Render_Effect(); Render_NonLight(); Render_Blend(); @@ -547,12 +549,11 @@ void CRenderer::Render_Fog() void CRenderer::Render_Effect() { COMPUTE_TIMEDELTA("Timer_Render_Effect"); + if (FAILED(m_pGameInstance->Begin_MRT_NO_DepthStencil(TEXT("MRT_WB")))) { return; } - - for (auto& pRenderObject : m_RenderObjects[ENUM_CLASS(RENDER::EFFECT)]) { if (nullptr != pRenderObject) @@ -869,6 +870,66 @@ void CRenderer::Render_Bloom() COMPUTE_TIMEDELTA("Timer_Render_Bloom"); } +void CRenderer::Render_Distortion() +{ + COMPUTE_TIMEDELTA("Timer_Render_Distortion"); + + if (FAILED(m_pGameInstance->Begin_MRT(TEXT("MRT_Distortion")))) { + return; + } + + for (auto& pRenderObject : m_RenderObjects[ENUM_CLASS(RENDER::DISTORTION)]) + { + if (nullptr != pRenderObject) + pRenderObject->Render(); + + SAFE_RELEASE(pRenderObject); + } + + m_RenderObjects[ENUM_CLASS(RENDER::DISTORTION)].clear(); + + if (FAILED(m_pGameInstance->End_MRT())) { + return; + } + + COMPUTE_TIMEDELTA("Timer_Render_Distortion"); +} + +void CRenderer::Render_DistortionAcc() +{ + COMPUTE_TIMEDELTA("Timer_Render_DistortionAcc"); + // Bind_Resorces + + ID3D11Texture2D* pBackBufferTexture2D = { nullptr }; + + m_pGameInstance->Get_BackBufferPTR(&pBackBufferTexture2D); + + if (FAILED(m_pGameInstance->Paste_RenderTarget(TEXT("Target_PreEffect"), pBackBufferTexture2D))) { + return; + } + + m_pDistortionShader->Bind_Matrix("g_WorldMatrix", &m_WorldMatrix); + m_pDistortionShader->Bind_Matrix("g_ViewMatrix", &m_ViewMatrix); + m_pDistortionShader->Bind_Matrix("g_ProjMatrix", &m_ProjMatrix); + + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_Distortion"), m_pDistortionShader, "g_DistortionTexture"))) { + return; + } + + if (FAILED(m_pGameInstance->Bind_RenderTarget(TEXT("Target_PreEffect"), m_pDistortionShader, "g_SceneTexture"))) { + return; + } + + m_pDistortionShader->Begin(0); + + m_pVIBuffer->Bind_Resources(); + m_pVIBuffer->Render(); + + SAFE_RELEASE(pBackBufferTexture2D); + + COMPUTE_TIMEDELTA("Timer_Render_DistortionAcc"); +} + void CRenderer::Render_UI() { COMPUTE_TIMEDELTA("Timer_Render_UI"); diff --git a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp index 296df9d93..f7b72b683 100644 --- a/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp +++ b/Jusin154_Team3D/Engine/Private/Renderer_Declare.cpp @@ -332,11 +332,23 @@ HRESULT CRenderer::Initialize() DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Bloom_2x2_2"), (_uint)(Viewport.Width * 0.5f), (_uint)(Viewport.Height * 0.5f), DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { return E_FAIL; } + if (FAILED(m_pGameInstance->Add_RenderTarget(TEXT("Target_Distortion"), (_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_PreEffect"), (_uint)(Viewport.Width), (_uint)(Viewport.Height), + DXGI_FORMAT_R16G16B16A16_FLOAT, _float4(0.0f, 0.0f, 0.0f, 0.0f)))) { + return E_FAIL; + } + + if (FAILED(Ready_ShadowDepthStencilView(g_iMaxShadowWidth, g_iMaxShadowHeight))) { return E_FAIL; @@ -457,6 +469,15 @@ HRESULT CRenderer::Initialize() return E_FAIL; } + + /* MRT_Distortion */ + if (FAILED(m_pGameInstance->Add_MRT(TEXT("MRT_Distortion"), TEXT("Target_Distortion")))) { + return E_FAIL; + } + + + + } m_pShader = (CShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, FX_DEFERRED, nullptr, nullptr); @@ -476,6 +497,14 @@ HRESULT CRenderer::Initialize() return E_FAIL; } + m_pDistortionShader = (CShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, FX_DISTORTION, nullptr, nullptr); + + if (nullptr == m_pDistortionShader) { + return E_FAIL; + } + + + m_pVIBuffer = CVIBuffer_Rect::Create(m_pDevice, m_pContext); if (nullptr == m_pVIBuffer) { return E_FAIL; @@ -532,6 +561,7 @@ void CRenderer::Free() SAFE_RELEASE(m_pShader); SAFE_RELEASE(m_pLastColorShader); SAFE_RELEASE(m_pWeightBlendShader); + SAFE_RELEASE(m_pDistortionShader); SAFE_RELEASE(m_pVIBuffer); SAFE_RELEASE(m_pDevice); SAFE_RELEASE(m_pContext); diff --git a/Jusin154_Team3D/Engine/Public/Engine_Enum.h b/Jusin154_Team3D/Engine/Public/Engine_Enum.h index 1f0a3bd08..d131b2115 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Enum.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Enum.h @@ -5,7 +5,7 @@ NS_BEGIN(Engine) enum class STATE { RIGHT, UP, LOOK, POSITION, END }; enum class LIGHT { DIRECTIONAL, POINT, SPOT, END }; enum class COLLIDER { AABB, OBB, SPHERE, END }; -enum class RENDER {PRIORITY, SHADOW_NEAR, NONBLEND, DECAL, BLUR, NONLIGHT, EFFECT ,BLEND, BLOOM, UI, OCCLUSION, SHADOW_MIDDLE, SHADOW_FAR, PRESHADOW, UI_OVERLAY, END }; +enum class RENDER {PRIORITY, SHADOW_NEAR, NONBLEND, DECAL, BLUR, NONLIGHT, EFFECT ,BLEND, BLOOM, DISTORTION, UI, OCCLUSION, SHADOW_MIDDLE, SHADOW_FAR, PRESHADOW, UI_OVERLAY ,END }; enum class RAY { LOCAL, WORLD, END }; enum class ACTOR { BOX, CAPSULE, SPHERE, PLANE, TRIANGLEMESH, HEIGHTFIELD, END }; enum class BLEND_BONE{SPINE,SHOULDER_L,SHOULDER_R,NECK,SHOULDER_NECK_L, SHOULDER_NECK_R,END}; diff --git a/Jusin154_Team3D/Engine/Public/Engine_Macro.h b/Jusin154_Team3D/Engine/Public/Engine_Macro.h index 613e92ca7..520ba7ea9 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Macro.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Macro.h @@ -30,7 +30,8 @@ #elif 진우 #undef ASSERT_JINWOO #define ASSERT_JINWOO(expression) assert(expression) -#define OPTIONAL_TRUE_KEYINPUTGUICHECK ||true +//#undef OPTIONAL_TRUE_KEYINPUTGUICHECK +//#define OPTIONAL_TRUE_KEYINPUTGUICHECK ||true #elif gimch #undef ASSERT_JINHO #define ASSERT_JINHO(expression) assert(expression) @@ -87,8 +88,9 @@ #define FX_DEFERRED TEXT("FX_DEFERRED") #define FX_LASTCOLOR TEXT("FX_LASTCOLOR") #define FX_WEIGHTBELND TEXT("FX_WEIGHTBELND") +#define FX_DISTORTION TEXT("FX_DISTORTION") -#define CS_EFFECT TEXT("CS_EFFECT") +#define CS_EFFECT TEXT("CS_EFFECT") #define CS_INSTANCE_MODEL TEXT("CS_INSTANCE_MODEL") #define SAFE_ADDREF(pInstance) Safe_AddRef(pInstance) diff --git a/Jusin154_Team3D/Engine/Public/Renderer.h b/Jusin154_Team3D/Engine/Public/Renderer.h index ff2ba04ed..b55c5d050 100644 --- a/Jusin154_Team3D/Engine/Public/Renderer.h +++ b/Jusin154_Team3D/Engine/Public/Renderer.h @@ -34,6 +34,7 @@ class CRenderer final : public CBase class CShader* m_pShader = { nullptr }; class CShader* m_pLastColorShader = { nullptr }; class CShader* m_pWeightBlendShader = { nullptr }; + class CShader* m_pDistortionShader = { nullptr }; class CVIBuffer_Rect* m_pVIBuffer = { nullptr }; private: @@ -91,6 +92,8 @@ class CRenderer final : public CBase void Render_NonLight(); void Render_Blend(); void Render_Bloom(); + void Render_Distortion(); + void Render_DistortionAcc(); void Render_LastColor(); void Render_Tone_Mapping(); void Render_UI();