From 77d7afd4c4b646fb870b71eaa84f6b532673fc20 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 24 Jan 2025 14:37:01 -0800 Subject: [PATCH] Fix some more matrix issues --- src/Halo1/scenes.ts | 56 +++++++++++----------- src/KingdomHearts2FinalMix/program.glsl | 2 +- src/MarioKartWii/PostEffect.ts | 4 +- src/SourceEngine/Materials/Material_Sky.ts | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/Halo1/scenes.ts b/src/Halo1/scenes.ts index 6de9c9a82..338d91146 100644 --- a/src/Halo1/scenes.ts +++ b/src/Halo1/scenes.ts @@ -158,10 +158,10 @@ void mainVS() { class ShaderTransparencyGenericProgram extends BaseProgram { public static BindingsDefinition = ` layout(std140, row_major) uniform ub_ShaderParams { - Mat4x2 u_MapTransform0; - Mat4x2 u_MapTransform1; - Mat4x2 u_MapTransform2; - Mat4x2 u_MapTransform3; + mat4x2 u_MapTransform0; + mat4x2 u_MapTransform1; + mat4x2 u_MapTransform2; + mat4x2 u_MapTransform3; vec4 u_Color0[8]; vec4 u_Color1[8]; }; @@ -176,10 +176,10 @@ layout(std140, row_major) uniform ub_ShaderParams { const fragBody: string[] = []; fragBody.push(` -vec2 uv0 = Mul(u_MapTransform0, vec4(v_UV, 1.0, 1.0)); -vec2 uv1 = Mul(u_MapTransform1, vec4(v_UV, 1.0, 1.0)); -vec2 uv2 = Mul(u_MapTransform2, vec4(v_UV, 1.0, 1.0)); -vec2 uv3 = Mul(u_MapTransform3, vec4(v_UV, 1.0, 1.0)); +vec2 uv0 = u_MapTransform0 * vec4(v_UV, 1.0, 1.0); +vec2 uv1 = u_MapTransform1 * vec4(v_UV, 1.0, 1.0); +vec2 uv2 = u_MapTransform2 * vec4(v_UV, 1.0, 1.0); +vec2 uv3 = u_MapTransform3 * vec4(v_UV, 1.0, 1.0); `); if (this.shader.first_map_type === rust.ShaderTransparentGenericMapType.Map2D) { fragBody.push(`vec4 t0 = texture(SAMPLER_2D(u_Texture0), uv0);`); @@ -617,10 +617,10 @@ class MaterialRender_TransparencyGeneric { class ShaderTransparencyChicagoProgram extends BaseProgram { public static BindingsDefinition = ` layout(std140, row_major) uniform ub_ShaderParams { - Mat4x2 u_MapTransform0; - Mat4x2 u_MapTransform1; - Mat4x2 u_MapTransform2; - Mat4x2 u_MapTransform3; + mat4x2 u_MapTransform0; + mat4x2 u_MapTransform1; + mat4x2 u_MapTransform2; + mat4x2 u_MapTransform3; }; `; @@ -655,10 +655,10 @@ layout(std140, row_major) uniform ub_ShaderParams { } } const fragBody: string[] = [ - `vec2 uv0 = Mul(u_MapTransform0, vec4(v_UV, 1.0, 1.0));`, - `vec2 uv1 = Mul(u_MapTransform1, vec4(v_UV, 1.0, 1.0));`, - `vec2 uv2 = Mul(u_MapTransform2, vec4(v_UV, 1.0, 1.0));`, - `vec2 uv3 = Mul(u_MapTransform3, vec4(v_UV, 1.0, 1.0));`, + `vec2 uv0 = u_MapTransform0 * vec4(v_UV, 1.0, 1.0);`, + `vec2 uv1 = u_MapTransform1 * vec4(v_UV, 1.0, 1.0);`, + `vec2 uv2 = u_MapTransform2 * vec4(v_UV, 1.0, 1.0);`, + `vec2 uv3 = u_MapTransform3 * vec4(v_UV, 1.0, 1.0);`, `vec4 t0 = texture(SAMPLER_2D(u_Texture0), uv0);`, `vec4 t1 = texture(SAMPLER_2D(u_Texture1), uv1);`, `vec4 t2 = texture(SAMPLER_2D(u_Texture2), uv2);`, @@ -774,7 +774,7 @@ void mainPS() { class ShaderTransparencyWaterProgram extends BaseProgram { public static BindingsDefinition = ` layout(std140, row_major) uniform ub_ShaderParams { - Mat4x2 u_RippleTransform; + mat4x2 u_RippleTransform; vec4 u_PerpendicularTint; vec4 u_ParallelTint; }; @@ -806,7 +806,7 @@ void mainPS() { t_ReflectionAlpha *= t_Base.a; } - vec2 uv = Mul(u_RippleTransform, vec4(v_UV, 1.0, 1.0)); + vec2 uv = u_RippleTransform * vec4(v_UV, 1.0, 1.0); vec4 t_BumpMap = 2.0 * texture(SAMPLER_2D(u_Texture1), uv) - 1.0; vec3 t_NormalWorld = normalize(CalcTangentToWorld(t_BumpMap.rgb, v_Tangent, v_Binormal, v_Normal)); @@ -859,10 +859,10 @@ class RippleAnimation { class ShaderCompositeRippleProgram extends DeviceProgram { public static BindingsDefinition = ` layout(std140, row_major) uniform ub_ShaderParams { - Mat4x2 u_MapTransform0; - Mat4x2 u_MapTransform1; - Mat4x2 u_MapTransform2; - Mat4x2 u_MapTransform3; + mat4x2 u_MapTransform0; + mat4x2 u_MapTransform1; + mat4x2 u_MapTransform2; + mat4x2 u_MapTransform3; vec4 u_Misc[1]; }; `; @@ -882,10 +882,10 @@ layout(binding = 2) uniform sampler2D u_Texture2; layout(binding = 3) uniform sampler2D u_Texture3; void mainPS() { - vec2 uv0 = Mul(u_MapTransform0, vec4(v_TexCoord, 1.0, 1.0)); - vec2 uv1 = Mul(u_MapTransform1, vec4(v_TexCoord, 1.0, 1.0)); - vec2 uv2 = Mul(u_MapTransform2, vec4(v_TexCoord, 1.0, 1.0)); - vec2 uv3 = Mul(u_MapTransform3, vec4(v_TexCoord, 1.0, 1.0)); + vec2 uv0 = u_MapTransform0 * vec4(v_TexCoord, 1.0, 1.0); + vec2 uv1 = u_MapTransform1 * vec4(v_TexCoord, 1.0, 1.0); + vec2 uv2 = u_MapTransform2 * vec4(v_TexCoord, 1.0, 1.0); + vec2 uv3 = u_MapTransform3 * vec4(v_TexCoord, 1.0, 1.0); vec4 t_BumpMap0 = 2.0 * texture(SAMPLER_2D(u_Texture0), uv0) - 1.0; vec4 t_BumpMap1 = 2.0 * texture(SAMPLER_2D(u_Texture1), uv1) - 1.0; @@ -1137,7 +1137,7 @@ interface TextureAnimationFunction { class ShaderModelProgram extends BaseProgram { public static BindingsDefinition = ` layout(std140, row_major) uniform ub_ShaderParams { - Mat4x2 u_BaseMapTransform; + mat4x2 u_BaseMapTransform; }; `; @@ -1150,7 +1150,7 @@ layout(std140, row_major) uniform ub_ShaderParams { const fragBody: string[] = []; fragBody.push(` -vec4 t_BaseTexture = texture(SAMPLER_2D(u_Texture0), Mul(u_BaseMapTransform, vec4(v_UV, 1.0, 1.0))).rgba; +vec4 t_BaseTexture = texture(SAMPLER_2D(u_Texture0), u_BaseMapTransform * vec4(v_UV, 1.0, 1.0)).rgba; gl_FragColor.rgba = t_BaseTexture.rgba; CalcFog(gl_FragColor, v_Position); `); diff --git a/src/KingdomHearts2FinalMix/program.glsl b/src/KingdomHearts2FinalMix/program.glsl index 72cc57ebf..e67bcb2f5 100644 --- a/src/KingdomHearts2FinalMix/program.glsl +++ b/src/KingdomHearts2FinalMix/program.glsl @@ -51,7 +51,7 @@ void main() { #ifdef USE_TEXTURE #ifdef USE_NORMAL - vec2 tc = Mul(u_View, vec4(v_Normal, 0.0)).xy; + vec2 tc = (u_View * vec4(v_Normal, 0.0)).xy; tc.y *= -1.0; tc = tc * v_TexScaleOffset.xy + v_TexScaleOffset.zw; #else diff --git a/src/MarioKartWii/PostEffect.ts b/src/MarioKartWii/PostEffect.ts index 00d0a634d..b0224ddc3 100644 --- a/src/MarioKartWii/PostEffect.ts +++ b/src/MarioKartWii/PostEffect.ts @@ -424,7 +424,7 @@ uniform sampler2D u_Texture; uniform sampler2D u_Texture2; layout(std140, row_major) uniform ub_Params { - Mat4x2 u_IndTexMat; + mat4x2 u_IndTexMat; vec4 u_Misc0; }; @@ -482,7 +482,7 @@ void main() { #ifdef USE_IND_WARP_TEX // Handcoded indtex pipeline... - vec2 t_WarpTexCoord = Mul(u_IndTexMat, vec4(v_TexCoord, 0.0, 1.0)); + vec2 t_WarpTexCoord = u_IndTexMat * vec4(v_TexCoord, 0.0, 1.0); vec2 t_IndTexOffs = ((255.0 * texture(SAMPLER_2D(u_Texture2), t_WarpTexCoord).ba) - 128.0) * u_IndTexIndScale; t_TexCoord += t_IndTexOffs; #endif diff --git a/src/SourceEngine/Materials/Material_Sky.ts b/src/SourceEngine/Materials/Material_Sky.ts index d7116315f..4d821c287 100644 --- a/src/SourceEngine/Materials/Material_Sky.ts +++ b/src/SourceEngine/Materials/Material_Sky.ts @@ -23,7 +23,7 @@ precision mediump float; ${MaterialShaderTemplateBase.Common} layout(std140, row_major) uniform ub_ObjectParams { - Mat4x2 u_BaseTextureTransform; + mat4x2 u_BaseTextureTransform; vec4 u_ColorScale; };