The rendering pipeline is designed to be:
- explicit
- modular
- editor-safe
- free of hidden render passes
1. Rendering Is Scene-Driven
In GFX-Next, rendering is not owned by GameElements.
Instead, the Scene controls the render flow.
Scene.RenderShadowMaps(Viewport, RenderDevice, Camera);
Scene.Render(Viewport, RenderDevice, Camera);
This keeps:
- draw order centralized
- render passes deterministic
- editor and runtime behavior identical
2. Camera & Viewport
Rendering always requires:
- a Camera
- a Viewport
Scene.Render(Viewport, RenderDevice, Camera);
The camera defines:
- view matrix
- projection matrix
- view position (lighting)
The viewport defines:
- render resolution
- aspect ratio
- render target dimensions
This separation allows:
- split-screen rendering
- editor viewports
- offscreen rendering
3. Render Targets
Scenes render into a render target, not directly to the backbuffer.
var renderTarget = Scene.RenderTarget as MSAARenderTarget2D;
This enables:
- MSAA
- post processing
- render-to-texture workflows
- editor previews
The backbuffer is only used for the final presentation step.
4. Shadow Rendering Pass
Shadow maps are rendered explicitly.
Scene.RenderShadowMaps(Viewport, RenderDevice, Camera);
Characteristics:
- separate depth-only pass
- light-driven
- resolution controlled per light
- no implicit shadow generation
This keeps shadow rendering:
- predictable
- debuggable
- scalable
5. Main Scene Render Pass
The main scene render pass:
- binds camera matrices
- resolves materials
- draws all visible elements
- respects transparency order
Scene.Render(Viewport, RenderDevice, Camera);
Key points:
- no per-object render logic
- no hidden state changes
- render stats are tracked centrally
6. Renderer Responsibilities
The renderer is a low-level execution layer.
renderer.DrawMesh(transform, mesh, materialOverride);
The renderer:
- binds shaders
- uploads uniforms
- issues draw calls
- never owns scene state
- never decides what to draw
This strict separation prevents:
- state leaks
- implicit behavior
- frame-order bugs
7. Post Processing Pipeline
Post processing is handled via a PostProcessStack.
_postProcessStack = new PostProcessStack();
_postProcessStack.Filter.Add(BrightnessContrastFX.Cinematic);
Post processing:
- operates on render targets
- is independent of scene rendering
- can be reordered freely
8. Applying Post Processing
Post processing is applied after the scene render pass.
_postProcessStack.Apply(RenderDevice, renderTarget.TextureId);
This produces a final render target that can be:
- drawn to the backbuffer
- used as input for further passes
- displayed in an editor viewport
9. Final Composition
The final image is presented explicitly.
RenderDevice.DrawRenderTarget(
_postProcessStack.RenderTarget,
GLRenderer.Backbuffer
);
There is no automatic fullscreen pass.
Everything is explicit.
10. UI & HUD Rendering
UI is rendered after the 3D pipeline.
HUD.Render(Viewport, RenderDevice);
RenderDevice.DrawRenderTarget(HUD.RenderTarget, GLRenderer.Backbuffer);
This guarantees:
- UI is not affected by post processing
- pixel-perfect rendering
- clear separation between 3D and 2D
11. Debugging & Render Safety
The pipeline is designed for debugging:
- render passes are explicit
- render targets are inspectable
- stats are tracked per frame
- no implicit frame graph
This makes rendering behavior:
- reproducible
- understandable
Summary
The rendering system in GFX-Next is built around:
- scene-controlled render flow
- explicit render passes
- render-target-based composition
- modular post processing
- strict separation of responsibilities
This avoids hidden complexity and keeps the rendering pipeline transparent and predictable.