diff --git a/Engine/Graphics/3DRenderer.cpp b/Engine/Graphics/3DRenderer.cpp index 83a228f..c8dabb5 100644 --- a/Engine/Graphics/3DRenderer.cpp +++ b/Engine/Graphics/3DRenderer.cpp @@ -6,7 +6,7 @@ // Rendering pipeline: // model matrix (Object SRT) -> view matrix (camera matrix inverted) -> proj matrix -> clipping -> perspective divide -> viewport transformation -> Rasterizer (draw pixels inside projected triangles on 2D screen) -// object coordinate -> world coordinate -> camera coordinate -> clip/screen coordinate +// object space -> world space -> camera space -> homogeneous clip space -> NDC space -> raster space // // Rasterizer inputs elements: // - texture-buffer (2D array of pixels color value) @@ -16,11 +16,14 @@ // Refs: // * https://en.wikipedia.org/wiki/3D_projection // * https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/overview-rasterization-algorithm.html +// * https://ktstephano.github.io/rendering/stratusgfx/aabbs +// * https://en.wikipedia.org/wiki/Clipping_(computer_graphics) +// * https://www.coranac.com/tonc/text/mode7.htm Graphic3DRenderer::Graphic3DRenderer() { if (mMainCamera == nullptr) { mMainCamera = std::make_unique(); - mMainCamera->SetPosition(0.0f, 3.0f, -20.0f); + mMainCamera->SetPosition(0.0f, 1.5f, -8.0f); mMainCamera->SetFrustrum(90.0f, 1280.f/324.f, 1.0f, 100.f); mMainCamera->UpdateCamView(); } @@ -28,17 +31,17 @@ Graphic3DRenderer::Graphic3DRenderer() { // Fill world object list to render mRenderList.clear(); mRenderList.push_back(std::make_shared()); - mRenderList.back()->SetPosition(0.f, 0.f, 50.f); - mRenderList.back()->SetScale(10.0f); + mRenderList.back()->SetPosition(0.f, 0.f, 15.f); + mRenderList.back()->SetScale(2.0f); mRenderList.push_back(std::make_shared()); - mRenderList.back()->SetPosition(24.f, 5.f, 12.f); - mRenderList.back()->SetScale(10.0f); + mRenderList.back()->SetPosition(6.f, 2.f, 2.f); + mRenderList.back()->SetScale(2.0f); mRenderList.push_back(std::make_shared()); - mRenderList.back()->SetPosition(-31.f, 16.f, 24.f); - mRenderList.back()->SetScale(10.0f); + mRenderList.back()->SetPosition(-8.f, 5.f, 10.f); + mRenderList.back()->SetScale(2.0f); mRenderList.push_back(std::make_shared()); mRenderList.back()->SetPosition(0.f, 0.f, 0.f); - mRenderList.back()->SetScale(25.0f); + mRenderList.back()->SetScale(5.0f); } Graphic3DRenderer::~Graphic3DRenderer() {}