Luna Engine is DirectX 11 based engine that i am trying to make.
Luna Engine is DirectX 11 based engine that i develop. Main reason why is that i want to learn more and try it all by myself
I made trello panel, so you can see what i want to do, what i already done and what i am working on atm. https://trello.com/b/T8T6vkBN/directx-11-engine-2019
Updated Main Example
Splash screen before launching main engine!
// Show splashscreen
SplashScreen::Launch(L"Engine/SplashEditor.bmp", 5 * 1000);
This line of code will create splash screen for 5 seconds from specifed image.
Deferred Renderer is now WIP!
void _DirectX::InitGameData() {
gRenderer = new RendererDeferred();
// ...
}
void _DirectX::CreateResources() {
// Create renderer's resources
gRenderer->Init();
// ...
}
bool _DirectX::Render() {
static uint gRenderFrame = 0;
// Reset counters
gDrawCallInstanceCount = 0;
gDispatchCallCount = 0;
gDrawCallCount = 0;
// Resize event
Resize();
// Bind and clear RTV
gRenderer->ClearMainRT();
// Render world
gRenderer->Render();
// Render to screen
gContext->OMSetRenderTargets(1, &gRTV, gDSV);
gRenderer->FinalScreen();
// Debug
gRenderer->DebugHUD();
gRenderer->ImGui();
// Handle present event
Present(1, 0);
// End of frame
gRenderFrame++;
return false;
}
void _DirectX::Resize() {
WindowConfig wcfg = gHighLevel.DefaultResize();
if( !wcfg.Resized ) return;
// Resize renderer
gRenderer->Resize();
// ...
}
void _DirectX::FreeResources() {
// Cleanup
gRenderer->Release();
// ...
}
void _DirectX::Unload() {
SAFE_RELEASE_RENDERER(RendererDeferred, gRenderer);
}
New 2D drawing functions
Entity Component System is now part of LunaEngine!
ECS based Scene system!
gScene->LoadModelStaticOpaque("../Models/LevelModelOBJ.obj");
gScene->MakeCameraFOVH(0, .1f, 10000.f, 1366.f, 768.f, 70.f);
gMainScene = new Scene();
gMainScene->SetAsActive(); // Bind current scene as active
New ECS based mesh system
SetLayoutGenerator(LayoutGenerator::LgMesh);
Old camera system will be deprecated soon
New camera control system WIP
// Create input controller for player camera
float fSpeed = 200.f;
MovementControlComponent lMovementControlComp{};
lMovementControlComp.mAssignedControls = {
InputControl(VK_A, GamepadButtonState::_StickL).SetValue(0.f, 0.f, -fSpeed).OrientationDependent(),
InputControl(VK_D, GamepadButtonState::_StickL).SetValue(0.f, 0.f, +fSpeed).OrientationDependent(),
InputControl(VK_W, GamepadButtonState::_StickL).SetValue(+fSpeed).OrientationDependent(),
InputControl(VK_S, GamepadButtonState::_StickL).SetValue(-fSpeed).OrientationDependent(),
InputControl(MouseButton::AxisXY).SetValue(1.f, 1.f).OrientationUpdate()
};
// Create cameras
gMainScene->MakeCameraFOVH(0, .2f, 10000.f, (float)(gRenderer->Width()), (float)(gRenderer->Height()), 70.f); // Player
gMainScene->MakeCameraFOVH(1, .2f, 10000.f, 2048.f, 2048.f, 70.f); // Sun Light camera
gMainScene->SetActiveCamera(0);
gMainScene->UpdateMadeCameras();
gMainScene->GetCamera(0)->cTransf->vPosition = float3(0.f, 10.f, 0.f);
// Add controls to main camera
gMainScene->AddComponent(gMainScene->GetActiveCameraHandle(), &lMovementControlComp);
New utils
File System (WIP)
Singleton class
TopologyState
Scoped Resource Mapping
ScopeMapConstantBuffer<Type> q(CB);
Order of operations:
{
ScopeMapConstantBuffer<DataBuffer> q(cbDataBuffer);
q.data->_InvViewProj = params.mInvViewProj;
q.data->_CameraPos = Camera::Current()->GetPosition();
q.data->_MinFadeDist2 = params.fMinFadeDist * params.fMinFadeDist;
q.data->_MaxFadeDist2 = params.fMaxFadeDist * params.fMaxFadeDist;
}
ScopeMapConstantBufferCopy<Type> q(CB, DataPtr);
Order of operations:
{
// Update CB
ScopeMapConstantBufferCopy<TransformBuff> q(cb, (void*)&this->mWorld);
}
cb->Bind(types, slot);
Same goes for ScopedMapResource
Fixed CountLines powershell script
Wrapper for ID3D11DeviceContext::Draw* & Dispatch* calls
DXDraw(UINT VertexCount, UINT StartVertexLocation);
DXDrawAuto();
DXDrawIndexed(UINT IndexCount, UINT StartIndexLocation, UINT BaseVertexLocation);
DXDrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, UINT BaseVertexLocation, UINT StartInstanceLocation);
DXDrawIndexedInstancedIndirect(ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs);
DXDrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation);
DXDrawInstancedIndirect(ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs);
DXDispatch(UINT ThreadGroupCountX, UINT ThreadGroupCountY, UINT ThreadGroupCountZ);
DXDispatchIndirect(ID3D11Buffer *pBufferForArgs, UINT AlignedByteOffsetForArgs);
// Container example
UIContainer c0(8.f, 81.f, 188.f, 256.f);
// Scrollbar example
UIScrollbar vsb(UIScrollbarType::Vertical);
// Enable RenderDoc
// Doing such - will disable DX Debug Layer messages
const bool RenderDocEnable = true;
gDirectX = gHighLevel.InitDirectX(dxCFG, RenderDocEnable);
//
void HighLevel::RenderDocCaptureBegin();
void HighLevel::RenderDocCaptureEnd();
void HighLevel::RenderDocLaunchUI();
bool HighLevel::RenderDocGetUI();
// Game tick function
void Tick(float fDeltaTime);
// Render frame
bool Render();
// Render UI; maybe soon deprecated
void ComposeUI();
// Handle resize event
void Resize();
// Game initialization
void InitGameData(); // Allocate memory for resources
void CreateResources(); // Will be runned 2nd time on device-lost event
// Desc: Create DX resources here
void PostCreateResources(bool Recreated=false);
// Game unloading
void FreeResources(); // Will be runned on device-lost/game end event
// Desc: Release DX resources here
void Unload(); // Game is already closing
void Present(UINT SyncInterval, UINT Flags); // Wrapper for IDXGISwapChain::Present();
shadertoolsconfig.json
for HLSL Tools Extension for Visual StudioFixed
When using RenderDoc you will see this:
{
ScopedRangeProfiler s1(L"Render depth buffer for directional light");
rtDepth->Bind();
rtDepth->Clear(0.f, 0, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL);
// Default is 1 ^^^
//rsFrontCull->Bind();
gContext->OMSetDepthStencilState(pDSS_Default, 1);
RenderScene(cLight, RendererFlags::DepthPass | RendererFlags::OpaquePass);
}
Didn't mentioned it in any of the prev. updates. Engine now uses inverse depth buffer. So the logic for shaders and CPU side code must consider this.
For example, depth msaa resolve function was:
[unroll(16)] // 32 - is max; 8 - max for me
for( uint i = 0; i < _SampleCount; i++ )
depth = min(depth, _In.Load(DTid.xy, i));
Now it is:
[unroll(16)] // 32 - is max; 8 - max for me
for( uint i = 0; i < _SampleCount; i++ )
depth = max(depth, _In.Load(DTid.xy, i));
Depth sampling was:
float depth = _DepthTexture.Sample(_LinearSampler, In.Texcoord);
Now:
float depth = 1.f - _DepthTexture.Sample(_LinearSampler, In.Texcoord);
Clear for depth buffer was:
rtDepth->Clear(1.f, 0, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL);
Now:
rtDepth->Clear(0.f, 0, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL);
MSAA support for RenderTargets
Deleted old RenderBuffer* classes
Created RenderTarget class
RenderTarget<
size_t dim,
size_t BufferNum,
bool DepthBuffer=false,
size_t ArraySize=1,
bool WillHaveMSAA=false,
bool Cube=false
>
x86 / x64 builds
3D Particles
2D Particles
Semi-Automated generartion of
Render Buffers
Model loading (avaliable all formats from Assimp)
2D Textures
Cube Maps
Physics Engine
Audio Engine
Text Engine
Material system
Input system
2D Drawing API (HighLevel/DirectX/Utilities.h)
What do I plan to do in the future? / What am i working on?