[add[ 물리 이동량 시스템을 Velocity 명칭으로 전면 교체

물리 엔진의 이동량 처리 방식을 Momentum에서 Velocity 명칭으로 전환하였으며, 관련 함수 및 변수명을 일괄 변경하였습니다. CRigidBody_Dynamic, PHYSX_USERDATA 등에서 bAutoOwnerTranslation → bAutoTranslation으로 명칭을 통일하였고, 내부 구현도 이에 맞게 수정되었습니다. 쉐이더의 PBR 라이팅, 그림자 블렌딩, 앰비언트 연산 등 일부 수식과 변수명이 개선되어 가독성이 향상되었습니다. CSM 관련 파이프라인 코드가 리팩토링되었고, 엔진 프레임워크의 업데이트 루틴, 타이머, 스레드 개수 등이 최적화되었습니다. README.md의 개발 환경 및 팀원 역할도 최신화하였습니다.
This commit is contained in:
kimnuri
2026-06-20 13:52:00 +09:00
60 changed files with 281 additions and 404 deletions
@@ -109,7 +109,7 @@ HRESULT CBroomRacerAI::Initialize(void* pArg)
void CBroomRacerAI::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
}
@@ -17,11 +17,11 @@ CCamera_Model::CCamera_Model(const CCamera_Model& rhs)
void CCamera_Model::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
_float3 vCamPos = {};
_float3 vCamMomentum = {};
XMStoreFloat3(&vCamPos, m_pTransformCom->Get_State(STATE::POSITION));
XMStoreFloat3(&vCamMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat3(&vCamMomentum, m_pTransformCom->Get_CurrentVelocity());
#ifdef _DEBUG
GUI::Text("Cam_Model Coord %.2f, %.2f, %.2f", vCamPos.x, vCamPos.y, vCamPos.z);
GUI::Text("v %.2f, %.2f, %.2f", vCamPos.x, vCamPos.y, vCamPos.z);
@@ -36,7 +36,7 @@ HRESULT CEffectParts::Initialize(void* pArg)
void CEffectParts::Priority_Update(_float fTimeDelta)
{
if (m_EffectInfo.isMotionBlur == true)
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CEffectParts::Update(_float fTimeDelta)
+3 -3
View File
@@ -57,7 +57,7 @@ HRESULT CElf::Initialize(void* pArg)
void CElf::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_iEntered -= 1;
if (m_iEntered < 0) {
m_iEntered = 0;
@@ -507,7 +507,7 @@ HRESULT CElf::Ready_Components(void* pArg)
{ // DO
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::OLLIVANDER);
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_NPC_HITBOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
@@ -580,7 +580,7 @@ void CElf::Describe_Entity()
}
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
if (GUI::Button("Move To Player"))
+1 -1
View File
@@ -680,7 +680,7 @@ void CGoblin::Describe_Entity()
GUI::Text("AnimRatio %.2f", m_pModelCom->Get_CurrentTrackProgressRatio());
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_float3 Pos;
@@ -780,7 +780,7 @@ void CGoblin_Assassin::Describe_Entity()
GUI::Text("AnimRatio %.2f", m_pModelCom->Get_CurrentTrackProgressRatio());
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_float3 Pos;
@@ -375,7 +375,7 @@ HRESULT CGoblin_Assassin::Behavior_DashExitCheck(_float fTimeDelta)
_float4 RootMomentum = m_pModelCom->Get_RootBoneMomentum();
_vector RootDelta = XMLoadFloat4(&RootMomentum);
_float dashDist = XMVectorGetX(XMVector3Length(RootDelta));
m_pTransformCom->AccumulateMomentum(XMLoadFloat4(&m_vDashDir) * dashDist * 1.5f);
m_pTransformCom->AccumulateVelocity(XMLoadFloat4(&m_vDashDir) * dashDist * 1.5f);
if (fRatio >= 0.7f)
{
@@ -974,7 +974,7 @@ void CGoblin_Assassin::HitState_Behavior(_float fTimeDelta)
_float ease = 1.f - (t * t);
_vector Force = vPlayerLook * fTimeDelta * 6.f * ease;
m_pTransformCom->AccumulateMomentum(Force);
m_pTransformCom->AccumulateVelocity(Force);
pairAnimInfo = m_Animation[STATEANIM::TUMBLE];
m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 0.6f, false, 0.8f);
}
@@ -50,7 +50,7 @@ void CGoblin_BattleAxe::Priority_Update(_float fTimeDelta)
XMStoreFloat4(&m_vStartGripPos, Get_WorldPostion());
}
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pModelCom->Combined_BoneMatrix();
_matrix socketMatrix = {};
@@ -38,7 +38,7 @@ HRESULT CGoblin_Dagger::Initialize(void* pArg)
void CGoblin_Dagger::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
XMStoreFloat4(&m_vStartPos, m_pTransformCom->Get_State(STATE::POSITION));
m_pModelCom->Combined_BoneMatrix();
if (m_bAttach)
@@ -563,7 +563,7 @@ void CGoblin_Mage::Describe_Entity()
GUI::Text("AnimRatio %.2f", m_pModelCom->Get_CurrentTrackProgressRatio());
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_float3 Pos;
@@ -859,7 +859,7 @@ void CGoblin_Mage::HitState_Behavior(_float fTimeDelta)
_float ease = 1.f - (t * t);
_vector Force = vPlayerLook * fTimeDelta * 6.f * ease;
m_pTransformCom->AccumulateMomentum(Force);
m_pTransformCom->AccumulateVelocity(Force);
pairAnimInfo = m_Animation[STATEANIM::TUMBLE];
m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 0.6f, false, 0.8f);
}
@@ -313,7 +313,7 @@ HRESULT CGoblin::Behavior_SwingExitCheck(_float fTimeDelta)
vDistance = XMVector4Normalize(vDistance);
_float step = dist - fDesiredRange;
m_pTransformCom->AccumulateMomentum(vDistance * step * fTimeDelta * 2.f);
m_pTransformCom->AccumulateVelocity(vDistance * step * fTimeDelta * 2.f);
}
}
@@ -938,7 +938,7 @@ void CGoblin::HitState_Behavior(_float fTimeDelta)
_float ease = 1.f - (t * t);
_vector Force = vPlayerLook * fTimeDelta * 6.f * ease;
m_pTransformCom->AccumulateMomentum(Force);
m_pTransformCom->AccumulateVelocity(Force);
pairAnimInfo = m_Animation[STATEANIM::TUMBLE];
m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second, 0.6f, false, 0.8f);
}
@@ -39,7 +39,7 @@ HRESULT CGoblin_Sword::Initialize(void* pArg)
void CGoblin_Sword::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pModelCom->Combined_BoneMatrix();
XMStoreFloat4(&m_vStartPos, m_pTransformCom->Get_State(STATE::POSITION));
@@ -81,7 +81,7 @@ HRESULT CHuman_Duelist::Initialize(void* pArg)
void CHuman_Duelist::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
@@ -641,7 +641,7 @@ void CHuman_Duelist::Describe_Entity()
}
m_pCharacter_Controller->Describe_Entity();
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_char label[256];
for (auto& iter : m_KeyFrames)
@@ -31,7 +31,7 @@ void CInfoInstance::Update(_float fTimeDelta)
m_pInteractiveInfo->Update(fTimeDelta);
m_pEffectInfo->Update(fTimeDelta);
m_pCutSceneInfo->Update(fTimeDelta);
}
}
void CInfoInstance::Change_Level()
{
@@ -41,7 +41,6 @@ void CInfoInstance::Change_Level()
m_pSkillInfo->Change_Level();
m_pInteractiveInfo->Change_Level();
m_pEffectInfo->Change_Level();
// UI_Event.clear();
m_pCutSceneInfo->Clear_AllEvents();
}
@@ -166,40 +166,6 @@ HRESULT CLevel_GamePlay::Initialize()
void CLevel_GamePlay::Update(_float fTimeDelta)
{
_bool bStartCinematic = { true };
#ifdef _DEBUG
#ifdef 기무리
bStartCinematic = false;
#elif 진우
bStartCinematic = true;
#elif Bin
bStartCinematic = false;
#elif gimch
bStartCinematic = true;
#elif 나
bStartCinematic = false;
#endif
#endif // _DEBUG
#ifdef RELEASE_DEBUGGER
if (m_pGameInstance->Key_Down(DIK_F5)) {
m_pGameInstance->Toggle_RenderCollider();
}
#endif
if (bStartCinematic && false == m_bIntroCinematic) {
m_bIntroCinematic = true;
bStartCinematic = false;
_string strCutSceneName = "CarriageIntro";
m_pInfoInstance->Active_Event(strCutSceneName);
}
if (m_pGameInstance->Key_Pressing(DIK_0)) {
if (m_pGameInstance->Key_Up(DIK_1))
{
m_pGameInstance->Set_LevelToChange();
}
}
m_pInfoInstance->Update(fTimeDelta);
if (true == m_pGameInstance->Check_LevelShouldChange()) {
@@ -208,7 +174,9 @@ void CLevel_GamePlay::Update(_float fTimeDelta)
UI_STATE eState = UI_STATE::LEVELCHANGE;
m_pInfoInstance->Event_CallBack(TEXT("Canvas_Change"), &eState);
if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::FIELD)))) {
if (FAILED(m_pGameInstance->Change_Level(
CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::FIELD)
))) {
return;
}
}
@@ -236,7 +236,7 @@ HRESULT CMapElement_Chest::Ready_Components(void* pArg)
// RIGID_BODY
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::BOX);
Desc.bAutoOwnerTranslation = true;
Desc.bAutoTranslation = true;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_HIDDEN_BOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
@@ -179,7 +179,7 @@ HRESULT CMapElement_Door::Ready_Components(void* pArg)
{ // RIGID_BODY
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::DOOR);
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_DOOR"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
+1 -1
View File
@@ -34,7 +34,7 @@ HRESULT CMonster::Initialize(void* pArg)
void CMonster::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
}
@@ -51,7 +51,7 @@ HRESULT CNPC_EleazarFig::Initialize(void* pArg)
void CNPC_EleazarFig::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_iEntered -= 1;
if (m_iEntered < 0) {
m_iEntered = 0;
@@ -304,7 +304,7 @@ HRESULT CNPC_EleazarFig::Ready_Components(void* pArg)
{ // DO
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::ELEAZARFIG);
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_NPC_HITBOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
@@ -21,7 +21,7 @@ CNPC_Ollivander::CNPC_Ollivander(const CNPC_Ollivander& Prototype)
void CNPC_Ollivander::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_iEntered -= 1;
if (m_iEntered < 0) {
m_iEntered = 0;
@@ -314,7 +314,7 @@ HRESULT CNPC_Ollivander::Ready_Components(void* pArg)
{ // DO
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::OLLIVANDER);
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_NPC_HITBOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
@@ -33,12 +33,12 @@ HRESULT CPhysXEffectHitBox::Initialize(void* pArg)
void CPhysXEffectHitBox::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CPhysXEffectHitBox::Update(_float fTimeDelta)
{
m_pTransformCom->AccumulateMomentum(XMLoadFloat3(&m_vDeltaPos));
m_pTransformCom->AccumulateVelocity(XMLoadFloat3(&m_vDeltaPos));
}
void CPhysXEffectHitBox::Late_Update(_float fTimeDelta)
@@ -49,6 +49,7 @@ void CPhysXEffectHitBox::Late_Update(_float fTimeDelta)
if (m_pGameInstance->IsIn_WorldFrustum(Get_WorldPostion(), m_pTransformCom->Get_Radius())) {
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
}
Set_Shadow(m_pGameInstance->IsIn_ShadowViewFrustum(m_pTransformCom->Get_State(STATE::POSITION), m_pTransformCom->Get_Radius()));
}
HRESULT CPhysXEffectHitBox::Render()
+3 -3
View File
@@ -141,7 +141,7 @@ void CPlayer::Priority_Update(_float fTimeDelta)
{
ReLockOnTarget();
SetGravity();
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
@@ -576,7 +576,7 @@ void CPlayer::Trigger(CTimeSocket& Socket)
m_pTransformCom->Set_State(STATE::POSITION, vNewPos);
m_pCharacter_Controller->Set_Position(vNewPos);
m_pTransformCom->RotationQ(pContents->pxTransform.q);
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
} break;
case TIMESOCKET_FUNC::TRANSLATION_LERP:
{
@@ -1196,7 +1196,7 @@ void CPlayer::Describe_Entity()
m_pCharacter_Controller->Describe_Entity();
GUI::Checkbox("Battle", &m_bDuel_ZOnlyMove);
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_char label[256];
for (auto& iter : m_KeyFrames)
@@ -596,7 +596,7 @@ HRESULT CPlayer::Behavior_MoveExitCheck(_float fTimeDelta)
}
_vector vLook = m_pTransformCom->Get_State(STATE::LOOK);
vLook = XMVector3Normalize(vLook);
m_pTransformCom->AccumulateMomentum(vLook *fTimeDelta *0.8f);
m_pTransformCom->AccumulateVelocity(vLook *fTimeDelta *0.8f);
}
else if (SUCCEEDED(InputMove())) {
m_fMoveTime += fTimeDelta;
+2 -2
View File
@@ -59,7 +59,7 @@ void CRandomNpc::Priority_Update(_float fTimeDelta)
if (!m_pGameInstance->IsIn_WorldFrustum(m_pTransformCom->Get_State(STATE::POSITION), m_pTransformCom->Get_Radius())) {
return;
}
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_iEntered -= 1;
if (m_iEntered < 0) {
m_iEntered = 0;
@@ -448,7 +448,7 @@ HRESULT CRandomNpc::Ready_Components(void* pArg)
{ // DO
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::OLLIVANDER);
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_NPC_HITBOX"), (CComponent**)&m_pRigidBody, &Desc))) {
return E_FAIL;
}
+1 -1
View File
@@ -787,7 +787,7 @@ HRESULT CRanrok::Ready_SubParts()
m_pRanrokCombinedBoneMatrices[ENUM_CLASS(RANROK_ENUM_BONEMATRICES::TAIL2)] = m_pTail2_BoneMat = m_pModelCom->Get_BoneMatrixPtr("tail_12");
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.bAutoOwnerTranslation = false;
Desc.bAutoTranslation = false;
Desc.iSubKind = ENUM_CLASS(PXOBJECT::RANROK_BODY);
for (_uint i = 0; i < ENUM_CLASS(RANROK_ENUM_BONEMATRICES::END); ++i) {
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_RANROK_BODY"), (CComponent**)&m_pTargetableDO[i], &Desc))) {
@@ -803,7 +803,7 @@ HRESULT CRanrok::Behavior_RushExitCheck(_float fTimeDelta)
vLook = XMVector3Normalize(vLook);
_vector vPos = m_pCharacter_Controller->Get_Position();
_vector vNextPos = vPos + vLook * 10.f * fTimeDelta;
m_pTransformCom->AccumulateMomentum(vLook * 10.f * fTimeDelta);
m_pTransformCom->AccumulateVelocity(vLook * 10.f * fTimeDelta);
return S_OK;
}
+1 -1
View File
@@ -52,7 +52,7 @@ HRESULT CTerrain::Initialize(void* pArg)
void CTerrain::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CTerrain::Update(_float fTimeDelta)
@@ -55,7 +55,7 @@ HRESULT CTroll_Weapon::Initialize(void* pArg)
void CTroll_Weapon::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pModelCom->Combined_BoneMatrix();
_matrix socketMatrix = {};
+1 -1
View File
@@ -44,7 +44,7 @@ HRESULT CWand::Initialize(void* pArg)
void CWand::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pModelCom->Combined_BoneMatrix();
#ifdef _DEBUG
Describe_Entity();
@@ -137,22 +137,8 @@ float2 UV_Cutting(float2 vUV, float2 vUVCutting, uint iCurrentFrame)
//}
// (Kd F(Lambert)) + (Ks F(cook-torrance))
//float LambertDiffuse(float c)
//{
// return c / PI;
//}
// F(cook-torrance)
// DFG / (4 (Wo dot N) (Wi dot N))
// D(distribution, NormalDistribution function), 표면의 거칠기에 영향을 받는 halfWay vector
// G(Geometry, GeometryFunc), 에너지 보존법칙 적용
// F(Fresnel-Fresnel equation), 표면 각도에 따른 반사율
// F->D
float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha) // NormalDistributionGGXTR, (H, halfWay vector), (A, Roughness), (N, Normal)
float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha)
{
float a2 = fAlpha * fAlpha;
float NdotH = saturate(dot(vNormal, vHalfWayVector));
@@ -166,28 +152,14 @@ float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha) // NormalDi
}
// F->G
// GschlickGGX(n, v, k)
// k는 이하 두개 조명 조건에 따라 가변적임
// Direct // Kdir -> ((a + 1) * (a + 1)) / 8 // direct lighting 추천
// IBL Lighting // Kibl -> a * a / 2 // 이미지 기반 조명기법
float Geometry_SchlickGGX(float NdotV, float fK)
float Geometry_SchlickGGX(float NdotV, float fk)
{
return NdotV / (NdotV * (1.0f - fK) + fK);
return NdotV / (NdotV * (1.0f - fk) + fk);
}
float Geometry_Smith(float3 vNormal, float3 vFromView, float3 vFromLight, float k)
float Geometry_Smith(float3 vNormal, float NdotV, float NdotL, float fk)
{
// Geometry Obstruction
// 철이 있는, 주로 튀어나온 장애물
float NdotV = saturate(dot(vNormal, vFromView));
// Geometry Shadowing
// 요가 있는, 주로 음푹 들어간 장애물 (그래서 셰도잉)
float NdotL = saturate(dot(vNormal, vFromLight));
// 요철이 골고루 있다고 가정하고 적당히 섞음
return Geometry_SchlickGGX(NdotV, k) * Geometry_SchlickGGX(NdotL, k);
return Geometry_SchlickGGX(NdotV, fk) * Geometry_SchlickGGX(NdotL, fk);
}
// F -> F
@@ -217,16 +189,17 @@ PBR_LIGHT_OUT PBR_Lighting(
return Out;
}
float fAlpha = max(fRoughness * fRoughness, 0.04f);
float k = ((fRoughness + 1.f) * (fRoughness + 1.f)) / 8.f;
float r = max(fRoughness, 0.046);
float fAlpha = r * r;
float k = ((r + 1.f) * (r + 1.f)) / 8.f;
float D = NDF_ggxtr(vNormal, vHalfVector, fAlpha);
float G = Geometry_Smith(vNormal, vToView, vToLight, k);
float G = Geometry_Smith(vNormal, NdotV, NdotL, k);
float3 F = Fresnel_Schlick(saturate(dot(vHalfVector, vToView)), vFO);
float3 vNumerator = D * G * F;
float3 vNominator = D * G * F;
float fDenominator = max(4.f * NdotL * NdotV, 1e-7);
float3 specularBRDF = vNumerator / fDenominator;
float3 specularBRDF = vNominator / fDenominator;
float3 kS = F;
float3 kD = (1.f - kS) * (1.f -fMetallic);
@@ -101,6 +101,7 @@ vector g_vFogColor;
float g_fDepthPackExponent;
Texture3D g_VolumeTexture;
float g_fCascadeBlendRatio = 0.02f;
float g_fWeights_32[32] =
{
@@ -224,8 +225,8 @@ struct PS_OUT_DEBUG_MOTIONBLUR
};
struct PS_OUT_LIGHT
{
vector vShade : SV_TARGET0;
vector vSpecular : SV_TARGET1;
float4 vShade : SV_TARGET0;
float4 vSpecular : SV_TARGET1;
};
struct PS_OUT_FLT4_SINGLE
{
@@ -457,10 +458,10 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
float2 uv = In.vTexcoord;
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
float fViewZ = vDepth.y * g_fFar;
@@ -482,8 +483,8 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
float fAttenuation = 1.f;
float fCameraDistance = length(g_vCamPosition.xyz - vWorldPosition.xyz);
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀에서 카메라로
float3 vToLight = normalize(-g_vLightDir.xyz); // 픽셀에서 라이트로
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀 -> 카메라
float3 vToLight = normalize(-g_vLightDir.xyz); // 픽셀 -> 라이트
if (g_bUsePhongShader)
{
@@ -492,8 +493,15 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
float3 vDiffuse = g_vLightDiffuse.rgb * vAlbedo * NdotL;
float3 vAmbient = fSSAO_AmbientOcclusion * g_vLightAmbient.rgb * g_vMtrlAmbient.rgb * vAlbedo;
Out.vShade = float4(vDiffuse + vAmbient, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f), 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
@@ -502,16 +510,15 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
{ // 수치조정 // 디렉셔널
float fMinRoughness = 0.05f;
fRoughness = max(fRoughness, fMinRoughness); // 러프니스 최소값 보장
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness); // 거리기반 러프니스 ( 대충 멀수록 반짝반짝한건 더 뭉개져서 표현 )
vF0 = min(vF0, 0.9f); // 메탈릭 상한선
fRoughness = max(fRoughness, fMinRoughness);
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness);
vF0 = min(vF0, 0.9f);
}
PBR_LIGHT_OUT PBR_Out = PBR_Lighting(vNormal, vToView, vToLight, vAlbedo, fMetallic, fRoughness, g_vLightDiffuse.rgb, g_fLightIntensity, fAttenuation, vF0);
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vAmbient = g_vLightAmbient.rgb * vAlbedo * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
@@ -578,8 +585,12 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
Out.vShade = float4(g_vLightDiffuse.rgb * vAlbedo * NdotL * fAttenuation, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f) * fAttenuation, 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
@@ -597,11 +608,9 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
Out.vShade = float4(vFinalDiffuse, 1.f);
Out.vShade = float4(PBR_Out.vShade, 1.f);
Out.vSpecular = float4(vFinalSpecular, 0.f);
return Out;
@@ -679,15 +688,19 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
Out.vShade = float4(g_vLightDiffuse.rgb * vAlbedo * NdotL * fAttenuation, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f) * fAttenuation, 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
{ // 수치조정 // 점광원
{ // 수치조정 // 스포트
float fMinRoughness = 0.05f;
fRoughness = max(fRoughness, fMinRoughness); // 러프니스 최소값 보장
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness); // 거리기반 러프니스 ( 대충 멀수록 반짝반짝한건 더 뭉개져서 표현 )
@@ -698,11 +711,9 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
Out.vShade = float4(vFinalDiffuse, 1.f);
Out.vShade = float4(PBR_Out.vShade, 1.f);
Out.vSpecular = float4(vFinalSpecular, 0.f);
return Out;
@@ -794,12 +805,12 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
vPosition = mul(vPosition, g_invmatProj);
vPosition = mul(vPosition, g_invMatView);
vPreShadowPosition = vPosition;
/* (로컬위치 * 월드) -> (로컬위치 * 월드 * 광원의 뷰 * 광원의 투영 ) */
float4 vNearShadowPos = vPosition;
float4 vMiddleShadowPos = vPosition;
float4 vFarShadowPos = vPosition;
vPreShadowPosition = vPosition;
{
vNearShadowPos = mul(vNearShadowPos, g_LightViewMatrix_NEAR);
vNearShadowPos = mul(vNearShadowPos, g_LightProjMatrix_NEAR);
@@ -813,46 +824,22 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
/* 광원의 NDC에서 샘플링 */
float fVisibility_Dynamic_Near = ShadowVisibility_hwPCF(g_ShadowNearTexture, vNearShadowPos, g_vNearShadowResolution, g_vShadowBias.x, g_vShadowRadiusTexel.x);
float fVisibility_Dynamic_Middle = ShadowVisibility_hwPCF(g_ShadowMiddleTexture, vMiddleShadowPos, g_vMiddleShadowResolution, g_vShadowBias.y, g_vShadowRadiusTexel.y);
float fVisibility_Static = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, g_vPreShadowResolution, g_vShadowBias.w, g_vShadowRadiusTexel.w);
float fVisibilityStatic = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, g_vPreShadowResolution, g_vShadowBias.w, g_vShadowRadiusTexel.w);
////////////////////////////
// 케스케이드
float fDepthRatio = saturate(vDepthDesc.y);
// 경계 블렌딩 폭. 경계 섞는 비중
float fShadowCascadeBlendWidthRatio = 0.02f; // 2% 섞음
float fCascadeBlend_Front = smoothstep(
g_fCascadeSplitRatioNear - g_fCascadeBlendRatio,
g_fCascadeSplitRatioNear + g_fCascadeBlendRatio, fDepthRatio);
// 경계 주변 부드럽게 할 비중
float fCascadeBlend_NearToMiddle = smoothstep(g_fCascadeSplitRatioNear - fShadowCascadeBlendWidthRatio,
g_fCascadeSplitRatioNear + fShadowCascadeBlendWidthRatio, fDepthRatio);
//float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
//g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
// Near -> Middle
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_NearToMiddle);
// 1번째 방법
//Dynamic - > Static
//부드럽게 전환
float g_fStaticShadowBlendWidthRatio = 0.05f;
float fStaticShadowBlendEndRatio = min(1.0f, g_fCascadeSplitRatioFar + g_fStaticShadowBlendWidthRatio);
float fStaticShadowBlendWeight = smoothstep(
g_fCascadeSplitRatioFar,
fStaticShadowBlendEndRatio,
fDepthRatio
);
float fStaticAdjusted = lerp(1.0f, fVisibility_Static, fStaticShadowBlendWeight);
float fVisibilityCombined = fVisibilityDynamic * fStaticAdjusted;
// 2번째 방법
// Dynamic * Static 항상 최소곱
//float fVisibilityCombined = saturate(fVisibilityDynamic * fVisibility_Static);
g_fCascadeSplitRatioFar - g_fCascadeBlendRatio,
g_fCascadeSplitRatioFar + g_fCascadeBlendRatio, fDepthRatio);
// 3번째 방법
// Dynamic , Static 최소값만 취함
//float fVisibilityCombined = min(fVisibilityDynamic, fVisibility_Static);
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_Front);
fVisibilityStatic = lerp(1.0f, fVisibilityStatic, fStaticShadowBlendWeight);
float fVisibilityCombined = fVisibilityDynamic * fVisibilityStatic;
// 최소 밝기
float fShadowMultiplier = lerp(g_fMinShadowBrightness, 1.0f, saturate(fVisibilityCombined));
@@ -40,12 +40,12 @@ void CCallBack_Playable_HitReport::onShapeHit(const PSX::PxControllerShapeHit& h
{
case 23: // 무거운데 올라갈 수 있는 벽
if (m_pGameInstance->Key_Pressing(DIK_E)) {
pOwnerActorData->pOwner->Get_Component<CTransform>()->BookMomentum(fLength * XMVectorSet(0.f, 1.5f, 0.f, 0.f));
pOwnerActorData->pOwner->Get_Component<CTransform>()->BookVelocity(fLength * XMVectorSet(0.f, 1.5f, 0.f, 0.f));
}
else if (m_pGameInstance->Key_Pressing(DIK_R)) {
pOwnerActorData->pOwner->Get_Component<CTransform>()->BookMomentum(fLength * XMVectorSet(0.f, -1.f, 0.f, 0.f));
pOwnerActorData->pOwner->Get_Component<CTransform>()->BookVelocity(fLength * XMVectorSet(0.f, -1.f, 0.f, 0.f));
}
//pOwnerActorData->pOwner->Get_Component<CTransform>()->BookMomentum(XMVectorSet(0.f, 0.5f * GRAVITY, 0.f, 0.f));
//pOwnerActorData->pOwner->Get_Component<CTransform>()->BookVelocity(XMVectorSet(0.f, 0.5f * GRAVITY, 0.f, 0.f));
break;
case 24: // 문짝
{
@@ -39,7 +39,7 @@ HRESULT CDummyObject::Initialize(void* pArg)
void CDummyObject::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CDummyObject::Update(_float fTimeDelta)
@@ -34,12 +34,12 @@ HRESULT CDummy_PhysXEffectHitBox::Initialize(void* pArg)
void CDummy_PhysXEffectHitBox::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CDummy_PhysXEffectHitBox::Update(_float fTimeDelta)
{
m_pTransformCom->AccumulateMomentum(XMLoadFloat3(&m_vDeltaPos));
m_pTransformCom->AccumulateVelocity(XMLoadFloat3(&m_vDeltaPos));
}
void CDummy_PhysXEffectHitBox::Late_Update(_float fTimeDelta)
@@ -16,7 +16,7 @@ CDummy_PhysXMonster::CDummy_PhysXMonster(const CDummy_PhysXMonster& rhs) :
void CDummy_PhysXMonster::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position());
}
@@ -26,16 +26,16 @@ void CDummy_PhysXMonster::Update(_float fTimeDelta)
GUI::Text("%f %f", m_vStunTimer.x, m_vStunTimer.y);
if (true == m_pCharacter_Controller->IsActive()) {
if (m_pGameInstance->Key_Pressing(DIK_UPARROW)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, 1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, 0.f, 1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_LEFT)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(-1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(-1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_DOWN)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, -1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, 0.f, -1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_RIGHT)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
m_pCharacter_Controller->Move(fTimeDelta);
m_vStunTimer.x = 0.f;
@@ -21,30 +21,30 @@ CDummy_PhysXPlayable::CDummy_PhysXPlayable(const CDummy_PhysXPlayable& rhs):
void CDummy_PhysXPlayable::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position());
}
void CDummy_PhysXPlayable::Update(_float fTimeDelta)
{
if (m_pGameInstance->Key_Pressing(DIK_UPARROW)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, 1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, 0.f, 1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_LEFT)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(-1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(-1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_DOWN)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, -1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, 0.f, -1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_RIGHT)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_LCONTROL)) {
if (m_pGameInstance->Key_Pressing(DIK_SPACE)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, 10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Pressing(DIK_C)) {
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, -10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta);
}
if (m_pGameInstance->Key_Down(DIK_V)) {
m_pGameInstance->Detach_Actor(*m_pCharacter_Controller->Get_Actor(), m_pGameInstance->Get_CurrentLevelID());
@@ -56,7 +56,7 @@ void CDummy_PhysXPlayable::Update(_float fTimeDelta)
}
}
m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f));
m_pTransformCom->AccumulateVelocity(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f));
m_pCharacter_Controller->Move(fTimeDelta);
}
@@ -43,7 +43,7 @@ HRESULT CEditEffect::Initialize(void* pArg)
void CEditEffect::Priority_Update(_float fTimeDelta)
{
if(m_EffectInfo.isMotionBlur == true)
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
}
void CEditEffect::Update(_float fTimeDelta)
+1 -1
View File
@@ -476,7 +476,7 @@ void CGoblin::Describe_Entity()
GUI::Text("AnimRatio %.2f", m_pModelCom->Get_CurrentTrackProgressRatio());
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_float3 Pos;
@@ -210,7 +210,7 @@ HRESULT CGoblin::Behavior_SwingExitCheck(_float fTimeDelta)
vDistance = XMVector4Normalize(vDistance);
_float step = dist - fDesiredRange;
m_pTransformCom->AccumulateMomentum(vDistance * step * fTimeDelta * 1.5f);
m_pTransformCom->AccumulateVelocity(vDistance * step * fTimeDelta * 1.5f);
}
}
@@ -67,7 +67,6 @@ void CLevel_Logo::Update(_float fTimeDelta)
if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::EFFECT))))
return;
#endif // 진우
}
HRESULT CLevel_Logo::Render()
+1 -1
View File
@@ -34,7 +34,7 @@ HRESULT CMonster::Initialize(void* pArg)
void CMonster::Priority_Update(_float fTimeDelta)
{
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
}
+2 -2
View File
@@ -117,7 +117,7 @@ void CPlayer::Priority_Update(_float fTimeDelta)
ReLockOnTarget();
if (m_pCharacter_Controller->Get_GravityAmount() > 0.f)
SetGravity();
m_pTransformCom->RewindMomentum();
m_pTransformCom->ResetVelocityVector();
__super::Priority_Update(fTimeDelta);
@@ -530,7 +530,7 @@ void CPlayer::Describe_Entity()
}
_float4 vMomentum = {};
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentMomentum());
XMStoreFloat4(&vMomentum, m_pTransformCom->Get_CurrentVelocity());
GUI::Text("%.2f %.2f %.2f %.2f ", vMomentum.x, vMomentum.y, vMomentum.z, vMomentum.w);
_char label[256];
for (auto& iter : m_KeyFrames)
@@ -137,22 +137,8 @@ float2 UV_Cutting(float2 vUV, float2 vUVCutting, uint iCurrentFrame)
//}
// (Kd F(Lambert)) + (Ks F(cook-torrance))
//float LambertDiffuse(float c)
//{
// return c / PI;
//}
// F(cook-torrance)
// DFG / (4 (Wo dot N) (Wi dot N))
// D(distribution, NormalDistribution function), 표면의 거칠기에 영향을 받는 halfWay vector
// G(Geometry, GeometryFunc), 에너지 보존법칙 적용
// F(Fresnel-Fresnel equation), 표면 각도에 따른 반사율
// F->D
float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha) // NormalDistributionGGXTR, (H, halfWay vector), (A, Roughness), (N, Normal)
float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha)
{
float a2 = fAlpha * fAlpha;
float NdotH = saturate(dot(vNormal, vHalfWayVector));
@@ -166,28 +152,14 @@ float NDF_ggxtr(float3 vNormal, float3 vHalfWayVector, float fAlpha) // NormalDi
}
// F->G
// GschlickGGX(n, v, k)
// k는 이하 두개 조명 조건에 따라 가변적임
// Direct // Kdir -> ((a + 1) * (a + 1)) / 8 // direct lighting 추천
// IBL Lighting // Kibl -> a * a / 2 // 이미지 기반 조명기법
float Geometry_SchlickGGX(float NdotV, float fK)
float Geometry_SchlickGGX(float NdotV, float fk)
{
return NdotV / (NdotV * (1.0f - fK) + fK);
return NdotV / (NdotV * (1.0f - fk) + fk);
}
float Geometry_Smith(float3 vNormal, float3 vFromView, float3 vFromLight, float k)
float Geometry_Smith(float3 vNormal, float NdotV, float NdotL, float fk)
{
// Geometry Obstruction
// 철이 있는, 주로 튀어나온 장애물
float NdotV = saturate(dot(vNormal, vFromView));
// Geometry Shadowing
// 요가 있는, 주로 음푹 들어간 장애물 (그래서 셰도잉)
float NdotL = saturate(dot(vNormal, vFromLight));
// 요철이 골고루 있다고 가정하고 적당히 섞음
return Geometry_SchlickGGX(NdotV, k) * Geometry_SchlickGGX(NdotL, k);
return Geometry_SchlickGGX(NdotV, fk) * Geometry_SchlickGGX(NdotL, fk);
}
// F -> F
@@ -217,16 +189,17 @@ PBR_LIGHT_OUT PBR_Lighting(
return Out;
}
float fAlpha = max(fRoughness * fRoughness, 0.04f);
float k = ((fRoughness + 1.f) * (fRoughness + 1.f)) / 8.f;
float r = max(fRoughness, 0.046);
float fAlpha = r * r;
float k = ((r + 1.f) * (r + 1.f)) / 8.f;
float D = NDF_ggxtr(vNormal, vHalfVector, fAlpha);
float G = Geometry_Smith(vNormal, vToView, vToLight, k);
float G = Geometry_Smith(vNormal, NdotV, NdotL, k);
float3 F = Fresnel_Schlick(saturate(dot(vHalfVector, vToView)), vFO);
float3 vNumerator = D * G * F;
float3 vNominator = D * G * F;
float fDenominator = max(4.f * NdotL * NdotV, 1e-7);
float3 specularBRDF = vNumerator / fDenominator;
float3 specularBRDF = vNominator / fDenominator;
float3 kS = F;
float3 kD = (1.f - kS) * (1.f -fMetallic);
@@ -101,6 +101,7 @@ vector g_vFogColor;
float g_fDepthPackExponent;
Texture3D g_VolumeTexture;
float g_fCascadeBlendRatio = 0.02f;
float g_fWeights_32[32] =
{
@@ -224,8 +225,8 @@ struct PS_OUT_DEBUG_MOTIONBLUR
};
struct PS_OUT_LIGHT
{
vector vShade : SV_TARGET0;
vector vSpecular : SV_TARGET1;
float4 vShade : SV_TARGET0;
float4 vSpecular : SV_TARGET1;
};
struct PS_OUT_FLT4_SINGLE
{
@@ -457,10 +458,10 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
float2 uv = In.vTexcoord;
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
float3 vAlbedo = g_DiffuseTexture.Sample(DefaultSampler, uv).rgb;
float3 vNormal = normalize(g_NormalTexture.Sample(DefaultSampler, uv).xyz * 2.f - 1.f);
float4 vDepth = g_DepthTexture.Sample(DefaultSampler, uv);
float fSSAO_AmbientOcclusion = g_SSAOInputTexture.Sample(DefaultSampler, uv).r;
float fViewZ = vDepth.y * g_fFar;
@@ -482,8 +483,8 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
float fAttenuation = 1.f;
float fCameraDistance = length(g_vCamPosition.xyz - vWorldPosition.xyz);
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀에서 카메라로
float3 vToLight = normalize(-g_vLightDir.xyz); // 픽셀에서 라이트로
float3 vToView = normalize(g_vCamPosition.xyz - vWorldPosition.xyz); // 픽셀 -> 카메라
float3 vToLight = normalize(-g_vLightDir.xyz); // 픽셀 -> 라이트
if (g_bUsePhongShader)
{
@@ -492,8 +493,15 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
float3 vDiffuse = g_vLightDiffuse.rgb * vAlbedo * NdotL;
float3 vAmbient = fSSAO_AmbientOcclusion * g_vLightAmbient.rgb * g_vMtrlAmbient.rgb * vAlbedo;
Out.vShade = float4(vDiffuse + vAmbient, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f), 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
@@ -502,16 +510,15 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In)
{ // 수치조정 // 디렉셔널
float fMinRoughness = 0.05f;
fRoughness = max(fRoughness, fMinRoughness); // 러프니스 최소값 보장
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness); // 거리기반 러프니스 ( 대충 멀수록 반짝반짝한건 더 뭉개져서 표현 )
vF0 = min(vF0, 0.9f); // 메탈릭 상한선
fRoughness = max(fRoughness, fMinRoughness);
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness);
vF0 = min(vF0, 0.9f);
}
PBR_LIGHT_OUT PBR_Out = PBR_Lighting(vNormal, vToView, vToLight, vAlbedo, fMetallic, fRoughness, g_vLightDiffuse.rgb, g_fLightIntensity, fAttenuation, vF0);
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vAmbient = g_vLightAmbient.rgb * vAlbedo * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
@@ -578,8 +585,12 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
Out.vShade = float4(g_vLightDiffuse.rgb * vAlbedo * NdotL * fAttenuation, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f) * fAttenuation, 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
@@ -597,11 +608,9 @@ PS_OUT_LIGHT PS_MAIN_POINT(PS_IN In)
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
Out.vShade = float4(vFinalDiffuse, 1.f);
Out.vShade = float4(PBR_Out.vShade, 1.f);
Out.vSpecular = float4(vFinalSpecular, 0.f);
return Out;
@@ -679,15 +688,19 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
if (false == CalcLighting(g_SurfaceTexture, vDepth.b, uv, vAlbedo, vF0, fMetallic, fRoughness, fOcclusion, fAttenuation))
{
Out.vShade = g_vLightDiffuse * saturate(max(dot(normalize(g_vLightDir.xyz) * -1.f, vNormal), 0.f) + (fSSAO_AmbientOcclusion * g_vLightAmbient * g_vMtrlAmbient));
Out.vSpecular = (g_vLightSpecular * g_vMtrlSpecular) * pow(max(dot(vToView * -1.f, vToLight), 0.f), 50.f);
float NdotL = saturate(dot(vNormal, vToLight));
float3 vHalf = normalize(vToView + vToLight);
float NdotH = saturate(dot(vNormal, vHalf));
Out.vShade = float4(g_vLightDiffuse.rgb * vAlbedo * NdotL * fAttenuation, 1.f);
Out.vSpecular = float4((g_vLightSpecular.rgb * g_vMtrlSpecular.rgb) * pow(NdotH, 50.f) * fAttenuation, 0.f);
Out.vSpecular.a = 0.f;
return Out;
}
float fTotalOcclusion = saturate(fOcclusion * fSSAO_AmbientOcclusion);
{ // 수치조정 // 점광원
{ // 수치조정 // 스포트
float fMinRoughness = 0.05f;
fRoughness = max(fRoughness, fMinRoughness); // 러프니스 최소값 보장
fRoughness = saturate(saturate(fCameraDistance * 0.01f) * 0.1f + fRoughness); // 거리기반 러프니스 ( 대충 멀수록 반짝반짝한건 더 뭉개져서 표현 )
@@ -698,11 +711,9 @@ PS_OUT_LIGHT PS_MAIN_SPOT(PS_IN In)
PBR_Out.vShade *= fTotalOcclusion;
float3 vAmbient = g_vLightAmbient.rgb * fTotalOcclusion * fAttenuation;
float3 vFinalDiffuse = PBR_Out.vShade + vAmbient;
float3 vFinalSpecular = clamp(PBR_Out.vSpecular, 0.f, g_fLightSpecularMaximum) * g_vLightSpecular.rgb;
Out.vShade = float4(vFinalDiffuse, 1.f);
Out.vShade = float4(PBR_Out.vShade, 1.f);
Out.vSpecular = float4(vFinalSpecular, 0.f);
return Out;
@@ -794,12 +805,12 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
vPosition = mul(vPosition, g_invmatProj);
vPosition = mul(vPosition, g_invMatView);
vPreShadowPosition = vPosition;
/* (로컬위치 * 월드) -> (로컬위치 * 월드 * 광원의 뷰 * 광원의 투영 ) */
float4 vNearShadowPos = vPosition;
float4 vMiddleShadowPos = vPosition;
float4 vFarShadowPos = vPosition;
vPreShadowPosition = vPosition;
{
vNearShadowPos = mul(vNearShadowPos, g_LightViewMatrix_NEAR);
vNearShadowPos = mul(vNearShadowPos, g_LightProjMatrix_NEAR);
@@ -813,46 +824,22 @@ PS_OUT_BACKBUFFER PS_MAIN_COMBINED(PS_IN In)
/* 광원의 NDC에서 샘플링 */
float fVisibility_Dynamic_Near = ShadowVisibility_hwPCF(g_ShadowNearTexture, vNearShadowPos, g_vNearShadowResolution, g_vShadowBias.x, g_vShadowRadiusTexel.x);
float fVisibility_Dynamic_Middle = ShadowVisibility_hwPCF(g_ShadowMiddleTexture, vMiddleShadowPos, g_vMiddleShadowResolution, g_vShadowBias.y, g_vShadowRadiusTexel.y);
float fVisibility_Static = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, g_vPreShadowResolution, g_vShadowBias.w, g_vShadowRadiusTexel.w);
float fVisibilityStatic = ShadowVisibility_hwPCF(g_PreShadowTexture, vPreShadowPosition, g_vPreShadowResolution, g_vShadowBias.w, g_vShadowRadiusTexel.w);
////////////////////////////
// 케스케이드
float fDepthRatio = saturate(vDepthDesc.y);
// 경계 블렌딩 폭. 경계 섞는 비중
float fShadowCascadeBlendWidthRatio = 0.02f; // 2% 섞음
float fCascadeBlend_Front = smoothstep(
g_fCascadeSplitRatioNear - g_fCascadeBlendRatio,
g_fCascadeSplitRatioNear + g_fCascadeBlendRatio, fDepthRatio);
// 경계 주변 부드럽게 할 비중
float fCascadeBlend_NearToMiddle = smoothstep(g_fCascadeSplitRatioNear - fShadowCascadeBlendWidthRatio,
g_fCascadeSplitRatioNear + fShadowCascadeBlendWidthRatio, fDepthRatio);
//float fCascadeBlend_MiddleToFar = smoothstep(g_fCascadeSplitRatioFar - fShadowCascadeBlendWidthRatio,
//g_fCascadeSplitRatioFar + fShadowCascadeBlendWidthRatio, fDepthRatio);
// Near -> Middle
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_NearToMiddle);
// 1번째 방법
//Dynamic - > Static
//부드럽게 전환
float g_fStaticShadowBlendWidthRatio = 0.05f;
float fStaticShadowBlendEndRatio = min(1.0f, g_fCascadeSplitRatioFar + g_fStaticShadowBlendWidthRatio);
float fStaticShadowBlendWeight = smoothstep(
g_fCascadeSplitRatioFar,
fStaticShadowBlendEndRatio,
fDepthRatio
);
float fStaticAdjusted = lerp(1.0f, fVisibility_Static, fStaticShadowBlendWeight);
float fVisibilityCombined = fVisibilityDynamic * fStaticAdjusted;
// 2번째 방법
// Dynamic * Static 항상 최소곱
//float fVisibilityCombined = saturate(fVisibilityDynamic * fVisibility_Static);
g_fCascadeSplitRatioFar - g_fCascadeBlendRatio,
g_fCascadeSplitRatioFar + g_fCascadeBlendRatio, fDepthRatio);
// 3번째 방법
// Dynamic , Static 최소값만 취함
//float fVisibilityCombined = min(fVisibilityDynamic, fVisibility_Static);
float fVisibilityDynamic = lerp(fVisibility_Dynamic_Near, fVisibility_Dynamic_Middle, fCascadeBlend_Front);
fVisibilityStatic = lerp(1.0f, fVisibilityStatic, fStaticShadowBlendWeight);
float fVisibilityCombined = fVisibilityDynamic * fVisibilityStatic;
// 최소 밝기
float fShadowMultiplier = lerp(g_fMinShadowBrightness, 1.0f, saturate(fVisibilityCombined));
@@ -262,9 +262,9 @@ _bool CCharacter_Controller::UpdateGroundByCast(_float fTimeDelta)
_float fDistanceFromGround = XMVectorGetX(XMVector3Dot(vFootToHitPos, vSurfaceNormal));
_float fDotUpNormal = (fabsf(fDotUp) < FLT_EPSILON) ? FLT_EPSILON: fDotUp;
_float fCurrentMomentumY = (-fDistanceFromGround / fDotUpNormal) * 0.3f;
_vector vCurrentMomentum = m_pTransform->Get_CurrentMomentum();
_vector vCurrentMomentum = m_pTransform->Get_CurrentVelocity();
m_pTransform->Set_CurrentMomentum( XMVectorSetY(vCurrentMomentum, fCurrentMomentumY) );
m_pTransform->Set_CurrentVelocity( XMVectorSetY(vCurrentMomentum, fCurrentMomentumY) );
Set_OnGroundFlag(true);
if (m_fCurrentSlopeDegree < m_fWalkableSlopeDegree * 0.5f) {
m_bSlide = false;
@@ -292,17 +292,17 @@ void CCharacter_Controller::Move(_float fTimeDelta)
const PSX::PxObstacleContext* pPxObstacles = { nullptr }; // 캐릭터가 충돌해야할 추가적인 장애물 객체?, 닿은 장애물은 캐시된다?
if (true == m_bGravity) {
if (0 >= m_iIsOnGround) { // 공중: 무조건 중력
m_pTransform->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * m_fGravity * fTimeDelta, 0.f, 0.f));
m_pTransform->AccumulateVelocity(XMVectorSet(0.f, -GRAVITY * m_fGravity * fTimeDelta, 0.f, 0.f));
}
else if ((iCoyote_Counter) >= m_iIsOnGround) {
UpdateGroundByCast(fTimeDelta);// 바닥에 플레이어 붙이게 함
}
else if (m_fCurrentSlopeDegree > m_fWalkableSlopeDegree) { // 너무 가파른 경사: 중력
m_pTransform->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f));
m_pTransform->AccumulateVelocity(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f));
m_bSlide = true;
}
}
XMStoreFloat3((_float3*)&pxVecMomentum, m_pTransform->Get_CurrentMomentum());
XMStoreFloat3((_float3*)&pxVecMomentum, m_pTransform->Get_CurrentVelocity());
m_eBeforeCollisionFlags = m_pController->move(pxVecMomentum, fMinimumDistant, fTimeDelta, pxFilter, pPxObstacles);
}
+12 -16
View File
@@ -61,7 +61,7 @@ HRESULT CGameInstance::Initialize_Engine(const ENGINE_DESC& EngineDesc, ID3D11De
#endif // _DEBUG
#ifndef _DEBUG
m_pThreadHolder = CThreadHolder::Create(12);
m_pThreadHolder = CThreadHolder::Create(8);
#endif // !_DEBUG
if (nullptr == m_pThreadHolder) {
@@ -149,21 +149,15 @@ void CGameInstance::Update_Engine(_float fTimeDelta)
m_pKey_Manager->Update();
m_pMouse_Manager->Update();
m_pSound_Manager->Update();
m_pPicking->Update();
m_pObject_Manager->Priority_Update(fExcuteTimeDelta);
m_pPipeLine->Update();
m_pObject_Manager->Update(fExcuteTimeDelta);
m_pPhysX_Manager->Update(fExcuteTimeDelta);
m_pObject_Manager->Late_Update(fExcuteTimeDelta);
m_pVolumetric->Dispatch();
m_pLevel_Manager->Update(fExcuteTimeDelta);
m_pObject_Manager->Clear_DeadObj();
}
@@ -352,15 +346,16 @@ void CGameInstance::Compute_TimeDelta(const _wstring& strTimerTag)
void CGameInstance::Compute_FrameCount()
{
m_fTimer_PriorityUpdate = Get_TimeDelta(TEXT("Timer_PriorityUpdate"));
m_fTimer_Update = Get_TimeDelta(TEXT("Timer_Update"));
m_fTimer_LateUpdate = Get_TimeDelta(TEXT("Timer_LateUpdate"));
m_fTimer_DrawCall = Get_TimeDelta(TEXT("Timer_DrawCall"));
m_fTimer_Present = Get_TimeDelta(TEXT("Timer_Present"));
m_fTimer_Picking = Get_TimeDelta(TEXT("Timer_Picking"));
m_fTimer_PhysX = Get_TimeDelta(TEXT("Timer_PhysX"));
m_fTimer_Level = Get_TimeDelta(TEXT("Timer_Level"));
m_fTimer_FrameCount = Get_TimeDelta(TEXT("Timer_FrameCount"));
#ifdef _DEBUG
m_fTimer_PriorityUpdate = Get_TimeDelta(TEXT("Timer_PriorityUpdate"));
m_fTimer_Update = Get_TimeDelta(TEXT("Timer_Update"));
m_fTimer_LateUpdate = Get_TimeDelta(TEXT("Timer_LateUpdate"));
m_fTimer_DrawCall = Get_TimeDelta(TEXT("Timer_DrawCall"));
m_fTimer_Present = Get_TimeDelta(TEXT("Timer_Present"));
m_fTimer_Picking = Get_TimeDelta(TEXT("Timer_Picking"));
m_fTimer_PhysX = Get_TimeDelta(TEXT("Timer_PhysX"));
m_fTimer_Level = Get_TimeDelta(TEXT("Timer_Level"));
m_fTimer_FrameCount = Get_TimeDelta(TEXT("Timer_FrameCount"));
m_fTimer_Render_Priority = Get_TimeDelta(TEXT("Timer_Render_Priority"));
m_fTimer_Render_Shadow = Get_TimeDelta(TEXT("Timer_Render_Shadow"));
@@ -382,6 +377,7 @@ void CGameInstance::Compute_FrameCount()
m_fTimer_Render_Tone_Mapping = Get_TimeDelta(TEXT("Timer_Render_Tone_Mapping"));
m_fTimer_Render_UI = Get_TimeDelta(TEXT("Timer_Render_UI"));
m_fTimer_Render_UI_Overley = Get_TimeDelta(TEXT("Timer_Render_UI_Overley"));
#endif // _DEBUG
}
void CGameInstance::Present_TimeCost()
+1 -1
View File
@@ -575,7 +575,7 @@ void CModel::Update_RootBone(_float Amount)
vDeltaWorld = XMVectorSetW(vDeltaWorld, 1.f);
if (m_bRootBone) {
m_pTransform->AccumulateMomentum(vDeltaWorld);
m_pTransform->AccumulateVelocity(vDeltaWorld);
}
else {
XMStoreFloat4(&m_RootBoneMomentum, vDeltaWorld);
@@ -207,7 +207,7 @@ void CMouse_Manager::Describe_Entity()
GUI::Begin("SYSTEM", 0, IMGUI_GLOBAL_BEGIN_FLAG);
GUI::PushItemWidth(IMGUI_GLOBAL_ITEM_WIDTH);
if (GUI::CollapsingHeader("Mouse_Manager")) {
GUI::Text("AccumulateMomentum %.2f, %.2f", m_vMove.x, m_vMove.y);
GUI::Text("AccumulateVelocity %.2f, %.2f", m_vMove.x, m_vMove.y);
GUI::Text("CurPos %d, %d", m_ptCurrentMouseCur.x, m_ptCurrentMouseCur.y);
GUI::Text("Lock %d", m_bLockMouseToCenter);
POINT pt = Get_MouseViewPortPos();
@@ -488,20 +488,17 @@ void CPhysX_Manager::Update_Kinematic()
continue;
}
PHYSX_USERDATA* pUserData = (PHYSX_USERDATA*)pBody->userData;
if (false == pUserData->bAutoOwnerTranslation) {
continue; // 유닛의 상태에 따라 Continue 혹은 Apply 분기
if (false == pUserData->bAutoTranslation) {
continue;
}
const CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
pActor->setKinematicTarget(XMWorldToPx_NoScaleNoFlip(pTransform->Get_XMWorldMatrix()));
}
}
}
{ // 해제된 액터 처리
_uint iCurrentLevel = m_pGameInstance->Get_CurrentLevelID();
for (list<PSX::PxActor*>::iterator ReleasedActor = ReleasedList.begin(); ReleasedActor != ReleasedList.end();) {
Detach_Actor(*(*ReleasedActor), iCurrentLevel);
ReleasedActor = ReleasedList.erase(ReleasedActor);
}
for (auto iterActor = ReleasedList.begin(); iterActor != ReleasedList.end();) {
Detach_Actor(*(*iterActor), m_pGameInstance->Get_CurrentLevelID());
iterActor = ReleasedList.erase(iterActor);
}
}
@@ -521,7 +518,6 @@ void CPhysX_Manager::Update(_float fTimeDelta)
}
{ // Post
Update_Dynamic_ActiveActors();
//Update_Dynamic_AllActors();
}
m_pGameInstance->Compute_TimeDelta(TEXT("Timer_PhysX"));
}
@@ -540,8 +536,8 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
ReleasedList.emplace_back(ppActiveActors[i]);
continue;
}
if (false == pUserData->bAutoOwnerTranslation) {
continue; // 유닛의 상태에 따라 Continue 혹은 Apply 분기
if (false == pUserData->bAutoTranslation) {
continue;
}
CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
@@ -549,16 +545,14 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
_float3 vOriginalScale = pTransform->Get_Scale();
_matrix WorldMatrix = {};
WorldMatrix = XMMatrixAffineTransformation(XMLoadFloat3(&vOriginalScale), XMVectorZero(), XMLoadFloat4((_float4*)&pPxTransform.q), XMLoadFloat3((_float3*)&pPxTransform.p));
WorldMatrix = XMMatrixAffineTransformation(XMLoadFloat3(&vOriginalScale), XMVectorZero(),
XMLoadFloat4((_float4*)&pPxTransform.q), XMLoadFloat3((_float3*)&pPxTransform.p));
pTransform->Set_WorldMatrix(WorldMatrix);
}
}
{ // 해제된 액터 처리
_uint iCurrentLevel = m_pGameInstance->Get_CurrentLevelID();
for (list<PSX::PxActor*>::iterator ReleasedActor = ReleasedList.begin(); ReleasedActor != ReleasedList.end();) {
Detach_Actor(*(*ReleasedActor), iCurrentLevel);
ReleasedActor = ReleasedList.erase(ReleasedActor);
}
for (auto iterActor = ReleasedList.begin(); iterActor != ReleasedList.end();) {
Detach_Actor(*(*iterActor), m_pGameInstance->Get_CurrentLevelID());
iterActor = ReleasedList.erase(iterActor);
}
}
+19 -19
View File
@@ -361,10 +361,10 @@ void CPipeLine::Make_LightBoxes()
_matrix ViewInvMatrix = XMMatrixInverse(nullptr, ViewMatrix);
// Cascaded Shadow Map (3단계: Near / Middle / Far)
for (_uint iIndex = 0; iIndex < 3; ++iIndex)
for (_uint iCSMIndex = 0; iCSMIndex < 3; ++iCSMIndex)
{
_float4 vCascadePoints8[8] = {};
Get_CascadePoints8(m_vShadowViewPoints, iIndex, vCascadePoints8);
Get_CascadePoints8(m_vShadowViewPoints, iCSMIndex, vCascadePoints8);
// AABB 초기값 설정 (첫 번째 점 기준)
_float fMinX = vCascadePoints8[0].x;
@@ -387,12 +387,6 @@ void CPipeLine::Make_LightBoxes()
fMaxZ = max(fMaxZ, vCascadePoints8[iPointIndex].z);
}
// 각 Cascade 별로 결과를 저장할 Plane 배열 선택
_float4* targetPlanes = nullptr;
if (iIndex == 0) targetPlanes = m_vNearShadowViewBoxPlane;
if (iIndex == 1) targetPlanes = m_vMiddleShadowViewBoxPlane;
if (iIndex == 2) targetPlanes = m_vFarShadowViewBoxPlane;
// Shadow Box 여유 공간 추가 (Shadow clipping 방지 / 안정성 확보)
fMinX += m_vShadowMarginMin.x;
fMaxX += m_vShadowMarginMax.x;
@@ -404,7 +398,7 @@ void CPipeLine::Make_LightBoxes()
// Cascade 별 Shadow Map 해상도 설정
_uint iShadowWidth = { 0 };
_uint iShadowHeight = { 0 };
switch (iIndex)
switch (iCSMIndex)
{
case 0:
iShadowWidth = g_iNearShadowWidth;
@@ -424,25 +418,31 @@ void CPipeLine::Make_LightBoxes()
Adjust_ShadowTexcel(fMinX, fMinY, fMaxX, fMaxY, iShadowWidth, iShadowHeight);
// 각 Cascade 별로 결과를 저장할 Plane 배열 선택
_float4* pTargetPlanes = nullptr;
if (iCSMIndex == 0) pTargetPlanes = m_vNearShadowViewBoxPlane;
if (iCSMIndex == 1) pTargetPlanes = m_vMiddleShadowViewBoxPlane;
if (iCSMIndex == 2) pTargetPlanes = m_vFarShadowViewBoxPlane;
// Light-Space AABB를 Plane 형태로 변환 (Frustum 형태)
// 물체는 그대로 World 좌표 사용
// Plane vs Bounding Volume 테스트만 수행
targetPlanes[0] = _float4(-1.f, 0.f, 0.f, fMinX); // Left
targetPlanes[1] = _float4(1.f, 0.f, 0.f, -fMaxX); // Right
targetPlanes[2] = _float4(0.f, -1.f, 0.f, fMinY); // Bottom
targetPlanes[3] = _float4(0.f, 1.f, 0.f, -fMaxY); // Top
targetPlanes[4] = _float4(0.f, 0.f, -1.f, fMinZ); // Near
targetPlanes[5] = _float4(0.f, 0.f, 1.f, -fMaxZ); // Far
pTargetPlanes[0] = _float4(-1.f, 0.f, 0.f, fMinX); // Left
pTargetPlanes[1] = _float4(1.f, 0.f, 0.f, -fMaxX); // Right
pTargetPlanes[2] = _float4(0.f, -1.f, 0.f, fMinY); // Bottom
pTargetPlanes[3] = _float4(0.f, 1.f, 0.f, -fMaxY); // Top
pTargetPlanes[4] = _float4(0.f, 0.f, -1.f, fMinZ); // Near
pTargetPlanes[5] = _float4(0.f, 0.f, 1.f, -fMaxZ); // Far
// Orthographic Projection 생성 Off-Center 방식 사용
_matrix ProjMatrix = XMMatrixOrthographicOffCenterLH(fMinX, fMaxX, fMinY, fMaxY, fMinZ, fMaxZ);
// Light View / View Inverse 저장
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW)], ViewMatrix);
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::VIEW_INV)], ViewInvMatrix);
XMStoreFloat4x4(&m_ShadowTransformMatrices[iCSMIndex][ENUM_CLASS(D3DTS::VIEW)], ViewMatrix);
XMStoreFloat4x4(&m_ShadowTransformMatrices[iCSMIndex][ENUM_CLASS(D3DTS::VIEW_INV)], ViewInvMatrix);
// Light Projection / Projection Inverse 저장
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ)], ProjMatrix);
XMStoreFloat4x4(&m_ShadowTransformMatrices[iIndex][ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, ProjMatrix));
XMStoreFloat4x4(&m_ShadowTransformMatrices[iCSMIndex][ENUM_CLASS(D3DTS::PROJ)], ProjMatrix);
XMStoreFloat4x4(&m_ShadowTransformMatrices[iCSMIndex][ENUM_CLASS(D3DTS::PROJ_INV)], XMMatrixInverse(nullptr, ProjMatrix));
}
}
@@ -394,7 +394,7 @@ HRESULT CRigidBody_Dynamic::Initialize(void* pArg)
m_tagData.pOwner = m_pOwner;
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
m_tagData.pBody = this;
m_tagData.bAutoOwnerTranslation = pDesc->bAutoOwnerTranslation;
m_tagData.bAutoTranslation = pDesc->bAutoTranslation;
m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this, m_pGameInstance->Get_NextLevelID());
m_pRigidBody->setCMassLocalPose(m_PxMassCenter);
m_pRigidBody->setRigidDynamicLockFlags(m_eLockFlag);
+14 -14
View File
@@ -276,32 +276,32 @@ void CTransform::Translation(_fvector vTrans)
Set_State(STATE::POSITION, Get_State(STATE::POSITION) + XMVectorSetW(vTrans, 0.f));
}
void CTransform::AccumulateMomentum(_fvector vMomentum)
void CTransform::AccumulateVelocity(_fvector vVelocity)
{
XMStoreFloat3(&m_vMomentum, (XMLoadFloat3(&m_vMomentum) + XMVectorSetW(vMomentum, 0.f)));
XMStoreFloat3(&m_vVelocityVector, (XMLoadFloat3(&m_vVelocityVector) + XMVectorSetW(vVelocity, 0.f)));
}
_vector CTransform::Get_CurrentMomentum() const
void CTransform::ResetVelocityVector()
{
return XMLoadFloat3(&m_vMomentum); // 누적값 읽기
m_vVelocityVector = m_vBackVelocityVector;
m_vBackVelocityVector = { 0.f, 0.f, 0.f };
m_PrevMatrix = m_WorldMatrix;
}
void CTransform::Set_CurrentMomentum(_fvector vMomentum)
_vector CTransform::Get_CurrentVelocity() const
{
XMStoreFloat3(&m_vMomentum, vMomentum);
return XMLoadFloat3(&m_vVelocityVector);
}
_vector CTransform::Get_EstimatedPositionByMomentum() const
void CTransform::Set_CurrentVelocity(_fvector vVelocity)
{
return XMVectorSetW(Get_State(STATE::POSITION) + XMLoadFloat3(&m_vMomentum), 1.f);
XMStoreFloat3(&m_vVelocityVector, vVelocity);
}
void CTransform::RewindMomentum()
_vector CTransform::Get_EstimatedPositionByVelocityVector() const
{
m_vMomentum = m_vDeferredTranslation;
m_vDeferredTranslation = { 0.f, 0.f, 0.f };
m_PrevMatrix = m_WorldMatrix; // Velocity Buffer를 위한 PrevMatrix
return XMVectorSetW(Get_State(STATE::POSITION) + XMLoadFloat3(&m_vVelocityVector), 1.f);
}
void CTransform::BookMomentum(_fvector vMomentum)
void CTransform::BookVelocity(_fvector vVelocity)
{
XMStoreFloat3(&m_vDeferredTranslation, (XMLoadFloat3(&m_vDeferredTranslation) + XMVectorSetW(vMomentum, 0.f)));
XMStoreFloat3(&m_vBackVelocityVector, (XMLoadFloat3(&m_vBackVelocityVector) + XMVectorSetW(vVelocity, 0.f)));
}
void CTransform::Turn(_fvector vAxis, _float fTimeDelta)
@@ -1560,7 +1560,7 @@ static void DemoWindowWidgetsDragAndDrop()
};
static int mode = 0;
if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine();
if (ImGui::RadioButton("AccumulateMomentum", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
if (ImGui::RadioButton("AccumulateVelocity", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine();
if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; }
static const char* names[9] =
{
@@ -1584,7 +1584,7 @@ static void DemoWindowWidgetsDragAndDrop()
// Display preview (could be anything, e.g. when dragging an image we could decide to display
// the filename and a small preview of the image, etc.)
if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); }
if (mode == Mode_Move) { ImGui::Text("AccumulateMomentum %s", names[n]); }
if (mode == Mode_Move) { ImGui::Text("AccumulateVelocity %s", names[n]); }
if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); }
ImGui::EndDragDropSource();
}
+8 -8
View File
@@ -128,14 +128,6 @@ enum class PHYSX_KIND {
OBSTACLEActor,
};
enum class PHYSX_JOINT {
D6,
DISTANCE,
REVOLUTE,
FIXED,
END
};
enum class PXOBJECT : _uint {
#pragma region NOT_DEFINE
NOT_DEFINE = 0,
@@ -240,6 +232,14 @@ enum class PXOBJECT : _uint {
END = 999
};
enum class PHYSX_JOINT {
D6,
DISTANCE,
REVOLUTE,
FIXED,
END
};
enum class HIT_TYPE
{
HIT_NONE = 0, // 히트모션 없음
+1 -1
View File
@@ -24,7 +24,7 @@
//#ifdef 기무리
//#define DEBUG_MOTIONBLUR
#define DEBUG_SSAO
//#define DEBUG_SSAO
//#define DEBUG_SHADOW
//#define DEBUG_CAMERAS
//#endif // 기무리
@@ -376,7 +376,7 @@ typedef struct tagVertexInstance_UIDesc
typedef struct tagPHYSX_USERDATA {
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
_bool bAutoOwnerTranslation = true;
_bool bAutoTranslation = true;
class CGameObject* pOwner = { nullptr };
_float4x4 BeforeMatrix = { };
@@ -19,7 +19,7 @@ class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody
typedef struct tagRigidBody_DYNAMIC_Desc : public CRigidBody::RIGIDBODY_DESC
{
_bool bAutoOwnerTranslation = true;
_bool bAutoTranslation = true;
}RIGIDBODY_DYNAMIC_DESC;
private:
@@ -62,8 +62,8 @@ class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody
_vector Get_Position();
void Set_Position(_vector vPos, _bool bTeleport);
void Set_Rotation(_vector vRotQ, _bool bTeleport);
void Set_AutoOwnerTranlation(_bool bAutoOwnerTranslation) { m_tagData.bAutoOwnerTranslation = bAutoOwnerTranslation; };
_bool Get_AutoOwnerTranlation() { return m_tagData.bAutoOwnerTranslation; };
void Set_AutoOwnerTranlation(_bool bAutoTranslation) { m_tagData.bAutoTranslation = bAutoTranslation; };
_bool Get_AutoOwnerTranlation() { return m_tagData.bAutoTranslation; };
void Set_Transform(_matrix WorldMatrix, _bool bTeleport);
void Set_Transform(_vector vPos, _vector vRotQ, _bool bTeleport);
+8 -8
View File
@@ -63,13 +63,13 @@ class ENGINE_DLL CTransform final :
void Translation(_float3& vTrans);
void Translation(_fvector vTrans);
void AccumulateMomentum(_fvector vMomentum);
_vector Get_CurrentMomentum() const;
void Set_CurrentMomentum(_fvector vMomentum);
void RewindMomentum();
void AccumulateVelocity(_fvector vVelocity);
_vector Get_CurrentVelocity() const;
void Set_CurrentVelocity(_fvector vVelocity);
void ResetVelocityVector();
_vector Get_EstimatedPositionByMomentum() const;
void BookMomentum(_fvector vMomentum);
_vector Get_EstimatedPositionByVelocityVector() const;
void BookVelocity(_fvector vVelocity);
void Turn(_fvector vAxis, _float fTimeDelta);
void TurnAngle(_float4 vAxis, _float fAngle);
@@ -103,8 +103,8 @@ class ENGINE_DLL CTransform final :
_float4x4 m_PrevMatrix = {};
_float m_fRadius = { 20.f };
_float3 m_vMomentum = {}; // 현재 프레임에 계산된 이동량
_float3 m_vDeferredTranslation = {}; // 다음 프레임에 계산될 이동량
_float3 m_vVelocityVector = {}; // 현재 프레임에 계산된 이동량
_float3 m_vBackVelocityVector = {}; // 다음 프레임에 계산될 이동량
#ifdef RELEASE_DEBUGGER
_float3 m_vRotation = {0.f, 0.f, 0.f};
+5 -5
View File
@@ -9,7 +9,7 @@
## 개발 환경
- **플랫폼**: Windows 10
- **언어**: C++14
- **언어**: C++17
- **그래픽 API**: DirectX 11
- **셰이더**: HLSL (Shader Model fx 5.0)
- **엔진**: 자체 개발
@@ -18,8 +18,8 @@
---
## 파트
- **김누리**:
- **김진우**:
- **배진호**:
- **김누리**: 팀장, 메인프레임워크, 기본 쉐이더, PhysX, 카메라
- **김진우**: 이펙트 프레임워크
- **배진호**: 맵툴, 최적화
- **백인혁**: UI
- **정현빈**:
- **정현빈**: 캐릭터 상호작용, FSM