-
Notifications
You must be signed in to change notification settings - Fork 4
Documentation
Choi edited this page Sep 24, 2021
·
9 revisions
As you can see in the diagram, input can be found on update function of app class. You can change the inputs to whatever you want just change the char characters on update function.
if (keyboard.KeyIsPressed('W'))
{
//move forward when pressed W
gfx.cam3D.AdjustPosition(gfx.cam3D.GetForwardVector() * cameraSpeed * deltaTime);
}
//You can change 'W' to 'Up Arrow' button
if (keyboard.KeyIsPressed(VK_UP))
{
//move forward when pressed Up Arrow (VK_UP)
gfx.cam3D.AdjustPosition(gfx.cam3D.GetForwardVector() * cameraSpeed * deltaTime);
}
You can reach all virtual key codes on microsoft site.
- 'W-A-S-D' for movement
- 'Left Shift' to 2x sprint
- 'F' for to 1.5x sprint
- 'Escape' to quit.
- 'H' to hide UI.
- 'V' to show UI.
- Hold 'RMB' (Right Mouse Button) to turn camera.
All objects rendering in graphics class. Also pipeline initialize and adapter reader works in graphics class. You can also check that on diagram
bool Graphics::SceneGraph(Camera3D cam3D)
{
//set depth stensil state
pContext->OMSetDepthStencilState(pDepthState.Get(), 0xFF);
pCPU.Frame();
gridMap.draw(cam3D);
dsShadow->BindTexture(pContext.Get(), 4);
//set primitive topology
pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
//Drawing Objects
pSkyBox.Draw(cam3D);
pDirectLight->BindCB(cam3D, 0);
for (int i = 0; i < pGameObjects.size(); i++)
{
pGameObjects[i]->draw(cam3D);
}
mParticle.Render(cam3D);
tessPlane.Draw(cam3D);
//set primitive topology
pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
pDirectLight->BindCB(cam3D, 5);
pPbrSphere->Draw(cam3D);
//Render to Texture
if (!*GameObject::GetWireframeEnabled())
{
pContext->OMSetRenderTargets(1u, pRtv.GetAddressOf(), nullptr);
rt->BindAsTexture(pContext.Get(), 0);
rtDepth->BindAsTexture(pContext.Get(), 1);
rtHDR->BindAsTexture(pContext.Get(), 2);
rtNoise->BindAsTexture(pContext.Get(), 3);
rtBrightness->BindAsTexture(pContext.Get(), 4);
rtBloom->BindAsTexture(pContext.Get(), 5);
rtNormal->BindAsTexture(pContext.Get(), 6);
quad->draw(pContext.Get(), cam3D);
}
return true;
}
Then SceneGraph function called from Render function in the same class.
void Graphics::Render()
{
//render docking window
RenderDockingWindow();
//Particle(s) frame
mParticle.Frame(timer.GetMilisecondsElapsed());
//Shadow map pass from light view
ID3D11RenderTargetView* rtv[1] = { 0 };
pContext->OMSetRenderTargets(1, rtv, dsShadow->pDepthStencilView.Get());
dsShadow->Clear(pContext.Get());
GameObject::SetBackCull(true);
SceneGraph(pDirectLight->GetLightCamera());
GameObject::SetBackCull(false);
//Depth pass
rtDepth->BindAsTarget(pContext.Get(), dsDepth->pDepthStencilView.Get());
float col[4] = { 0,0,0,1 };
rtDepth->Clear(pContext.Get(), col);
dsDepth->Clear(pContext.Get());
GameObject::SetDepthBufferEnabled(TRUE);
SceneGraphSSR(cam3D);
GameObject::SetDepthBufferEnabled(FALSE);
//Random noise texture render
rtNoise->BindAsTarget(pContext.Get(), dsNoise->pDepthStencilView.Get());
dsNoise->Clear(pContext.Get());
SceneGraph(cam3D);
//High dynamic range render
rtHDR->BindAsTarget(pContext.Get(), dsHDR->pDepthStencilView.Get());
rtHDR->Clear(pContext.Get(), col);
dsHDR->Clear(pContext.Get());
SceneGraph(cam3D);
//Brightness render
rtBrightness->BindAsTarget(pContext.Get(), dsBrightness->pDepthStencilView.Get());
rtBrightness->Clear(pContext.Get(), col);
dsBrightness->Clear(pContext.Get());
pDirectLight->SetBrightnessRenderEnabled(TRUE);
SceneGraph(cam3D);
pDirectLight->SetBrightnessRenderEnabled(FALSE);
//Normals render
rtNormal->BindAsTarget(pContext.Get(), dsNormal->pDepthStencilView.Get());
rtNormal->Clear(pContext.Get(), col);
dsNormal->Clear(pContext.Get());
pDirectLight->SetNormalsEnabled(TRUE);
SceneGraphSSR(cam3D);
pDirectLight->SetNormalsEnabled(FALSE);
//Bloom render
rtBloom->BindAsTarget(pContext.Get(), dsBloom->pDepthStencilView.Get());
rtBloom->Clear(pContext.Get(), col);
dsBloom->Clear(pContext.Get());
FSQuad::SetBloomRenderEnabled(true);
quad->draw(pContext.Get(), cam3D);
FSQuad::SetBloomRenderEnabled(false);
UI::SetCanRendered(true);
//Render scene as normally
rt->BindAsTarget(pContext.Get(), ds->pDepthStencilView.Get());
ds->Clear(pContext.Get());
if (*GameObject::GetWireframeEnabled())
{
pContext->OMSetRenderTargets(1u, pRtv.GetAddressOf(), pDSV.Get());
float bgColor[] = { 0.0f, 0.0f, 0.1f, 1.0f };
pContext->ClearRenderTargetView(pRtv.Get(), bgColor);
pContext->ClearDepthStencilView(pDSV.Get(), D3D11_CLEAR_DEPTH
| D3D11_CLEAR_STENCIL, 1.0f, 0);
}
SceneGraph(cam3D);
}
All user interface settings stroes in UI class. You can edit user interface settings in here. You can also check that on diagram
void UI::ToolBar(bool* gridMapEnabled, bool*
wireframeEnabled, bool* fogEnabled,
bool* depthBufferEnabled, bool* blurEnabled, bool* msaaEnabled, App* app)
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("Editor"))
{
if (ImGui::MenuItem("Grid Map"))
{
if(*gridMapEnabled)
{
*gridMapEnabled = false;
}
else
{
*gridMapEnabled = true;
}
}
}
}
}
User interface functions called from App class.
//toolbar creation
UI::ToolBar(GridMap::getRender(), GameObject::GetWireframeEnabled(), GameObject::GetFogEnabled(), GameObject::GetDepthBufferEnabled(),
GameObject::GetBlurEnabled(), &gfx.msaaEnabled, this);