Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Shaders/Borderlands 2 and The Pre-Sequel/Includes/GameCBuffers.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ namespace CB
// vanilla no-op. SMAA metrics are passed via a dedicated CB at b1, not here.
struct LumaGameSettings
{
float Exposure; // 1 = vanilla. Scene exposure multiplier, scene-referred / pre-grade.
float Saturation; // 1 = vanilla. Oklab saturation multiplier on the final HDR color.
float HighlightDechroma; // 0 = off (only the mandatory DICE/gamut desat applies); higher = bright sources fade to white sooner.
float BloomIntensity; // 1 = vanilla. Scales the game's bloom contribution in the scene mix.
float Contrast; // 1 = vanilla. Slope contrast around 18% mid-gray on the final HDR color.
float VignetteIntensity; // 1 = vanilla. Scales the game's vignette darkening (0 = no vignette).
float LumaBloomEnable; // 0/1. 1 = composite Luma HDR pyramidal bloom (t5 BL2 / t8 TPS, additive); 0 = vanilla game bloom (t1).
float DOFRadius; // Luma Gaussian DoF strength (half-res blur extent, full-res px @ 4K).
float DOFType; // DoF path: 0 = vanilla game DoF, 2 = Luma separable Gaussian (t7 pre-blurred).
float Dithering; // 0/1 toggle. Animated triangular dither at output (HDR only) to break gradient banding.
float Exposure; // 1 = vanilla. Scene exposure multiplier, scene-referred / pre-grade.
float Saturation; // 1 = vanilla. Oklab saturation multiplier on the final HDR color.
float HighlightDechroma; // 0 = off (only the mandatory DICE/gamut desat applies); higher = bright sources fade to white sooner.
float BloomIntensity; // 1 = vanilla. Scales the game's bloom contribution in the scene mix.
float Contrast; // 1 = vanilla. Slope contrast around 18% mid-gray on the final HDR color.
float VignetteIntensity; // 1 = vanilla. Scales the game's vignette darkening (0 = no vignette).
float LumaBloomEnable; // 0/1. 1 = composite Luma HDR pyramidal bloom (t5 BL2 / t8 TPS, additive); 0 = vanilla game bloom (t1).
float DOFRadius; // Luma Gaussian DoF strength (half-res blur extent, full-res px @ 4K).
float DOFType; // DoF path: 0 = vanilla game DoF, 1 = Luma separable Gaussian (t7 pre-blurred).
float Dithering; // 0/1 toggle. Animated triangular dither at output (HDR only) to break gradient banding.
float VideoAutoHDREnable; // 0/1. 1 = light PumboAutoHDR on Bink videos (HDR only); 0 = flat SDR at paper white.
float VideoAutoHDRBoost; // 0..1. Highlight-expansion strength; peak = lerp(sRGB white, 250 nits, boost). 0 = off.
};

// Game specific cbuffer (instance/pass) data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// RCAS sharpening for the SMAA output.
// Runs after the SMAA neighborhood-blend pass, on the linear scRGB color (DrawSMAA blends the linear copy),
// before the result is copied back into the fp16 scRGB swapchain. paperWhite=1.0; the sharpness slider is the
// tuning knob. RCAS_LIMIT bounds the lobe so HDR highlights don't over-sharpen.
// Runs after the SMAA neighborhood-blend pass, on the gamma LDR color (the same gamma LDR SMAA consumed),
// before the result is copied back into the LDR buffer (core Display Composition does paper-white + scRGB
// downstream). paperWhite=1.0; the sharpness slider is the tuning knob. RCAS_LIMIT bounds the lobe so bright
// pixels don't over-sharpen.

#include "../Includes/RCAS.hlsl"

Expand All @@ -10,7 +11,7 @@ cbuffer SharpenCB : register(b0)
float4 SharpenParams; // (width, height, sharpness[0..1], unused)
}

Texture2D<float4> tex0 : register(t0); // SMAA output (linear scRGB)
Texture2D<float4> tex0 : register(t0); // SMAA output (gamma LDR)
Texture2D<float2> dummyMV : register(t1); // unused (dynamicSharpening = false)

float4 sharpen_ps(float4 pos : SV_Position) : SV_Target
Expand Down
310 changes: 310 additions & 0 deletions Shaders/Borderlands 2 and The Pre-Sequel/Luma_BL2TPS_Tonemap.hlsl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Threshold = soft-knee quadratic (Bloom.hlsl default LUMA_BLOOM_THRESHOLD_FUNCTION). Source is linear scene
// referred to paper white (1.0), so threshold 1.0 blooms above-paper-white highlights; soft knee 0.5 fades the
// transition in (web best-practice — avoids hard popping on cel-shade ink edges). Karis firefly weighting is
// transition in (avoids hard popping on cel-shade ink edges). Karis firefly weighting is
// applied separately (DrawKarisAverage) before this, since BL2 has no TAA to hide sparkle.

#include "../Includes/Color.hlsl" // GetLuminance, gamma helpers used by Bloom.hlsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cbuffer SmaaMetricsCB : register(b1)
#define SMAA_PRESET_ULTRA
#define SMAA_PREDICATION 1
#define SMAA_PREDICATION_SCALE SmaaPredication.x
// Predication tuned to ReShade-community best-practice + BL2's clean view-Z depth signal:
// Predication tuned to BL2's clean view-Z depth signal:
// - flat threshold = SCALE * SMAA_THRESHOLD = 2.0 * 0.05 = 0.10 (recommended; rejects busy
// cel-shade texture color-noise so SMAA doesn't over-AA flat detail)
// - silhouette thr = SCALE * SMAA_THRESHOLD * (1-STR) = 2.0 * 0.05 *0.5 = 0.05 (= plain ULTRA base; predication
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Borderlands: The Pre-Sequel — tonemap / HDR injection point (dgVoodoo 2.81.3 -> ps_4_0, hash 0x2079F1E8).
// Older dgVoodoo builds emit ps_4_0 -> a different CSO hash for the same DX9 shader. Identical I/O + slot map
// (LightShaft@t1, +1 shift, Luma bloom -> t8) to the 2.87.3 TPS variant (0xFCFE623E), so it reuses the same
// TPS slot macros over the shared grade impl.
#define TM_HAS_LIGHTSHAFT 1
#define TM_T_LIGHTSHAFT t1 // LightShaftTexture (god rays) — TPS-only, inserted at slot 1
#define TM_T_BLOOM t2 // FilterColor1Texture (screen-blend bloom)
#define TM_T_VIGNETTE t3 // VignetteTexture
#define TM_T_LUT t4 // ColorGradingLUT (256x16, 16-slice)
#define TM_T_DOF t5 // LowResPostProcessBuffer (half-res DOF)
#define TM_T_LUMABLOOM t8 // injected Luma HDR bloom (t5 is the native DOF on TPS — bind higher to avoid the clash)
#define TM_S_BLOOM s2
#define TM_S_VIGNETTE s3
#define TM_S_LUT s4
#define TM_S_DOF s5
#include "Luma_BL2TPS_Tonemap.hlsl"

void main(
float4 v0 : SV_POSITION0,
float4 v1 : TEXCOORD8,
float4 v2 : COLOR0,
float4 v3 : COLOR1,
float4 v4 : TEXCOORD9,
float4 v5 : TEXCOORD0,
float4 v6 : TEXCOORD1,
float4 v7 : TEXCOORD2,
float4 v8 : TEXCOORD3,
float4 v9 : TEXCOORD4,
float4 v10 : TEXCOORD5,
float4 v11 : TEXCOORD6,
float4 v12 : TEXCOORD7,
out float4 o0 : SV_TARGET0)
{
o0 = RunTonemap(v5, v6);
}
Loading
Loading