forked from clshortfuse/renodx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'clshortfuse:main' into main
- Loading branch information
Showing
42 changed files
with
3,127 additions
and
1,009 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
cbuffer _Globals : register(b0) | ||
{ | ||
float2 resolution : packoffset(c0); | ||
float2 invResolution : packoffset(c0.z); | ||
} | ||
|
||
SamplerState s_framebuffer_s : register(s0); | ||
Texture2D<float4> s_framebuffer : register(t0); | ||
|
||
#define cmp - | ||
|
||
static const float3 Rec709_Luminance = float3(0.2126f, 0.7152f, 0.0722f); | ||
|
||
float GetLuminance( float3 color ) | ||
{ | ||
return dot( color, Rec709_Luminance ); | ||
} | ||
|
||
void main( | ||
float4 v0 : SV_Position0, | ||
float2 v1 : TEXCOORD0, | ||
float2 w1 : TEXCOORD1, | ||
float2 v2 : TEXCOORD2, | ||
float2 w2 : TEXCOORD3, | ||
float2 v3 : TEXCOORD4, | ||
out float4 o0 : SV_Target0) | ||
{ | ||
#if 0 // Disable AA | ||
o0 = s_framebuffer.Load(v0.xyz); | ||
#else | ||
//TODO: implemented more modern spatial AA | ||
float4 r0,r1,r2,r3,r4,r5; | ||
r0.xyzw = resolution.xyxy * v1.xyxy; | ||
r1.xyzw = s_framebuffer.Sample(s_framebuffer_s, v1.xy).xyzw; | ||
r2.xyzw = s_framebuffer.Sample(s_framebuffer_s, w1.xy).xyzw; | ||
r3.xyzw = s_framebuffer.Sample(s_framebuffer_s, v2.xy).xyzw; | ||
r4.xyzw = s_framebuffer.Sample(s_framebuffer_s, w2.xy).xyzw; | ||
r5.xyzw = s_framebuffer.Sample(s_framebuffer_s, v3.xy).xyzw; | ||
// RenoDX: fixed BT.601 luminance coeffs //TODO: fix more of these (e.g. bloom?) | ||
r1.x = GetLuminance(r1.xyz); | ||
r1.y = GetLuminance(r2.xyz); | ||
r1.z = GetLuminance(r3.xyz); | ||
r1.w = GetLuminance(r4.xyz); | ||
r2.x = GetLuminance(r5.xyz); | ||
r2.y = min(r1.y, r1.z); | ||
r2.z = min(r2.x, r1.w); | ||
r2.y = min(r2.y, r2.z); | ||
r2.y = min(r2.y, r1.x); | ||
r2.z = max(r1.y, r1.z); | ||
r2.w = max(r2.x, r1.w); | ||
r2.z = max(r2.z, r2.w); | ||
r2.z = max(r2.z, r1.x); | ||
r2.w = r1.y + r1.z; | ||
r3.x = r2.x + r1.w; | ||
r3.x = -r3.x + r2.w; | ||
r4.xz = -r3.xx; | ||
r1.y = r1.y + r1.w; | ||
r1.z = r2.x + r1.z; | ||
r4.yw = r1.yy + -r1.zz; | ||
r1.y = r2.w + r1.w; | ||
r1.y = r1.y + r2.x; | ||
r1.y = 0.03125 * r1.y; | ||
r1.y = max(0.0078125, r1.y); | ||
r1.z = min(abs(r4.w), abs(r3.x)); | ||
r1.y = r1.z + r1.y; | ||
r1.y = 1 / r1.y; | ||
r3.xyzw = r4.xyzw * r1.yyyy; | ||
r3.xyzw = max(float4(-8,-8,-8,-8), r3.xyzw); | ||
r3.xyzw = min(float4(8,8,8,8), r3.xyzw); | ||
r3.xyzw = invResolution.xyxy * r3.xyzw; | ||
r0.xyzw = invResolution.xyxy * r0.xyzw; | ||
r4.xyzw = r3.zwzw * float4(-0.166666672,-0.166666672,0.166666672,0.166666672) + r0.zwzw; | ||
r5.xyzw = s_framebuffer.Sample(s_framebuffer_s, r4.xy).xyzw; | ||
r4.xyzw = s_framebuffer.Sample(s_framebuffer_s, r4.zw).xyzw; | ||
r1.yzw = r5.xyz + r4.xyz; | ||
r0.xyzw = r3.xyzw * float4(-0.5,-0.5,0.5,0.5) + r0.xyzw; | ||
r3.xyzw = s_framebuffer.Sample(s_framebuffer_s, r0.xy).xyzw; | ||
r0.xyzw = s_framebuffer.Sample(s_framebuffer_s, r0.zw).xyzw; | ||
r0.xyz = r3.xyz + r0.xyz; | ||
r0.xyz = float3(0.25,0.25,0.25) * r0.xyz; | ||
r0.xyz = r1.yzw * float3(0.25,0.25,0.25) + r0.xyz; | ||
r0.w = dot(r0.xyz, r1.xxx); | ||
r1.x = cmp(r0.w < r2.y); | ||
r0.w = cmp(r2.z < r0.w); | ||
r0.w = (int)r0.w | (int)r1.x; | ||
if (r0.w != 0) { | ||
o0.xyz = float3(0.5,0.5,0.5) * r1.yzw; | ||
} else { | ||
o0.xyz = r0.xyz; | ||
} | ||
o0.w = 0; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "./shared.h" | ||
|
||
cbuffer _Globals : register(b0) | ||
{ | ||
float ImageSpace_hlsl_ToneMapPixelShader011_4bits : packoffset(c0) = {0}; | ||
float4 fogColor : packoffset(c1); | ||
float3 fogTransform : packoffset(c2); | ||
float4x3 screenDataToCamera : packoffset(c3); | ||
float globalScale : packoffset(c6); | ||
float sceneDepthAlphaMask : packoffset(c6.y); | ||
float globalOpacity : packoffset(c6.z); | ||
float distortionBufferScale : packoffset(c6.w); | ||
float2 wToZScaleAndBias : packoffset(c7); | ||
float4 screenTransform[2] : packoffset(c8); | ||
float4 textureToPixel : packoffset(c10); | ||
float4 pixelToTexture : packoffset(c11); | ||
float maxScale : packoffset(c12) = {0}; | ||
float bloomAlpha : packoffset(c12.y) = {0}; | ||
float sceneBias : packoffset(c12.z) = {1}; | ||
float exposure : packoffset(c12.w) = {0}; | ||
float deltaExposure : packoffset(c13) = {0}; | ||
float4 ColorFill : packoffset(c14); | ||
} | ||
|
||
SamplerState s_framebuffer_s : register(s0); | ||
SamplerState s_bloom_s : register(s1); | ||
Texture2D<float4> s_framebuffer : register(t0); | ||
Texture2D<float4> s_bloom : register(t1); | ||
|
||
void main( | ||
float4 v0 : SV_Position0, | ||
float2 v1 : TEXCOORD0, | ||
float2 w1 : TEXCOORD1, | ||
out float4 outColor : SV_Target0) | ||
{ | ||
float3 bloomColor = s_bloom.Sample(s_bloom_s, w1.xy).rgb; | ||
float4 sceneColor = s_framebuffer.Sample(s_framebuffer_s, v1.xy).rgba; | ||
bloomColor *= bloomAlpha; // Scale down (or up) the bloom intensity | ||
sceneColor.rgb += bloomColor; // Bloom is 100% additive here | ||
sceneColor.rgb *= sceneBias; // Exposure? | ||
|
||
const float paperWhite = injectedData.paperWhiteNits / renodx::color::srgb::REFERENCE_WHITE; | ||
const float peakWhite = injectedData.peakWhiteNits / renodx::color::srgb::REFERENCE_WHITE; | ||
const float highlightsShoulderStart = paperWhite; // Don't tonemap the "SDR" range (in luminance), we want to keep it looking as it used to look in SDR | ||
sceneColor.rgb = renodx::tonemap::dice::BT709(sceneColor.rgb * paperWhite, peakWhite, highlightsShoulderStart) / paperWhite; | ||
|
||
outColor = float4(pow(abs(sceneColor.rgb), 1.0 / 2.2) * sign(sceneColor.rgb), sceneColor.a); // Gamma 2.2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
void main(uint id: SV_VERTEXID, out float4 pos: SV_POSITION, out float2 uv: TEXCOORD0) { | ||
uv.x = (id == 1) ? 2.0 : 0.0; | ||
uv.y = (id == 2) ? 2.0 : 0.0; | ||
pos = float4(uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "./shared.h" | ||
|
||
SamplerState sourceSampler_s : register(s0); | ||
Texture2D<float4> sourceTexture : register(t0); | ||
|
||
void main( | ||
float4 vpos: SV_Position, | ||
float2 texcoord: TEXCOORD, | ||
out float4 output: SV_Target0) { | ||
float4 color = sourceTexture.Sample(sourceSampler_s, texcoord.xy); | ||
|
||
// Linearize with 2.2 Gamma and scale paper white | ||
float3 linearizedColor = renodx::color::gamma::DecodeSafe(color.rgb, 2.2); | ||
linearizedColor *= injectedData.paperWhiteNits / renodx::color::srgb::REFERENCE_WHITE; | ||
|
||
output.rgba = float4(linearizedColor, color.a); | ||
} |
Oops, something went wrong.