• Home
  • About
    • 게임 개발자 유정룡 photo

      게임 개발자 유정룡

      포트폴리오

    • Learn More
    • Email
    • Github
    • Bitbucket
  • Projects
    • All Projects
    • All Tags

Direct3D11 공부 29일차(Viewport)

07 Jul 2021

Reading time ~1 minute

Rendering Pipeline

현재까지 배웠던 파이프라인을 다시 보자

IA - VS - RS - PS - OM

여기서 VS 단계에서는 World, View, Projection변환을 하고, RS단계에선s Viewport 변환을 한다.

이런 방식으로 변환을 하는데 3D공간에 좌표로 World 공간에 만들고, View, Projection에서 절두체로 변환한 뒤, Viewport에 렌더링이 된다.

렌더링 파이프라인을 통해 계산한다고 해도 우리가 사용하기 위해 리턴받기가 힘들다. 따라서 같은 수식으로 계산해서 값을 사용한다.

도대체 이걸 어디다 사용하냐?

2D위치로 계산되어야 하는 UI등을 표시하기 위해 사용한다.

Viewport는 이 전에 완료된 작업들을 어떻게 보여줄까에 관한 작업이다.

Viewport

void ViewportDemo::Render()
{
	static float width = D3D::Width();
	static float height = D3D::Height();
	static float x = 0.0f;
	static float y = 0.0f;

	ImGui::InputFloat("Width", &width, 1.0f);
	ImGui::InputFloat("Height", &height, 1.0f);
	ImGui::InputFloat("X", &x, 1.0f);
	ImGui::InputFloat("Y", &y, 1.0f);
	Context::Get()->GetViewport()->Set(width, height, x, y);

	
	static float fov = 0.25f;
	ImGui::InputFloat("Fov", &fov, 0.001f);

	static float minZ = 0.01f, maxZ = 1000.0f;
	ImGui::InputFloat("MinZ", &minZ, 0.01f);
	ImGui::InputFloat("MaxZ", &maxZ, 1000.0f);

	Perspective* perspective = Context::Get()->GetPerspective();
	perspective->Set(D3D::Width(), D3D::Height(), minZ, maxZ, Math::PI * fov);
	.
	.
	.
}

일단 width height 는 말 그대로 가로 세로 화면의 크기이다

X, Y는 보여주는 화면의 XY 좌표이다.

fov는 시야각이다.

minZ maxZ 는 최대, 최소로 보여주는 z의 값이다.



DirectX Share Tweet +1