Skip to content

Commit

Permalink
[TEW2] Add build date, remove some max(0
Browse files Browse the repository at this point in the history
  • Loading branch information
marat569 committed Oct 31, 2024
1 parent d462dd0 commit 8763b35
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 267 deletions.
34 changes: 15 additions & 19 deletions src/games/tew2/X_Final_0xFFFFFFFE.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@ 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);
float4 vpos: SV_Position,
float2 texcoord: TEXCOORD,
out float4 output: SV_Target0) {
float4 color = sourceTexture.Sample(sourceSampler_s, texcoord.xy);

// Marat's final code -- we use color.rgb instead of o0
color.rgb = renodx::math::SafePow(color.rgb, 2.2f);
color.rgb *= injectedData.toneMapGameNits;
color.rgb /= 80.f;


//Marat's final code -- we use color.rgb instead of o0
color.rgb = renodx::math::SafePow(color.rgb, 2.2f);
color.rgb *= injectedData.toneMapGameNits;
color.rgb /= 80.f;

if ((injectedData.toneMapType >= 2) && (injectedData.clipPeak)) { //If tonemapper is not "none" or "Vanilla"
if (renodx::color::y::from::BT709(color.rgb) > injectedData.toneMapPeakNits / 80.f) { // If the MaxCll is over peaknits
color.rgb = min(color.rgb, injectedData.toneMapPeakNits / 80.f); //clamp output to peak nits slider, bandaid for a few effects
}
if ((injectedData.toneMapType >= 2) && (injectedData.clipPeak)) { // If tonemapper is not "none" or "Vanilla"
if (renodx::color::y::from::BT709(color.rgb) > injectedData.toneMapPeakNits / 80.f) { // If the MaxCll is over peaknits
color.rgb = min(color.rgb, injectedData.toneMapPeakNits / 80.f); // clamp output to peak nits slider, bandaid for a few effects
}
output.rgba = color;
}
}

output.rgba = color;
}
7 changes: 7 additions & 0 deletions src/games/tew2/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ renodx::utils::settings::Settings settings = {
},
},

new renodx::utils::settings::Setting{
.value_type = renodx::utils::settings::SettingValueType::TEXT,
.label = "Version: " + std::string(IsoDate),
.section = "About",
.tooltip = std::string(__DATE__),
},

};

void OnPresetOff() {
Expand Down
45 changes: 22 additions & 23 deletions src/games/tew2/colorcorrect_0x2DFACEA2.ps_5_0.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// Currently not part of the mod, just added to the game's project folder
// The shader right before the tonemapper
// Might be used for future effect sliders (film grain strength for example)
// Seems to include a lot of ACES AP1 color correction
// Similar to the Unreal Engine ACES Lut Builder
// The game's tonemapper is uncharted2, so this is probably just for color correction

#include "./shared.h"

cbuffer fblock : register(b0)
{
cbuffer fblock : register(b0) {
float4 renderpositiontoviewtexture : packoffset(c0);
float4 toneoverbrightcolor : packoffset(c1);
float4 screenscale : packoffset(c2);
Expand All @@ -33,27 +35,24 @@ SamplerState viewcolormap_samp_state_s : register(s1);
Texture2D<float4> postdistortionmap_samp : register(t0);
Texture2D<float4> viewcolormap_samp : register(t1);


// 3Dmigoto declarations
#define cmp -


void main(
float4 v0 : SV_Position0,
out float4 o0 : SV_Target0)
{
float4 r0,r1,r2,r3,r4,r5,r6;
float4 v0 : SV_Position0,
out float4 o0 : SV_Target0) {
float4 r0, r1, r2, r3, r4, r5, r6;
uint4 bitmask, uiDest;
float4 fDest;

r0.xy = v0.xy * renderpositiontoviewtexture.zw + renderpositiontoviewtexture.xy;
r1.xyz = postdistortionmap_samp.Sample(postdistortionmap_samp_state_s, r0.xy, int2(0, 0)).xyz;
r1.xyz = float3(-0.498039216,-0.498039216,-0.498039216) + r1.xyz;
r1.xyz = float3(-0.498039216, -0.498039216, -0.498039216) + r1.xyz;
r0.zw = r1.xy * r1.zz;
r1.xy = r1.xy * r1.zz + r0.xy;
r2.xyz = viewcolormap_samp.SampleLevel(viewcolormap_samp_state_s, r1.xy, 0).xyz;
r3.xyz = postdistortionmap_samp.Sample(postdistortionmap_samp_state_s, r1.xy, int2(0, 0)).xyz;
r3.xyz = float3(-0.498039216,-0.498039216,-0.498039216) + r3.xyz;
r3.xyz = float3(-0.498039216, -0.498039216, -0.498039216) + r3.xyz;
r0.z = dot(r0.zw, r0.zw);
r1.zw = r3.xy * r3.zz;
r0.w = dot(r1.zw, r1.zw);
Expand All @@ -67,16 +66,16 @@ void main(
}
r0.xyz = toneoverbrightcolor.xyz * r2.xyz;
r2.xyz = screenscale.xyz * r0.xyz;
r0.w = dot(r2.xyz, float3(0.272228718,0.674081743,0.0536895171));
r0.w = dot(r2.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); // AP1
r0.xyz = r0.xyz * screenscale.xyz + -r0.www;
r0.xyz = cgsaturation.xyz * r0.xyz + r0.www;
r0.xyz = max(float3(0,0,0), r0.xyz);
r0.xyz = float3(5.55555534,5.55555534,5.55555534) * r0.xyz;
// r0.xyz = max(float3(0, 0, 0), r0.xyz); //rec709 clamp
r0.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r0.xyz;
r0.xyz = log2(r0.xyz);
r0.xyz = cgcontrast.xyz * r0.xyz;
r0.xyz = exp2(r0.xyz);
r0.xyz = float3(0.180000007,0.180000007,0.180000007) * r0.xyz;
r2.xyz = float3(1,1,1) / cggamma.xyz;
r0.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r0.xyz; // ACES Film Toe
r2.xyz = float3(1, 1, 1) / cggamma.xyz;
r0.xyz = log2(r0.xyz);
r0.xyz = r2.xyz * r0.xyz;
r0.xyz = exp2(r0.xyz);
Expand All @@ -96,7 +95,7 @@ void main(
r1.w = saturate(r1.w / r2.w);
r4.xyz = r0.xyz * cghighlightcolor.xyz + -r2.xyz;
r4.xyz = r1.www * r4.xyz + r2.xyz;
r5.xy = cmp(float2(0,0) < cgparm.xz);
r5.xy = cmp(float2(0, 0) < cgparm.xz);
if (r5.x != 0) {
r5.xzw = cgshadowcolor.xyz * r2.xyz;
r1.w = saturate(-cgparm.x + r0.w);
Expand All @@ -117,14 +116,14 @@ void main(
}
r1.z = cmp(0 < cgparm.w);
if (r1.z != 0) {
r0.x = dot(r0.xyz, float3(0.272228718,0.674081743,0.0536895171));
r0.x = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171));
r0.y = cmp(cgparm.w == 1.000000);
r0.x = r0.y ? r0.x : r0.w;
r0.y = dot(r3.xyz, float3(0.272228718,0.674081743,0.0536895171));
r0.y = dot(r3.xyz, float3(0.272228718, 0.674081743, 0.0536895171));
r0.x = r0.x / r0.y;
r3.xyz = r3.xyz * r0.xxx;
}
r0.xy = r1.xy * float2(2,2) + float2(-1,-1);
r0.xy = r1.xy * float2(2, 2) + float2(-1, -1);
r0.z = cmp(0 < vignetteparm2.x);
if (r0.z != 0) {
r0.zw = r0.xy * vignetteparm.xy + vignetteparm.zw;
Expand All @@ -137,8 +136,8 @@ void main(
r0.z = exp2(r0.z);
r0.z = vignetteparm2.x * r0.z;
r0.z = 0.180000007 * r0.z;
r1.xyz = float3(-1,-1,-1) + vignettecolor.xyz;
r1.xyz = r0.zzz * r1.xyz + float3(1,1,1);
r1.xyz = float3(-1, -1, -1) + vignettecolor.xyz;
r1.xyz = r0.zzz * r1.xyz + float3(1, 1, 1);
r3.xyz = r3.xyz * r1.xyz;
}
r0.z = cmp(0 < vignetteinvparm2.x);
Expand All @@ -152,8 +151,8 @@ void main(
r0.x = r0.y * r0.x;
r0.x = exp2(r0.x);
r0.x = vignetteinvparm2.x * r0.x;
r0.yzw = float3(-1,-1,-1) + vignetteinvcolor.xyz;
r0.xyz = r0.xxx * r0.yzw + float3(1,1,1);
r0.yzw = float3(-1, -1, -1) + vignetteinvcolor.xyz;
r0.xyz = r0.xxx * r0.yzw + float3(1, 1, 1);
r3.xyz = r3.xyz * r0.xyz;
}
o0.xyz = r3.xyz;
Expand Down
Loading

0 comments on commit 8763b35

Please sign in to comment.