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
3 changes: 2 additions & 1 deletion MarathonRecomp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ compile_pixel_shader(copy_depth_ps)
compile_pixel_shader(csd_filter_ps)
compile_vertex_shader(csd_no_tex_vs)
compile_vertex_shader(csd_vs)
compile_pixel_shader(enhanced_motion_blur_ps)
compile_vertex_shader(enhanced_burnout_blur_vs)
compile_pixel_shader(enhanced_burnout_blur_ps)
compile_pixel_shader(gaussian_blur_3x3)
compile_pixel_shader(gaussian_blur_5x5)
compile_pixel_shader(gaussian_blur_7x7)
Expand Down
51 changes: 51 additions & 0 deletions MarathonRecomp/gpu/shader/hlsl/enhanced_burnout_blur_ps.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "../../../../tools/XenosRecomp/XenosRecomp/shader_common.h"

#ifdef __spirv__

#define s0_Texture2DDescriptorIndex vk::RawBufferLoad<uint>(g_PushConstants.SharedConstants + 0)
#define s0_SamplerDescriptorIndex vk::RawBufferLoad<uint>(g_PushConstants.SharedConstants + 192)

#else

cbuffer SharedConstants : register(b2, space4)
{
uint s0_Texture2DDescriptorIndex : packoffset(c0.x);
uint s0_SamplerDescriptorIndex : packoffset(c12.x);
DEFINE_SHARED_CONSTANTS();
};

#endif

float4 shaderMain(
in float4 oPos : SV_Position,
in float2 oTexCoord0 : TEXCOORD0,
in float2 oVelocity : TEXCOORD1,
in float2 oVelScale : TEXCOORD2) : SV_Target
{
Texture2D<float4> texture = g_Texture2DDescriptorHeap[s0_Texture2DDescriptorIndex];
SamplerState samplerState = g_SamplerDescriptorHeap[s0_SamplerDescriptorIndex];

float velocityMag = sqrt(dot(oVelocity, oVelocity));
float blurAmount = saturate(velocityMag - 0.25);

if (blurAmount == 0.0)
return texture.SampleLevel(samplerState, oTexCoord0, 0);

blurAmount = min(blurAmount * blurAmount, 0.25);

float blurStrength = blurAmount * velocityMag;
int g_SampleCount = clamp((int)(blurStrength * 256.0), 4, 64);
float2 scaledVelStep = oVelScale / (float)g_SampleCount;

float4 result = float4(0.0, 0.0, 0.0, 0.0);

for (int i = 0; i < g_SampleCount; i++)
{
float2 offset = blurAmount * scaledVelStep * (float)i;
float2 samplePos = oTexCoord0 + offset;

result += texture.SampleLevel(samplerState, samplePos, 0);
}

return result * (1.0 / (float)g_SampleCount);
}
37 changes: 37 additions & 0 deletions MarathonRecomp/gpu/shader/hlsl/enhanced_burnout_blur_vs.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../../../../tools/XenosRecomp/XenosRecomp/shader_common.h"

#ifdef __spirv__

#define g_Velocity vk::RawBufferLoad<float4>(g_PushConstants.VertexShaderConstants + 3360, 0x10)

#else

cbuffer VertexShaderConstants : register(b1, space4)
{
float4 g_Velocity : packoffset(c210);
};

#endif

void shaderMain(
[[vk::location(0)]] in float4 iPosition0 : POSITION0,
[[vk::location(13)]] in float2 iTexCoord0 : TEXCOORD0,
out float4 oPos : SV_Position,
out float2 oTexCoord0 : TEXCOORD0,
out float2 oVelocity : TEXCOORD1,
out float2 oVelScale : TEXCOORD2)
{
oPos = iPosition0;
oTexCoord0 = iTexCoord0;

float2 centeredUV;
centeredUV.x = iTexCoord0.y * 2.0 - 1.0;
centeredUV.y = iTexCoord0.x * 2.0 - 1.0;

oVelocity.x = -g_Velocity.x - centeredUV.y;
oVelocity.y = centeredUV.x - g_Velocity.y;

float2 scaledVec = oVelocity * g_Velocity.w;
oVelScale.x = scaledVec.x * 0.00002;
oVelScale.y = -scaledVec.y * 0.00001;
}
75 changes: 0 additions & 75 deletions MarathonRecomp/gpu/shader/hlsl/enhanced_motion_blur_ps.hlsl

This file was deleted.

46 changes: 46 additions & 0 deletions MarathonRecomp/gpu/shader/msl/enhanced_burnout_blur_ps.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "../../../../tools/XenosRecomp/XenosRecomp/shader_common.h"

#define s0_TextureDescriptorIndex (*(reinterpret_cast<device int*>(g_PushConstants.SharedConstants + 0)))
#define s0_SamplerDescriptorIndex (*(reinterpret_cast<device uint*>(g_PushConstants.SharedConstants + 192)))

struct Interpolators
{
float4 oPos [[position]];
float2 oTexCoord0 [[user(TEXCOORD0)]];
float2 oVelocity [[user(TEXCOORD1)]];
float2 oVelScale [[user(TEXCOORD2)]];
};

[[fragment]]
float4 shaderMain(Interpolators input [[stage_in]],
constant Texture2DDescriptorHeap* g_Texture2DDescriptorHeap [[buffer(0)]],
constant SamplerDescriptorHeap* g_SamplerDescriptorHeap [[buffer(3)]],
constant PushConstants& g_PushConstants [[buffer(8)]])
{
texture2d<float> texture = g_Texture2DDescriptorHeap[s0_TextureDescriptorIndex].tex;
sampler samp = g_SamplerDescriptorHeap[s0_SamplerDescriptorIndex].samp;

float velocityMag = sqrt(dot(input.oVelocity, input.oVelocity));
float blurAmount = saturate(velocityMag - 0.25);

if (blurAmount == 0.0)
return texture.sample(samp, input.oTexCoord0, level(0));

blurAmount = min(blurAmount * blurAmount, 0.25);

float blurStrength = blurAmount * velocityMag;
int g_SampleCount = clamp((int)(blurStrength * 256.0), 4, 64);
float2 scaledVelStep = input.oVelScale / (float)g_SampleCount;

float4 result = float4(0.0);

for (int i = 0; i < g_SampleCount; i++)
{
float2 offset = blurAmount * scaledVelStep * (float)i;
float2 samplePos = input.oTexCoord0 + offset;

result += texture.sample(samp, samplePos, level(0));
}

return result * (1.0 / (float)g_SampleCount);
}
41 changes: 41 additions & 0 deletions MarathonRecomp/gpu/shader/msl/enhanced_burnout_blur_vs.metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "../../../../tools/XenosRecomp/XenosRecomp/shader_common.h"

// #define g_SampleCount (*(reinterpret_cast<device int*>(g_PushConstants.VertexShaderConstants + 0)))
#define g_Velocity (*(reinterpret_cast<device float4*>(g_PushConstants.VertexShaderConstants + 3360)))

struct VertexShaderInput
{
float4 iPosition0 [[attribute(0)]];
float2 iTexCoord0 [[attribute(13)]];
};

struct Interpolators
{
float4 oPos [[position]];
float2 oTexCoord0 [[user(TEXCOORD0)]];
float2 oVelocity [[user(TEXCOORD1)]];
float2 oVelScale [[user(TEXCOORD2)]];
};

[[vertex]]
Interpolators shaderMain(VertexShaderInput input [[stage_in]],
constant PushConstants& g_PushConstants [[buffer(8)]])
{
Interpolators output;

output.oPos = input.iPosition0;
output.oTexCoord0 = input.iTexCoord0;

float2 centeredUV;
centeredUV.x = input.iTexCoord0.y * 2.0 - 1.0;
centeredUV.y = input.iTexCoord0.x * 2.0 - 1.0;

output.oVelocity.x = -g_Velocity.x - centeredUV.y;
output.oVelocity.y = centeredUV.x - g_Velocity.y;

float2 scaledVec = output.oVelocity * g_Velocity.w;
output.oVelScale.x = scaledVec.x * 0.00002;
output.oVelScale.y = -scaledVec.y * 0.00001;

return output;
}
59 changes: 0 additions & 59 deletions MarathonRecomp/gpu/shader/msl/enhanced_motion_blur_ps.metal

This file was deleted.

Loading
Loading