1121_2154

This commit is contained in:
GiJungSUk
2025-11-21 21:54:53 +09:00
parent b389bbc087
commit bba4268e89
57 changed files with 530 additions and 191 deletions
@@ -181,5 +181,53 @@ float3 DecodeNormalFromRG(Texture2D NormalMap, SamplerState Samp, float2 uv)
return normalize(n);
}
float4x4 RotateX(float fAngle)
{
float fCos = cos(radians(fAngle));
float fSin = sin(radians(fAngle));
float4x4 RotateXMat =
{
1, 0, 0, 0,
0, fCos, -fSin, 0,
0, fSin, fCos, 0,
0, 0, 0, 1,
};
return RotateXMat;
}
float4x4 RotateY(float fAngle)
{
float fCos = cos(radians(fAngle));
float fSin = sin(radians(fAngle));
float4x4 RotateYMat =
{
fCos , 0, fSin, 0,
0 , 1, 0, 0,
-fSin , 0, fCos, 0,
0 , 0, 0, 1
};
return RotateYMat;
}
float4x4 RotateZ(float fAngle)
{
float fCos = cos(radians(fAngle));
float fSin = sin(radians(fAngle));
float4x4 RotateZMat =
{
fCos, -fSin, 0, 0,
fSin, fCos, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
};
return RotateZMat;
}
#endif // ENGINE_SHADER_FUNCTIONS_HLSLI
@@ -1,5 +1,4 @@
float PI = 3.141592;
#include "Engine_Shader_Functions.hlsli"
struct Particle
{
@@ -30,7 +29,8 @@ struct ParticleValue
float2 vAniIndex;
float fGravity;
float3 vSinAmount;
float3 vSinAmount;
float3 vDeltaAngle;
};
@@ -48,6 +48,11 @@ cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐
bool isDrop;
bool isMoveForward;
bool isSinWave;
bool IsTurn;
bool isPadding1;
bool isPadding2;
bool isPadding3;
float fTimeDelta;
float fPadding1; // 반드시 상수버퍼는 16바이트 배수로 만들어져야 한다.
@@ -74,8 +79,6 @@ void CS_MAIN(
{
if (isLoop == false)
{
return;
}
@@ -92,7 +95,7 @@ void CS_MAIN(
if (isMoveForward)
{
float4 vVelocity = vector(normalize(particleValue.vOriginLook.xyz) * particleValue.fSpeed, 1.f);
float4 vVelocity = vector(normalize(particle.vLook.xyz) * particleValue.fSpeed, 1.f);
particle.vTranslation += vVelocity * fTimeDelta;
}
@@ -107,6 +110,28 @@ void CS_MAIN(
{
particle.vTranslation += vector( sin(particle.vLifeTime.x * 3.141592 * 2.f) * particleValue.vSinAmount, 0.f);
}
if (IsTurn == true)
{
/* ROTATE */
float4x4 RotateXMat = RotateX(particleValue.vDeltaAngle.x * fTimeDelta);
float4x4 RotateYMat = RotateY(particleValue.vDeltaAngle.y * fTimeDelta);
float4x4 RotateZMat = RotateZ(particleValue.vDeltaAngle.z * fTimeDelta);
float4x4 CombinedRotMat = mul(RotateZMat, mul(RotateYMat, RotateXMat));
float4x4 CurRotatemat = {particle.vRight, particle.vUp, particle.vLook, vector(0.f , 0.f, 0.f, 1.f)};
CurRotatemat = mul(CombinedRotMat, CurRotatemat);
particle.vRight = CurRotatemat[0].xyzw;
particle.vUp = CurRotatemat[1].xyzw;
particle.vLook = CurRotatemat[2].xyzw;
}
//애니메이션 속도 , 인덱스
@@ -84,7 +84,7 @@ vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::Dispatch(_uint iSRVIndex, _uint
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource)))
{
CInstance_Model::CS_PARTICLE_VALUE_DESC* pValueDesc = static_cast<CInstance_Model::CS_PARTICLE_VALUE_DESC*>(StagingSubResource.pData);
StagingSubResources.push_back(StagingSubResource);
@@ -232,7 +232,7 @@ HRESULT CInstance_Model::Create_CS()
};
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, 2, CS_OutputStrides, CS_InputStrides);
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, 2, CS_InputStrides, CS_OutputStrides);
if (m_pComputeShader == nullptr)
return E_FAIL;
@@ -277,6 +277,7 @@ void CInstance_Model::Drop(_float fTimeDelta)
pDesc->fTimeDelta = fTimeDelta;
pDesc->isLoop = m_InstanceDesc.isLoop;
pDesc->isDrop = m_InstanceDesc.isDrop;
pDesc->isTurn = m_InstanceDesc.isTurn;
pDesc->isMoveForward = m_InstanceDesc.isMoveForward;
pDesc->isSinWave = m_InstanceDesc.isSinWave;
@@ -315,6 +316,7 @@ void CInstance_Model::Drop(_float fTimeDelta)
memcpy(ParticleValueResource.pData, OutSubResources[1].pData, sizeof(CS_PARTICLE_VALUE_DESC) * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다.
m_pContext->Unmap(m_pParticleValueBuffer, 0);
}
@@ -399,6 +401,13 @@ void CInstance_Model::Instane_Buffer_ReStruct()
pParticleValues[i].vSinAmount = vSinAmount;
_float3 vDeltaAngle = _float3(
m_pGameInstance->Random_Float(m_InstanceDesc.vDeltaAngleMin.x, m_InstanceDesc.vDeltaAngleMax.x),
m_pGameInstance->Random_Float(m_InstanceDesc.vDeltaAngleMin.y, m_InstanceDesc.vDeltaAngleMax.y),
m_pGameInstance->Random_Float(m_InstanceDesc.vDeltaAngleMin.z, m_InstanceDesc.vDeltaAngleMax.z)
);
pParticleValues[i].vDeltaAngle = vDeltaAngle;
//라이프 타임 설정
pVertices[i].vLifeTime = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vLifeTime.x, m_InstanceDesc.vLifeTime.y));
@@ -413,7 +422,6 @@ void CInstance_Model::Instane_Buffer_ReStruct()
pParticleValues[i].vAniIndex = _float2(0.f, m_InstanceDesc.vAniIndex.y);
pParticleValues[i].fGravity = m_pGameInstance->Random_Float(m_InstanceDesc.vGravity.x, m_InstanceDesc.vGravity.y);
memcpy(&pParticleValues[i].vOriginRight, SRMatrix.m[0], sizeof(_float4));
memcpy(&pParticleValues[i].vOriginUp, SRMatrix.m[1], sizeof(_float4));
memcpy(&pParticleValues[i].vOriginLook, SRMatrix.m[2], sizeof(_float4));
@@ -520,6 +528,11 @@ void CInstance_Model::Describe_Entity()
Instane_Buffer_ReStruct();
}
if (GUI::Checkbox("Turn", &m_InstanceDesc.isTurn))
{
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat3("SizeMin", reinterpret_cast<_float*>(&m_InstanceDesc.vSizeMin)))
{
Instane_Buffer_ReStruct();
@@ -611,6 +624,16 @@ void CInstance_Model::Describe_Entity()
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat3("DeltaAngleMin", reinterpret_cast<_float*>(&m_InstanceDesc.vDeltaAngleMin)))
{
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat3("DeltaAngleMax", reinterpret_cast<_float*>(&m_InstanceDesc.vDeltaAngleMax)))
{
Instane_Buffer_ReStruct();
}
ImGui::PopItemWidth();
ImGui::TreePop();
@@ -27,7 +27,7 @@ class ENGINE_DLL CComputeShader final : public CBase
HRESULT CreateComputeShader(const _tchar* pShaderFilePath, const _char* pStartFunctionName);
private:
ID3D11Device* m_pDevice = { nullptr };
ID3D11Device* m_pDevice = { nullptr };
ID3D11DeviceContext* m_pContext = { nullptr };
class CGameInstance* m_pGameInstance = { nullptr };
+20 -1
View File
@@ -32,10 +32,16 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_bool isMoveForward = {};
_float2 vGravity = { 0.f , 9.8f };
_bool isSinWave = {};
_float3 vSinMinAmount = { 0.f , 0.f , 0.f};
_float3 vSinMaxAmount = { 0.f , 0.f , 0.f };
_bool isTurn;
_float3 vDeltaAngleMin = {};
_float3 vDeltaAngleMax = {};
}INSTANCE_DESC;
typedef struct tagPreInstanceDesc
@@ -64,9 +70,15 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_bool isMoveForward = {};
_float2 vGravity = { 0.f , 9.8f };
_bool isSinWave = {};
_float3 vSinMinAmount = { 0.f , 0.f , 0.f };
_float3 vSinMaxAmount = { 0.f , 0.f , 0.f };
_bool isTurn;
_float3 vDeltaAngleMin = {};
_float3 vDeltaAngleMax = {};
}PRE_INSTANCE_DESC;
typedef struct tagCSParticleDesc
@@ -78,11 +90,17 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_int isMoveForward = {};
_int isSinWave = {};
_int isTurn = {};
_int isPadding1 = {};
_int isPadding2 = {};
_int isPadding3 = {};
_float fTimeDelta = {};
_float fPadding2 = {};
_float fPadding3 = {};
_float fPadding4 = {};
}CS_PARTICLE_DESC;
typedef struct tagCSParticleValueDesc
@@ -104,7 +122,8 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_float2 vAniIndex = {};
_float fGravity = {};
_float3 vSinAmount = {};
_float3 vSinAmount = {};
_float3 vDeltaAngle = {};
}CS_PARTICLE_VALUE_DESC;