chore: cleaned up all of the decompiled shaders

This commit is contained in:
la
2026-03-04 07:52:32 +10:00
parent 39339e821e
commit 94d52937a5
3 changed files with 79 additions and 98 deletions
+28 -43
View File
@@ -46,54 +46,39 @@ Texture2D<float4> diffuse_texture : register(t0);
struct PS_INPUT struct PS_INPUT
{ {
float4 v0 : SV_POSITION; float4 position : SV_POSITION;
float4 v1 : COLOR0; float4 colour : COLOR0;
linear centroid float4 v2 : TEXCOORD0; linear centroid float4 texcoord : TEXCOORD0;
}; };
float4 main(PS_INPUT input) : SV_TARGET float4 main(PS_INPUT input) : SV_TARGET
{ {
float4 r0, r1; float2 uv = input.texcoord.xy;
#ifdef TEXTURE_PROJECTION #ifdef TEXTURE_PROJECTION
r0.xy = input.v2.xy / input.v2.ww; uv /= input.texcoord.w;
r0.xyzw = diffuse_texture.Sample(diffuse_sampler_s, r0.xy).xyzw; #endif
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;
#elif defined(FORCE_LOD) #ifdef FORCE_LOD
r0.xyzw = diffuse_texture.SampleLevel(diffuse_sampler_s, input.v2.xy, forcedLod.x).xyzw; float4 texel = diffuse_texture.SampleLevel(
r0.xyzw = diffuse_colour.xyzw * r0.xyzw; diffuse_sampler_s,
r0.w = input.v1.w * r0.w; uv,
r1.x = (r0.w < alphaTestRef.w) ? 1 : 0; forcedLod.x);
if (r1.x != 0) discard; #else
r0.xyz = r0.xyz * input.v1.xyz + -fog_colour.xyz; float4 texel =
float4 o0; (uv.x > 1.0f)
o0.xyz = input.v2.zzz * r0.xyz + fog_colour.xyz; ? diffuse_texture.SampleLevel(diffuse_sampler_s, uv, 0)
o0.w = r0.w; : diffuse_texture.Sample(diffuse_sampler_s, uv);
return o0; #endif
#else float4 colour = texel * diffuse_colour;
r0.x = (1 < input.v2.x) ? 1 : 0; colour.a *= input.colour.a;
if (r0.x != 0)
r0.xyzw = diffuse_texture.SampleLevel(diffuse_sampler_s, input.v2.xy, 0).xyzw; if (colour.a < alphaTestRef.w)
else discard;
r0.xyzw = diffuse_texture.Sample(diffuse_sampler_s, input.v2.xy).xyzw;
r0.xyzw = diffuse_colour.xyzw * r0.xyzw; float3 shaded = colour.rgb * input.colour.rgb;
r0.w = input.v1.w * r0.w; float3 fogged = lerp(fog_colour.rgb, shaded, input.texcoord.z);
r1.x = (r0.w < alphaTestRef.w) ? 1 : 0;
if (r1.x != 0) discard; return float4(fogged, colour.a);
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
} }
+34 -42
View File
@@ -132,72 +132,64 @@ VS_OUTPUT main(VS_INPUT input)
{ {
VS_OUTPUT output; 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); float2 lightUV = frac(max(vecUVT2.xy, float2(input.lightMapCoord) * 0.00390625f));
float4 cameraSpacePos = mul(matWorldView, skinnedPosition); float4 lightSample = light_texture.SampleLevel(light_sampler_s, lightUV, 0);
output.position = mul(matProjection, cameraSpacePos); lightSample.w = 1.0f;
float2 lightMapUV = float2((int2) input.lightMapCoord) * 0.00390625f; #ifdef LIGHTING
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
float3 skinNormal = mul((float3x3)matWorldView2, input.normal); float3 skinNormal = mul((float3x3)matWorldView2, input.normal);
float3 viewNormal = normalize(mul((float3x3)matWorldView, skinNormal)); float3 viewNormal = normalize(mul((float3x3)matWorldView, skinNormal));
float d0 = max(0.0f, dot(vecLight0, viewNormal)); float diffuse0 = max(0.0f, dot(vecLight0, viewNormal));
float d1 = max(0.0f, dot(vecLight1, viewNormal)); float diffuse1 = max(0.0f, dot(vecLight1, viewNormal));
float4 litColour = saturate(vecLightAmbientCol + d0 * vecLight0Col + d1 * vecLight1Col); float4 litColour = saturate(vecLightAmbientCol + diffuse0 * vecLight0Col + diffuse1 * vecLight1Col);
lightMapUV = float2((int2)input.lightMapCoord) * 0.00390625f; output.colour.xyz = litColour.xyz * (input.colour.wzy * lightSample.xyz);
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.w = litColour.w; output.colour.w = litColour.w;
#endif #else
output.colour = input.colour.wzyx * lightSample;
#endif
#ifdef TEXGEN #ifdef TEXGEN
float4 texGenCoords = mul(matTexGenView, cameraSpacePos) + mul(matTexGenObj, input.position); float4 texGenCoords = mul(matTexGenView, cameraPos) + mul(matTexGenObj, input.position);
output.texCoord.x = dot(matUV[0], texGenCoords); output.texCoord.xy = float2(dot(matUV[0], texGenCoords), dot(matUV[1], texGenCoords));
output.texCoord.y = dot(matUV[1], texGenCoords); output.texCoord.w = dot(matUV[3], texGenCoords);
output.texCoord.w = dot(matUV[3], texGenCoords); #else
#else
output.texCoord.xy = float2(dot(matUV[0], input.texCoord), dot(matUV[1], input.texCoord)); output.texCoord.xy = float2(dot(matUV[0], input.texCoord), dot(matUV[1], input.texCoord));
output.texCoord.w = 1.0f; output.texCoord.w = 1.0f;
#endif #endif
output.texCoord.z = CalcFogFactor(vecFog, cameraSpacePos.z); output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z);
#else // COMPRESSED #else // COMPRESSED
float4 pos; float4 pos;
pos.xyz = float3((int3)input.position.xyz) * 0.0009765625f + vecWV2Trans.xyz; pos.xyz = float3((int3)input.position.xyz) * 0.0009765625f + vecWV2Trans.xyz;
pos.w = 1.0f; pos.w = 1.0f;
int packedColor = (int)input.position.w + 32768; 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); float4 cameraPos = mul(matWorldView, pos);
output.position = mul(matProjection, cameraSpacePos); output.position = mul(matProjection, cameraPos);
float4 uvs = float4((int4)input.texCoord.zwxy) * float4(0.00390625f, 0.00390625f, 0.000122070312f, 0.000122070312f); float4 uvs = float4((int4)input.texCoord.zwxy) * float4(0.00390625f, 0.00390625f, 0.000122070312f, 0.000122070312f);
float2 lightMapUV = frac(max(vecUVT2.xy, uvs.xy)); float2 lightUV = frac(max(vecUVT2.xy, uvs.xy));
float4 lightMapSample = light_texture.SampleLevel(light_sampler_s, lightMapUV, 0); 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.colour.w = 1.0f;
output.texCoord.xy = uvs.zw; output.texCoord.xy = uvs.zw;
output.texCoord.z = CalcFogFactor(vecFog, cameraSpacePos.z); output.texCoord.z = CalcFogFactor(vecFog, cameraPos.z);
output.texCoord.w = 1.0f; output.texCoord.w = 1.0f;
#endif #endif
return output; return output;
} }
+17 -13
View File
@@ -21,24 +21,28 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
cbuffer cbuff : register(b4) cbuffer screenspace_constants : register(b9)
{ {
float4 clear_colour; float4 v_scaleoffset;
}; };
SamplerState screen_sampler_s : register(s0); void VS_ScreenSpace(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION, out float2 texcoord : TEXCOORD0)
Texture2D<float4> screen_texture : register(t0);
float4 PS_ScreenSpace(float4 v0 : SV_POSITION, float2 v1 : TEXCOORD0) : SV_TARGET
{ {
float4 o0; float2 corner = float2(
o0.xyzw = screen_texture.Sample(screen_sampler_s, v1.xy).xyzw; (vertex_id << 1) & 2,
return o0; vertex_id & 2
);
position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1);
texcoord = corner * 0.5 * v_scaleoffset.zw + v_scaleoffset.xy;
} }
float4 PS_ScreenClear(float4 v0 : SV_POSITION) : SV_TARGET void VS_ScreenClear(uint vertex_id : SV_VertexID, out float4 position : SV_POSITION)
{ {
float4 o0; float2 corner = float2(
o0.xyzw = clear_colour.xyzw; (vertex_id << 1) & 2,
return o0; vertex_id & 2
);
position = float4(corner * float2(2, -2) + float2(-1, 1), 1, 1);
} }