Programming/DirectX12
-
조명과 그림자Programming/DirectX12 2022. 4. 10. 13:21
게임에서 조명과 그림자가 없으면 굉장히 밋밋해진다. 예전에 3D게임프로그래밍을 수강 중일 때 만든 조명과 그림자를 적용시켜봤다. 조명 // scene.h struct Light { XMFLOAT4X4lightViewMatrix; XMFLOAT4X4lightProjMatrix; XMFLOAT3color; FLOATpadding1; XMFLOAT3direction; FLOATpadding2; }; struct cbScene { Light ligths[Setting::MAX_LIGHTS]; }; 졸업작품에서는 방향성 조명만 사용할 것이므로 방향과 색깔만 갖고있다. `lightViewMatrix` 와 `lightProjMatrix` 는 그림자맵을 만들 때 쓰이는 행렬이다. 또한 이 구조체는 셰이더에 상수버퍼로 ..
-
서버-클라이언트 연결Programming/DirectX12 2022. 3. 30. 00:39
졸업작품 게임은 3인이서 플레이하는 게임이다. 우선 서버-클라이언트 네트워크 관련 틀을 잡기 위해 플레이어 이동만 구현해보도록 했다. void GameFramework::OnInit(HINSTANCE hInstance, HWND hWnd) { m_hInstance = hInstance; m_hWnd = hWnd; LoadPipeline(); LoadAssets(); #ifdef NETWORK ConnectServer(); m_networkThread = thread{ &GameFramework::ProcessClient, this, reinterpret_cast(g_c_socket) }; #endif } void Scene::ProcessClient(LPVOID arg) { while (g_isConne..
-
스카이박스 구조 변경Programming/DirectX12 2022. 3. 15. 21:23
문제점 Skybox::Skybox(const array& meshes, const shared_ptr& shader, const array& textures) : m_faces{ new GameObject[6] } { // 앞, 좌, 우, 뒤, 상, 하 for (int i = 0; i < 6; ++i) { m_faces[i].SetMesh(meshes[i]); m_faces[i].SetShader(shader); m_faces[i].SetTexture(textures[i]); } } 기존에는 클래스를 하나 만들어서 6개의 사각형과 6개의 텍스쳐를 갖고 6개의 사각형을 렌더링하는 방식이였다. 하지만 현재 프레임워크 구조상 class Texture 객체를 여러개 만드는 것은 비효율적이다. 더불어 부동소수점 ..
-
애니메이션하는 객체가 여러 개일 때 발생하던 문제 해결Programming/DirectX12 2022. 3. 7. 00:29
문제점 내 프레임워크에서 렌더링 순서는 플레이어 -> 게임오브젝트이다. 애니메이션하는 객체가 여러 개있을 때 해당 메쉬를 사용하는 모든 객체가 가장 마지막에 렌더링하는 객체의 애니메이션과 같아지는 현상이 있었다. void Mesh::CreateShaderVariable(const ComPtr& device, const ComPtr& commandList) { ComPtr dummy; constexpr UINT cbMeshByteSize{ (sizeof(cbMesh) + 255) & ~255 }; m_cbMesh = CreateBufferResource(device, commandList, NULL, cbMeshByteSize, 1, D3D12_HEAP_TYPE_UPLOAD, {}, dummy); m_cb..
-
상하체 애니메이션 분리Programming/DirectX12 2022. 3. 1. 22:19
문제점 if (animationInfo->state == PLAY) // 프레임 진행 { Animation ani{}; if (parentMesh) ani = parentMesh->GetAnimations().at(animationInfo->currAnimationName); else ani = m_animations.at(animationInfo->currAnimationName); const float frame{ animationInfo->currTimer / (1.0f / 24.0f) }; const UINT currFrame{ min(static_cast(floorf(frame)), ani.length - 1) }; const UINT nextFrame{ min(static_cast(ceilf(..