Skip to content

Commit

Permalink
feat(tunic): rewrite with renodx::draw
Browse files Browse the repository at this point in the history
  • Loading branch information
clshortfuse committed Jan 11, 2025
1 parent 1979079 commit f83b1ae
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 498 deletions.
285 changes: 212 additions & 73 deletions src/games/tunic/addon.cpp

Large diffs are not rendered by default.

101 changes: 0 additions & 101 deletions src/games/tunic/booklet_0xB274BE4D.ps_4_0.hlsl

This file was deleted.

26 changes: 0 additions & 26 deletions src/games/tunic/final00_0x49E25D6C.ps_4_0.hlsl

This file was deleted.

85 changes: 0 additions & 85 deletions src/games/tunic/final01_0x55B0DCB7.ps_4_0.hlsl

This file was deleted.

39 changes: 0 additions & 39 deletions src/games/tunic/final02_0x5439FB55.ps_4_0.hlsl

This file was deleted.

31 changes: 0 additions & 31 deletions src/games/tunic/final03_0x54E583C8.ps_4_0.hlsl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cbuffer cb0 : register(b0) {
// 3Dmigoto declarations
#define cmp -

void main(float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, out float4 o0 : SV_Target0) {
void main(float4 v0: SV_POSITION0, float2 v1: TEXCOORD0, out float4 o0: SV_Target0) {
float4 r0, r1, r2;
uint4 bitmask, uiDest;
float4 fDest;
Expand Down Expand Up @@ -67,22 +67,20 @@ void main(float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, out float4 o0 : SV_Ta
r0.y = -r0.y * r1.z + 1;
r1.y = v1.y;
r1.xy = r1.xy * cb0[4].xy + cb0[4].zw;
r1.xyzw = t0.Sample(s0_s, r1.xy).xyzw;

const float4 inputColor = t0.Sample(s0_s, r1.xy).xyzw;
const float3 inputColor = r1.rgb;
// Expects the frame buffer to be in gamma
r1.xyzw = inputColor;

r0.xyz = r0.yyy * r1.xyz + r0.xzw;
r1.xy = float2(-0.5, -0.5) + v1.xy;
r1.xy = r1.xy * r1.xy;
r0.w = r1.x + r1.y;
r0.w = log2(r0.w);
r0.w = cb2[2].y * r0.w; // cb2[2].y
r0.w = cb2[2].y * r0.w;
r0.w = exp2(r0.w);
r1.x = saturate(cb2[2].x);

const float3 colorFilter = cb2[1].xyz;

r1.xyz = colorFilter * r1.xxx;
r1.xyz = cb2[1].xyz * r1.xxx;
r2.xyz = r1.xyz * r0.www + -r0.xyz;
r1.w = r1.x * r0.w;
r0.xyz = r1.www * r2.xyz + r0.xyz;
Expand All @@ -91,6 +89,7 @@ void main(float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, out float4 o0 : SV_Ta
// r1.xyz = saturate(r0.xyz);
r1.xyz = r0.xyz;

// r0.w = dot(r1.xyz, float3(0.300000012, 0.589999974, 0.109999999));
r0.w = renodx::color::y::from::BT709(abs(r1.xyz));

r2.xyz = r0.www + -r1.xyz;
Expand All @@ -105,25 +104,19 @@ void main(float4 v0 : SV_POSITION0, float2 v1 : TEXCOORD0, out float4 o0 : SV_Ta
r0.xyz = cb2[8].yyy * r0.xyz + r1.xyz;
r0.xyz = cb2[3].yyy + r0.xyz;
r0.xyz = -cb2[3].zzz + r0.xyz;
r1.xy = v1.xy * cb0[5].xy + cb0[5].zw;

float4 t1Color = t1.Sample(s1_s, r1.xy).xyzw; // last frame
r1.xyzw = t1Color;
t1Color *= 80.f / injectedData.toneMapGameNits; // reduce paperwhite sclaing
r1.xyzw = sign(t1Color) * pow(abs(t1Color), 1.f / 2.2f); // Convert raw framebuffer to gamma

r1.xyz = r1.xyz - r0.xyz; // delta
float scaleStrength = saturate(cb2[6].y); // scaler?
// Custom
r0.xyz = lerp(inputColor.rgb, r0.xyz, CUSTOM_SCREEN_GLOW);

o0.xyz = scaleStrength * r1.xyz + r0.xyz;
o0.w = 1;
r1.xy = v1.xy * cb0[5].xy + cb0[5].zw;
r1.xyzw = t1.Sample(s1_s, r1.xy).xyzw;

o0.rgb = lerp(inputColor.rgb, o0.rgb, injectedData.fxScreenGlow);
// r1.xyz = r1.xyz + -r0.xyz;
// r0.w = saturate(cb2[6].y);
// o0.xyz = r0.www * r1.xyz + r0.xyz;

o0.rgb = sign(o0.rgb) * pow(abs(o0.rgb), 2.2f); // linear
o0.rgb *= injectedData.toneMapGameNits / 80.f;
o0.xyz = lerp(r0.xyz, r1.xyz, saturate(cb2[6].y) * CUSTOM_MOTION_BLUR);

// Clamp needed before effects happen after tone mapping...
o0.rgb = min(o0.rgb, injectedData.toneMapPeakNits / 80.f);
o0.w = 1;
return;
}
}
Loading

0 comments on commit f83b1ae

Please sign in to comment.