Skip to content

Commit

Permalink
Fix some more matrix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Jan 24, 2025
1 parent b5b857d commit 77d7afd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
56 changes: 28 additions & 28 deletions src/Halo1/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand All @@ -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);`);
Expand Down Expand Up @@ -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;
};
`;

Expand Down Expand Up @@ -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);`,
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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];
};
`;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
};
`;

Expand All @@ -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);
`);
Expand Down
2 changes: 1 addition & 1 deletion src/KingdomHearts2FinalMix/program.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/MarioKartWii/PostEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/SourceEngine/Materials/Material_Sky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 77d7afd

Please sign in to comment.