From c8abc0127b8d36e87920f66e46181da2cbb53eec Mon Sep 17 00:00:00 2001 From: la <76826837+3UR@users.noreply.github.com> Date: Wed, 4 Mar 2026 03:50:31 +1000 Subject: [PATCH] chore: cleaned up all of the decompiled shaders --- Windows_Libs/Dev/Render/Render.vcxproj | 14 ++++ .../Dev/Render/Render.vcxproj.filters | 17 +++++ Windows_Libs/Dev/Render/shaders/main_PS.hlsl | 71 +++++++---------- Windows_Libs/Dev/Render/shaders/main_VS.hlsl | 76 +++++++++---------- .../Dev/Render/shaders/screen_PS.hlsl | 14 ++-- .../Dev/Render/shaders/screen_VS.hlsl | 35 ++++----- 6 files changed, 111 insertions(+), 116 deletions(-) diff --git a/Windows_Libs/Dev/Render/Render.vcxproj b/Windows_Libs/Dev/Render/Render.vcxproj index 647e669..641c887 100644 --- a/Windows_Libs/Dev/Render/Render.vcxproj +++ b/Windows_Libs/Dev/Render/Render.vcxproj @@ -357,6 +357,20 @@ Create + + + Document + + + Document + + + Document + + + Document + + diff --git a/Windows_Libs/Dev/Render/Render.vcxproj.filters b/Windows_Libs/Dev/Render/Render.vcxproj.filters index 33db01c..57c929b 100644 --- a/Windows_Libs/Dev/Render/Render.vcxproj.filters +++ b/Windows_Libs/Dev/Render/Render.vcxproj.filters @@ -27,6 +27,9 @@ {3b83a35a-3f4e-4ae3-b7fa-17a84f509af5} + + {a7d5eaa5-01ec-4f81-93cc-0699c5eabc2c} + @@ -191,4 +194,18 @@ Source Files\microprofile + + + Shaders + + + Shaders + + + Shaders + + + Shaders + + \ No newline at end of file diff --git a/Windows_Libs/Dev/Render/shaders/main_PS.hlsl b/Windows_Libs/Dev/Render/shaders/main_PS.hlsl index 3da3dce..91546a5 100644 --- a/Windows_Libs/Dev/Render/shaders/main_PS.hlsl +++ b/Windows_Libs/Dev/Render/shaders/main_PS.hlsl @@ -46,54 +46,39 @@ Texture2D diffuse_texture : register(t0); struct PS_INPUT { - float4 v0 : SV_POSITION; - float4 v1 : COLOR0; - linear centroid float4 v2 : TEXCOORD0; + float4 position : SV_POSITION; + float4 colour : COLOR0; + linear centroid float4 texcoord : TEXCOORD0; }; float4 main(PS_INPUT input) : SV_TARGET { - float4 r0, r1; + float2 uv = input.texcoord.xy; -#ifdef TEXTURE_PROJECTION - r0.xy = input.v2.xy / input.v2.ww; - r0.xyzw = diffuse_texture.Sample(diffuse_sampler_s, r0.xy).xyzw; - r0.xyzw = diffuse_colour.xyzw * r0.xyzw; - r0.w = input.v1.w * r0.w; - r1.x = (r0.w < alphaTestRef.w) ? 1 : 0; - if (r1.x != 0) discard; - r0.xyz = r0.xyz * input.v1.xyz + -fog_colour.xyz; - float4 o0; - o0.xyz = input.v2.zzz * r0.xyz + fog_colour.xyz; - o0.w = r0.w; - return o0; + #ifdef TEXTURE_PROJECTION + uv /= input.texcoord.w; + #endif -#elif defined(FORCE_LOD) - r0.xyzw = diffuse_texture.SampleLevel(diffuse_sampler_s, input.v2.xy, forcedLod.x).xyzw; - r0.xyzw = diffuse_colour.xyzw * r0.xyzw; - r0.w = input.v1.w * r0.w; - r1.x = (r0.w < alphaTestRef.w) ? 1 : 0; - if (r1.x != 0) discard; - r0.xyz = r0.xyz * input.v1.xyz + -fog_colour.xyz; - float4 o0; - o0.xyz = input.v2.zzz * r0.xyz + fog_colour.xyz; - o0.w = r0.w; - return o0; + #ifdef FORCE_LOD + float4 texel = diffuse_texture.SampleLevel( + diffuse_sampler_s, + uv, + forcedLod.x); + #else + float4 texel = + (uv.x > 1.0f) + ? diffuse_texture.SampleLevel(diffuse_sampler_s, uv, 0) + : diffuse_texture.Sample(diffuse_sampler_s, uv); + #endif -#else - r0.x = (1 < input.v2.x) ? 1 : 0; - if (r0.x != 0) - r0.xyzw = diffuse_texture.SampleLevel(diffuse_sampler_s, input.v2.xy, 0).xyzw; - else - r0.xyzw = diffuse_texture.Sample(diffuse_sampler_s, input.v2.xy).xyzw; - r0.xyzw = diffuse_colour.xyzw * r0.xyzw; - r0.w = input.v1.w * r0.w; - r1.x = (r0.w < alphaTestRef.w) ? 1 : 0; - if (r1.x != 0) discard; - r0.xyz = r0.xyz * input.v1.xyz + -fog_colour.xyz; - float4 o0; - o0.xyz = input.v2.zzz * r0.xyz + fog_colour.xyz; - o0.w = r0.w; - return o0; -#endif + float4 colour = texel * diffuse_colour; + colour.a *= input.colour.a; + + if (colour.a < alphaTestRef.w) + discard; + + float3 shaded = colour.rgb * input.colour.rgb; + float3 fogged = lerp(fog_colour.rgb, shaded, input.texcoord.z); + + return float4(fogged, colour.a); } \ No newline at end of file diff --git a/Windows_Libs/Dev/Render/shaders/main_VS.hlsl b/Windows_Libs/Dev/Render/shaders/main_VS.hlsl index 534f1a3..6f2517c 100644 --- a/Windows_Libs/Dev/Render/shaders/main_VS.hlsl +++ b/Windows_Libs/Dev/Render/shaders/main_VS.hlsl @@ -132,72 +132,64 @@ VS_OUTPUT main(VS_INPUT input) { VS_OUTPUT output; -#ifndef COMPRESSED + #ifndef COMPRESSED + + float4 skinnedPos = mul(matWorldView2, input.position); + float4 cameraPos = mul(matWorldView, skinnedPos); + output.position = mul(matProjection, cameraPos); - float4 skinnedPosition = mul(matWorldView2, input.position); - float4 cameraSpacePos = mul(matWorldView, skinnedPosition); - output.position = mul(matProjection, cameraSpacePos); - - float2 lightMapUV = float2((int2) input.lightMapCoord) * 0.00390625f; - lightMapUV = frac(max(vecUVT2.xy, lightMapUV)); - float4 lightMapSample = light_texture.SampleLevel(light_sampler_s, lightMapUV, 0); - lightMapSample.w = 1.0f; - -#ifndef LIGHTING - output.colour.xyzw = input.colour.wzyx * lightMapSample; -#endif - -#ifdef LIGHTING + float2 lightUV = frac(max(vecUVT2.xy, float2(input.lightMapCoord) * 0.00390625f)); + float4 lightSample = light_texture.SampleLevel(light_sampler_s, lightUV, 0); + lightSample.w = 1.0f; + + #ifdef LIGHTING float3 skinNormal = mul((float3x3)matWorldView2, input.normal); float3 viewNormal = normalize(mul((float3x3)matWorldView, skinNormal)); - float d0 = max(0.0f, dot(vecLight0, viewNormal)); - float d1 = max(0.0f, dot(vecLight1, viewNormal)); - float4 litColour = saturate(vecLightAmbientCol + d0 * vecLight0Col + d1 * vecLight1Col); + float diffuse0 = max(0.0f, dot(vecLight0, viewNormal)); + float diffuse1 = max(0.0f, dot(vecLight1, viewNormal)); + float4 litColour = saturate(vecLightAmbientCol + diffuse0 * vecLight0Col + diffuse1 * vecLight1Col); - lightMapUV = float2((int2)input.lightMapCoord) * 0.00390625f; - lightMapUV = frac(max(vecUVT2.xy, lightMapUV)); - lightMapSample = light_texture.SampleLevel(light_sampler_s, lightMapUV, 0); - - output.colour.xyz = litColour.xyz * (input.colour.wzy * lightMapSample.xyz); + output.colour.xyz = litColour.xyz * (input.colour.wzy * lightSample.xyz); output.colour.w = litColour.w; -#endif + #else + output.colour = input.colour.wzyx * lightSample; + #endif -#ifdef TEXGEN - float4 texGenCoords = mul(matTexGenView, cameraSpacePos) + mul(matTexGenObj, input.position); - output.texCoord.x = dot(matUV[0], texGenCoords); - output.texCoord.y = dot(matUV[1], texGenCoords); - output.texCoord.w = dot(matUV[3], texGenCoords); -#else + #ifdef TEXGEN + float4 texGenCoords = mul(matTexGenView, cameraPos) + mul(matTexGenObj, input.position); + output.texCoord.xy = float2(dot(matUV[0], texGenCoords), dot(matUV[1], texGenCoords)); + output.texCoord.w = dot(matUV[3], texGenCoords); + #else output.texCoord.xy = float2(dot(matUV[0], input.texCoord), dot(matUV[1], input.texCoord)); output.texCoord.w = 1.0f; -#endif + #endif - output.texCoord.z = CalcFogFactor(vecFog, cameraSpacePos.z); - -#else // COMPRESSED + output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z); + + #else // COMPRESSED float4 pos; pos.xyz = float3((int3)input.position.xyz) * 0.0009765625f + vecWV2Trans.xyz; pos.w = 1.0f; int packedColor = (int)input.position.w + 32768; - float3 colour = frac(packedColor * float3(1.52587891e-05f, 0.00048828125f, 0.03125f)); + float3 color = frac(packedColor * float3(1.52587891e-05f, 0.00048828125f, 0.03125f)); - float4 cameraSpacePos = mul(matWorldView, pos); - output.position = mul(matProjection, cameraSpacePos); + float4 cameraPos = mul(matWorldView, pos); + output.position = mul(matProjection, cameraPos); float4 uvs = float4((int4)input.texCoord.zwxy) * float4(0.00390625f, 0.00390625f, 0.000122070312f, 0.000122070312f); - float2 lightMapUV = frac(max(vecUVT2.xy, uvs.xy)); - float4 lightMapSample = light_texture.SampleLevel(light_sampler_s, lightMapUV, 0); + float2 lightUV = frac(max(vecUVT2.xy, uvs.xy)); + float4 lightSample = light_texture.SampleLevel(light_sampler_s, lightUV, 0); - output.colour.xyz = lightMapSample.xyz * colour; + output.colour.xyz = lightSample.xyz * color; output.colour.w = 1.0f; output.texCoord.xy = uvs.zw; - output.texCoord.z = CalcFogFactor(vecFog, cameraSpacePos.z); + output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z); output.texCoord.w = 1.0f; -#endif + #endif return output; } \ No newline at end of file diff --git a/Windows_Libs/Dev/Render/shaders/screen_PS.hlsl b/Windows_Libs/Dev/Render/shaders/screen_PS.hlsl index 8c58198..376f487 100644 --- a/Windows_Libs/Dev/Render/shaders/screen_PS.hlsl +++ b/Windows_Libs/Dev/Render/shaders/screen_PS.hlsl @@ -23,22 +23,18 @@ SOFTWARE. */ cbuffer cbuff : register(b4) { - float4 clear_colour; + float4 clearColour; }; SamplerState screen_sampler_s : register(s0); Texture2D screen_texture : register(t0); -float4 PS_ScreenSpace(float4 v0 : SV_POSITION, float2 v1 : TEXCOORD0) : SV_TARGET +float4 PS_ScreenSpace(float4 position : SV_POSITION, float2 texcoord : TEXCOORD0) : SV_TARGET { - float4 o0; - o0.xyzw = screen_texture.Sample(screen_sampler_s, v1.xy).xyzw; - return o0; + return screen_texture.Sample(screen_sampler_s, texcoord); } -float4 PS_ScreenClear(float4 v0 : SV_POSITION) : SV_TARGET +float4 PS_ScreenClear(float4 position : SV_POSITION) : SV_TARGET { - float4 o0; - o0.xyzw = clear_colour.xyzw; - return o0; + return clearColour; } \ No newline at end of file diff --git a/Windows_Libs/Dev/Render/shaders/screen_VS.hlsl b/Windows_Libs/Dev/Render/shaders/screen_VS.hlsl index 2281d5f..7eec30e 100644 --- a/Windows_Libs/Dev/Render/shaders/screen_VS.hlsl +++ b/Windows_Libs/Dev/Render/shaders/screen_VS.hlsl @@ -26,32 +26,23 @@ cbuffer screenspace_constants : register(b9) float4 v_scaleoffset; }; -void VS_ScreenSpace(uint v0 : SV_VertexID, out float4 o0 : SV_POSITION, out float2 o1 : TEXCOORD0) +void VS_ScreenSpace(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION, out float2 texcoord : TEXCOORD0) { - float4 r0, r1; + float2 corner = float2( + (vertex_id << 1) & 2, + vertex_id & 2 + ); - o0.zw = float2(1, 1); - r0.xy = (int2)v0.xx & int2(1, -2); - r0.z = (uint)r0.x << 1; - r0.yz = (int2)r0.yz + int2(-1, -1); - r1.x = (int)r0.x; - o0.xy = (int2)r0.zy; - r0.x = (uint)v0.x >> 1; - r0.x = (int)-r0.x + 1; - r1.y = (int)r0.x; - o1.xy = r1.xy * v_scaleoffset.zw + v_scaleoffset.xy; + position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1); + texcoord = corner * 0.5 * v_scaleoffset.zw + v_scaleoffset.xy; } -void VS_ScreenClear(uint v0 : SV_VertexID, out float4 o0 : SV_POSITION) +void VS_ScreenClear(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION) { - float4 r0; + float2 corner = float2( + (vertex_id << 1) & 2, + vertex_id & 2 + ); - r0.x = (uint)v0.x << 1; - r0.x = (int)r0.x & 2; - r0.x = (int)r0.x + -1; - o0.x = (int)r0.x; - r0.x = (int)v0.x & -2; - r0.x = (int)r0.x + -1; - o0.y = (int)r0.x; - o0.zw = float2(1, 1); + position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1); } \ No newline at end of file