Skip to content

Commit

Permalink
refactor(shaders): add namespaces, clang-format, remove globals
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jul 2, 2024
1 parent 9e70627 commit d759210
Show file tree
Hide file tree
Showing 216 changed files with 3,808 additions and 4,558 deletions.
5 changes: 3 additions & 2 deletions src/games/batmanak/final00_0x2C2D0899.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// UI Back layer (With alpha)

#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -27,7 +26,9 @@ void main(float2 v0 : TEXCOORD0, float4 v1 : COLOR0, out float4 o0 : SV_TARGET0)
o0.w = v1.w * r0.x;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
5 changes: 3 additions & 2 deletions src/games/batmanak/final01_0x5DAD9473.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Some UI effects

#include "../../shaders/color.hlsl"
#include "./shared.h"

cbuffer cb0 : register(b0) {
Expand All @@ -19,7 +18,9 @@ void main(float4 v0 : COLOR0, float4 v1 : COLOR1, out float4 o0 : SV_TARGET0) {
o0.w = v1.w * v0.w;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
7 changes: 4 additions & 3 deletions src/games/batmanak/final02_0x311E0BDA.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// UI layer

#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -19,7 +18,7 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o

r0.xyzw = t0.Sample(s0_s, v2.xy).xyzw;
r0.xyz = saturate(r0.xyz);

r1.xyz = v1.xyz;
r1.w = 1;
r0.xyzw = r1.xyzw * r0.xyzw;
Expand All @@ -32,7 +31,9 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
13 changes: 4 additions & 9 deletions src/games/batmanak/final03_0x2AC7F89E.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

cbuffer cb0 : register(b0) {
Expand All @@ -8,13 +7,7 @@ cbuffer cb0 : register(b0) {
// 3Dmigoto declarations
#define cmp -

void main(
float4 v0 : COLOR0,
float4 v1 : COLOR1,
float4 v2 : TEXCOORD0,
float4 v3 : TEXCOORD1,
out float4 o0 : SV_TARGET0)
{
void main(float4 v0 : COLOR0, float4 v1 : COLOR1, float4 v2 : TEXCOORD0, float4 v3 : TEXCOORD1, out float4 o0 : SV_TARGET0) {
float4 r0;
uint4 bitmask, uiDest;
float4 fDest;
Expand All @@ -27,7 +20,9 @@ void main(
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
15 changes: 5 additions & 10 deletions src/games/batmanak/final04_0x7527C8AD.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -12,19 +11,13 @@ cbuffer cb0 : register(b0) {
// 3Dmigoto declarations
#define cmp -

void main(
float4 v0 : COLOR0,
float4 v1 : TEXCOORD0,
float4 v2 : TEXCOORD1,
float2 v3 : TEXCOORD2,
out float4 o0 : SV_TARGET0)
{
void main(float4 v0 : COLOR0, float4 v1 : TEXCOORD0, float4 v2 : TEXCOORD1, float2 v3 : TEXCOORD2, out float4 o0 : SV_TARGET0) {
float4 r0;
uint4 bitmask, uiDest;
float4 fDest;

r0.xyzw = t0.Sample(s0_s, v3.xy).xyzw;
r0 = saturate(r0); // sdr clamp
r0 = saturate(r0); // sdr clamp
r0.xyzw = r0.xyzw * v2.xyzw + v1.xyzw;
r0.xyz = saturate(r0.xyz);
o0.w = v0.w * r0.w;
Expand All @@ -33,7 +26,9 @@ void main(
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
5 changes: 3 additions & 2 deletions src/games/batmanak/final05_0xF3B4727D.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand Down Expand Up @@ -26,7 +25,9 @@ void main(float4 v0 : COLOR0, float2 v1 : TEXCOORD0, out float4 o0 : SV_TARGET0)
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
5 changes: 3 additions & 2 deletions src/games/batmanak/final06_0x8D4B625A.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

cbuffer cb0 : register(b0) {
Expand All @@ -18,7 +17,9 @@ void main(out float4 o0 : SV_TARGET0) {
o0.w = cb0[6].w;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
5 changes: 3 additions & 2 deletions src/games/batmanak/final07_0xBD36EC09.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

cbuffer cb0 : register(b0) {
Expand All @@ -23,7 +22,9 @@ void main(float4 v0 : COLOR0, float4 v1 : COLOR1, float4 v2 : TEXCOORD0, float4
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
9 changes: 5 additions & 4 deletions src/games/batmanak/final08_0x420BA351.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// writes to texture or swapchain

#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t1 : register(t1);
Expand Down Expand Up @@ -37,7 +36,7 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
r1.y = cb0[8].y + r2.y;
r0.zw = r1.xy * cb0[11].xy + v2.xy;
r0.z = t1.SampleLevel(s1_s, r0.zw, 0).w;
r0.z = saturate(r0.z); // sdr clamp
r0.z = saturate(r0.z); // sdr clamp
r2.x = r2.x + r0.z;
r2.y = 1 + r2.y;
}
Expand All @@ -48,7 +47,7 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
r0.yz = cb0[10].xy * v2.xy;
r1.xyzw = t0.SampleLevel(s0_s, r0.yz, 0).xyzw;

r1 = saturate(r1); // SDR Clamp
r1 = saturate(r1); // SDR Clamp

r0.y = 1 + -r1.w;
r0.x = r0.x * r0.y;
Expand All @@ -66,7 +65,9 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
o0.w = r0.w;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
7 changes: 4 additions & 3 deletions src/games/batmanak/final09_0xFE8B44FC.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -18,7 +17,7 @@ void main(float2 v0 : TEXCOORD0, out float4 o0 : SV_TARGET0) {
float4 fDest;

r0.xyzw = t0.Sample(s0_s, v0.xy).xyzw;
r0 = saturate(r0); //sdr clamp
r0 = saturate(r0); // sdr clamp
r1.x = dot(r0.xyzw, cb0[7].xyzw);
r1.y = dot(r0.xyzw, cb0[8].xyzw);
r1.z = dot(r0.xyzw, cb0[9].xyzw);
Expand All @@ -32,7 +31,9 @@ void main(float2 v0 : TEXCOORD0, out float4 o0 : SV_TARGET0) {
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
7 changes: 4 additions & 3 deletions src/games/batmanak/final10_0xB4B3061C.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -24,7 +23,7 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
if (r1.y != 0) break;
r1.yz = r1.xx * cb0[8].xy + v2.xy;
r2.xyzw = t0.SampleLevel(s0_s, r1.yz, 0).xyzw;
r2 = saturate(r2); // sdr clamp
r2 = saturate(r2); // sdr clamp
r0.xyzw = r2.xyzw + r0.xyzw;
r1.x = 1 + r1.x;
}
Expand All @@ -41,7 +40,9 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
o0.w = r0.w;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
7 changes: 4 additions & 3 deletions src/games/batmanak/final11_0xDB56A8CA.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand Down Expand Up @@ -29,7 +28,7 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
if (r1.z != 0) break;
r1.zw = r1.xy * cb0[8].xy + v2.xy;
r3.xyzw = t0.SampleLevel(s0_s, r1.zw, 0).xyzw;
r3 = saturate(r3); // sdr clamp
r3 = saturate(r3); // sdr clamp
r2.xyzw = r3.xyzw + r2.xyzw;
r1.y = 1 + r1.y;
}
Expand All @@ -49,7 +48,9 @@ void main(float4 v0 : TEXCOORD0, float4 v1 : TEXCOORD1, float2 v2 : TEXCOORD2, o
o0.w = r0.w;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
7 changes: 4 additions & 3 deletions src/games/batmanak/final12_0x45741188.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

Texture2D<float4> t0 : register(t0);
Expand All @@ -18,7 +17,7 @@ void main(float4 v0 : COLOR0, float4 v1 : TEXCOORD0, float4 v2 : TEXCOORD1, floa
float4 fDest;

r0.xyzw = t0.Sample(s0_s, v3.xy).xyzw;
r0 = saturate(r0); // sdr clamp
r0 = saturate(r0); // sdr clamp
r0.xyzw = r0.xyzw * v2.xyzw + v1.xyzw;
r0.w = v0.w * r0.w;
r0.xyz = saturate(r0.xyz * r0.www);
Expand All @@ -28,7 +27,9 @@ void main(float4 v0 : COLOR0, float4 v1 : TEXCOORD0, float4 v2 : TEXCOORD1, floa
o0.xyz = exp2(r0.xyz);

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
21 changes: 6 additions & 15 deletions src/games/batmanak/final13_0x8CBD2352.ps_5_0.hlsl
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
#include "../../shaders/color.hlsl"
#include "./shared.h"

cbuffer cb0 : register(b0){
cbuffer cb0 : register(b0) {
float4 cb0[47];
}

// 3Dmigoto declarations
#define cmp -

void main(
float4 v0 : TEXCOORD10,
float4 v1 : TEXCOORD11,
float2 v2 : TEXCOORD0,
float2 w2 : TEXCOORD7,
float4 v3 : TEXCOORD1,
float4 v4 : TEXCOORD2,
float4 v5 : TEXCOORD5,
float3 v6 : TEXCOORD6,
out float4 o0 : SV_TARGET0)
{
float4 r0,r1;
void main(float4 v0 : TEXCOORD10, float4 v1 : TEXCOORD11, float2 v2 : TEXCOORD0, float2 w2 : TEXCOORD7, float4 v3 : TEXCOORD1, float4 v4 : TEXCOORD2, float4 v5 : TEXCOORD5, float3 v6 : TEXCOORD6, out float4 o0 : SV_TARGET0) {
float4 r0, r1;
uint4 bitmask, uiDest;
float4 fDest;

Expand All @@ -40,7 +29,9 @@ void main(
o0.w = r0.x;

o0.rgb = saturate(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection ? pow(o0.rgb, 2.2f) : linearFromSRGB(o0.rgb);
o0.rgb = injectedData.toneMapGammaCorrection
? pow(o0.rgb, 2.2f)
: renodx::color::bt709::from::SRGB(o0.rgb);
o0.rgb *= injectedData.toneMapUINits / 80.f;
return;
}
4 changes: 4 additions & 0 deletions src/games/batmanak/shared.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef SRC_BATMAN_ARKHAMKNIGHT_SHARED_H_
#define SRC_BATMAN_ARKHAMKNIGHT_SHARED_H_

#ifndef __cplusplus
#include "../../shaders/renodx.hlsl"
#endif

// Must be 32bit aligned
// Should be 4x32
struct ShaderInjectData {
Expand Down
Loading

0 comments on commit d759210

Please sign in to comment.