Skip to content

Feature/postprocessing#176

Open
Anand-Ramnarain-27 wants to merge 18 commits into
mainfrom
feature/postprocessing
Open

Feature/postprocessing#176
Anand-Ramnarain-27 wants to merge 18 commits into
mainfrom
feature/postprocessing

Conversation

@Anand-Ramnarain-27

Copy link
Copy Markdown
Contributor

Post-Processing System

Implemented a fully editor-driven post-processing pipeline with runtime scripting support. All effects can be configured through the editor and controlled through the new PostProcessAPI.

Features

Exposure

Adjust the Exposure (EV) value to control scene brightness.

  • Negative values darken the image.
  • Positive values brighten the image.

This also verifies that the HDR → Tonemap → Gamma correction pipeline is functioning correctly.

Bloom

Enable Bloom and adjust:

  • Threshold – Controls which pixels contribute to bloom.
  • Intensity – Controls bloom strength.

For testing, set the threshold to approximately 0.7 and intensity to 1.0. Bright and emissive surfaces should glow and bleed into surrounding pixels.

Colour Grading (LUT)

Enable Colour Grading (LUT) and provide a .cube file path, you can download or use any cube file to test.

Example:

Assets/Textures/CUBE/Test.cube

and automatically fall back to a neutral grade.

Chromatic Aberration

Enable Chromatic Aberration and adjust CA Strength.

Higher values increase colour fringing toward the edges of the screen.

Heartbeat (Damage Effect)

Enable Heartbeat (Damage FX) and reduce the Health (test) value below 0.5.

Effects include:

  • Animated red vignette.

  • Pulsing screen effect.

  • Faster pulse rate as health decreases.

  • Critical state effects below approximately 0.25 health:

    • Additional edge darkening.
    • Subtle screen sway.

Increase Separation (test) to strengthen the blue vignette effect.

The effect updates live in the editor using unscaled time.

Death Fade

Enable Death Fade (test).

The viewport will:

  1. Desaturate and blur to greyscale over Grey Duration.
  2. Fade completely to black over Black Duration.

Disable the effect to immediately restore the scene.

Outline (Ink)

Enable Outline (Ink).

Recommended workflow:

  1. Adjust Threshold first.

    • Lower if no outlines appear.
    • Raise if too much of the screen is outlined.
  2. Tune:

    • Thickness
    • Intensity
    • Ink Colour
    • Wobble
    • Noise Scale
    • Break-up

These settings allow creation of a hand-drawn or stylized ink effect.

Scripting Support

All post-processing features are exposed through the new PostProcessAPI declared in EngineAPI.h.

Examples include:

PostProcessAPI::setExposure(...);

PostProcessAPI::setBloomEnabled(...);
PostProcessAPI::setBloomThreshold(...);
PostProcessAPI::setBloomIntensity(...);

PostProcessAPI::setLutEnabled(...);
PostProcessAPI::setLutPath(...);

PostProcessAPI::setChromaticAberrationEnabled(...);
PostProcessAPI::setChromaticAberrationStrength(...);

PostProcessAPI::setHeartbeatEnabled(...);
PostProcessAPI::setHealth(...);
PostProcessAPI::setSeparation(...);

PostProcessAPI::setDeathFadeActive(...);

PostProcessAPI::setOutlineEnabled(...);

Introduce a new HDR post-processing pipeline: adds BloomPass and PostProcessPass with supporting HLSL shaders (bloom downsample/upsample/threshold, postprocess) and a CubeLut loader for 3D LUT color grading. Integrates an HDR render target (R16G16B16A16_FLOAT) into RenderSurface and ModuleResources, updates PSOs (mesh & particles) to render to HDR, and wires bloom/LUT into ModuleRender so the scene is rendered to an HDR target, blurred, color graded and resolved to the LDR output. Also: adjust shaders to output linear HDR (LightPixelShader), simplify particle tinting, add project file entries and filters, and include editor_windows.ini. Adds helper Texture and LUT creation utilities and pipeline/root-signature setup for the new passes.
Convert the renderer to produce a linear HDR scene target and resolve it via a post-process pass. Deferred and skybox passes now render into a new SCENE_HDR attachment using DXGI_FORMAT_R16G16B16A16_FLOAT and shaders output linear HDR (tone mapping/gamma removed). ModuleResources adds createHDRRenderTexture and attaches SCENE_HDR to RenderSurface (enum expanded). PostProcessPass was refactored to implement IRenderPass, own a BloomPass, handle LUTs/dummy bloom SRV, perform resource-state transitions, and resolve exposure/tone-mapping/gamma into the COMPOSITE target. ModuleRender and SwapChain updated to create and schedule the post-process pass and to attach the HDR texture to the surface.
Set desc.DSVFormat to DXGI_FORMAT_D32_FLOAT and use the surface depth-stencil texture's DSV when calling OMSetRenderTargets in PostProcessPass so the composite pass has a proper depth-stencil view. Also remove the obsolete Engine_OUT/GameScripts_runtime_1.dll.
Introduce an explicit HDR render target and move tone mapping/gamma to the post-process pass. Pixel shader now outputs linear HDR color (no tone mapping/gamma). Added createHDRRenderTexture and attach a R16G16B16A16_FLOAT COLOR_1 target to render surfaces and the swapchain. Updated ModuleRender API to operate on RenderSurface references (renderToSurface, renderScene, wrapper calls, renderGameToBackbuffer) and made resource transitions/clears for the HDR target. PostProcessPass now reads from COLOR_1 and writes to COLOR_0. Skybox pipeline RTV format updated to R16G16B16A16_FLOAT. RenderContext now carries a RenderSurface& for passes that need access to surface textures. These changes implement an HDR pipeline where scene lighting is rendered in HDR and tone mapping/exposure/gamma are applied later in post-processing.
Introduce PostProcessCommon.{h,cpp} with shared helpers (bilinearClampSampler, createFullscreenPSO, drawFullscreenTriangle) to centralize common post-process setup. Refactor BloomPass.cpp and PostProcessPass.cpp to use these helpers (remove duplicated sampler/PSO/draw code) and update comments clarifying HDR/LDR targets. Add new sources to Engine.vcxproj and filters.
Implement heartbeat (low-health damage) and death-fade postprocess effects.

- PostProcessPass: advance time-based effects once per frame, clamp dt; add heartbeat state machine and death-fade timer; expose new PostProcessParams fields and internal state for pulse/sway/blur; update parameter packing and per-frame updates.
- PostProcessPixelShader.hlsl: extend constant buffer with heartbeat and death-fade inputs; add scene blur helper, heartbeat color/tint/darken logic, sample sway, and apply desaturation/fade to black; ensure bloom samples follow sway.
- PostProcessSettings: add editable knobs for enabling heartbeat, health threshold, runtime health/separation inputs (test-only), and death-fade durations/trigger.
- SceneConfig: add ImGui controls for heartbeat and death-fade testing (health, separation, grey/black durations).

These changes add CPU-driven heartbeat visuals (vignette, pulse, sway, desaturation) and layered death fade (blur -> grey -> black), with authorable settings and editor test UI.
Introduce a depth-driven "ink" outline in the post-process pass. Key changes:

- PostProcessPixelShader.hlsl: add depthTexture (t3), noise/hash helpers and applyOutline() which detects edges from the depth buffer and blends an ink colour. Hook outline into the final color path.
- PostProcessPass.* and ModuleResources.cpp: make depth buffer shader-visible (shaderVisibleSRV), add depth SRV to the root signature and bind it (t3). Transition the depth resource to PIXEL_SHADER_RESOURCE for the post-process, then restore it to DEPTH_WRITE and re-bind the DSV for subsequent overlay passes.
- PostProcessPass.h / PostProcessSettings.h / SceneConfig.cpp: add parameters for outline (enabled, thickness, threshold, intensity, colour, wobble, noise scale, breakup), expose them in the editor UI and propagate them into PostProcessParams.

These changes enable a tunable, depth-based outline effect while preserving correct depth state for later overlay rendering.
Introduce a new PostProcessAPI namespace in EngineAPI.h/cpp to expose runtime control of post-processing effects to code/scripts. Adds header declarations and implementations for toggling heartbeat, death fade, bloom, outline, chromatic aberration, and for setting health, separation and exposure. Includes a getSettings() helper with nullptr checks to safely access scene post-process settings. Changes affect Engine_Master_UPC/EngineAPI.h and Engine_Master_UPC/EngineAPI.cpp.
Add many new getters/setters and expand PostProcessAPI surface to expose additional tuning parameters. Refactor implementations in EngineAPI.cpp to compact inline methods with safe null checks and sensible default return values. New controls include bloom (threshold/intensity), LUT enable/path, chromatic aberration strength, heartbeat/health getters, health threshold, death fade durations, and extensive outline parameters (thickness, threshold, intensity, color, wobble, noise scale, breakup). Update EngineAPI.h to declare the new functions for scripting/API use.

@AndreuMiroSabate AndreuMiroSabate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good feature. I think the effects are really good and work very well. Also having the functions to change the values by script will let us upgrade the visuals of the game.
One thing that bothers me is that the skyboxes are brighter than before. This may cause some issues with the illumination of the levels since everything is more bright than is supposed to be. An example can be this images, where this image is supposed to be very dark, but has a bright bluish tone
For the rest good job.

Image Image

@JorxPi

JorxPi commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Good feature. I think the effects are really good and work very well. Also having the functions to change the values by script will let us upgrade the visuals of the game. One thing that bothers me is that the skyboxes are brighter than before. This may cause some issues with the illumination of the levels since everything is more bright than is supposed to be. An example can be this images, where this image is supposed to be very dark, but has a bright bluish tone For the rest good job.

Image Image

It is important that things don't change if there are no postprocess effects being applied, this is something important to look into before accepting the PR

Sample scene depth and treat pixels with depth >= 0.9999 as background. Background pixels now use a direct scene sample (saturated) and skip the blurred HDR path, bloom, exposure/tone-mapping/LUT and sRGB conversion to reduce work; non-background pixels follow the existing blurred HDR + bloom + exposure + PBR neutral tone mapping + optional LUT + LinearToSRGB flow. Preserves existing outline compositing behavior.
@Anand-Ramnarain-27

Copy link
Copy Markdown
Contributor Author

So the skybox should be darker again now, please test to make sure and check if this way is better, it just was like thaat cause tone-mapping was included for the hdr sky was it would effect the entire scene but now its changes not the skybox stays the same but only the objects within the scene get tone-mapping

@MiquelBarbara MiquelBarbara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve tested the post-processing effects and came across a few things that seemed off. First, the bloom looks like the attached image when enabled, and then there’s the depth fade, where strange artifacts appear. Otherwise, it works well. Good job.

Image Image

Add a configurable bloomClamp to post-process settings and use it to limit bloom contribution so extremely bright or Inf HDR pixels can't drive the fp16 bloom chain to Inf/NaN. Introduces bloomClamp (serialized and exposed in the UI), a BloomParams.maxBrightness field, and sets maxBrightness in BloomPass (clamped 0..8192). BloomThresholdPixelShader now clamps sampled color to maxBrightness before thresholding, and PostProcessPixelShader additionally clamps the final bloom sample to 65000.0 to sanitize any residual Inf values.
Replace the old 8-direction fixed blur with a high-quality Poisson-disc (golden-angle) sampling loop (N=64) that uses aspect-corrected offsets, radius scaling, and exponential weights; samples are clamped and the result normalized by total weight to avoid bright-pixel ghosting. Also remove/trim some obsolete comments in BloomThresholdPixelShader.hlsl and tidy minor whitespace/comments in PostProcessPixelShader.hlsl.
@Anand-Ramnarain-27

Copy link
Copy Markdown
Contributor Author

Fixed it, please check again, so now with bloom there is a clamp the lower the value will reduce the brightness/glow that was coming out and the spliting effect should also be less like particles for the fade as it bluring by pixel now should be by radius like blob of defocus

@AndreuMiroSabate AndreuMiroSabate left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The skybox now looks as it should good job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants