Skip to content

Commit

Permalink
Source: Stop using legacy matrix library
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Jan 2, 2025
1 parent 47b254c commit e889f8f
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 89 deletions.
22 changes: 11 additions & 11 deletions src/SourceEngine/Materials/MaterialBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ export class MaterialShaderTemplateBase extends UberShaderTemplateBasic {
// #define DEBUG_DIFFUSEONLY 1
// #define DEBUG_FULLBRIGHT 1
layout(std140) uniform ub_SceneParams {
Mat4x4 u_ProjectionView;
layout(std140, row_major) uniform ub_SceneParams {
mat4 u_ProjectionView;
vec4 u_SceneMisc[3];
};
layout(std140) uniform ub_SkinningParams {
layout(std140, row_major) uniform ub_SkinningParams {
#if SKINNING_MODE == ${SkinningMode.Smooth}
Mat4x3 u_BoneMatrix[${MaterialShaderTemplateBase.MaxSkinningParamsBoneMatrix}];
mat4x3 u_BoneMatrix[${MaterialShaderTemplateBase.MaxSkinningParamsBoneMatrix}];
#else
Mat4x3 u_ModelMatrix;
mat4x3 u_ModelMatrix;
#endif
};
Expand Down Expand Up @@ -247,15 +247,15 @@ layout(location = ${MaterialShaderTemplateBase.a_BoneWeights}) in vec4 a_BoneWei
layout(location = ${MaterialShaderTemplateBase.a_BoneIDs}) in vec4 a_BoneIndices;
#endif
Mat4x3 CalcWorldFromLocalMatrix() {
mat4x3 CalcWorldFromLocalMatrix() {
#if SKINNING_MODE == ${SkinningMode.Smooth}
// Calculate our per-vertex position.
Mat4x3 t_WorldFromLocalMatrix = _Mat4x3(0.0);
mat4x3 t_WorldFromLocalMatrix = mat4x3(0.0);
Fma(t_WorldFromLocalMatrix, u_BoneMatrix[int(a_BoneIndices.x)], a_BoneWeights.x);
Fma(t_WorldFromLocalMatrix, u_BoneMatrix[int(a_BoneIndices.y)], a_BoneWeights.y);
Fma(t_WorldFromLocalMatrix, u_BoneMatrix[int(a_BoneIndices.z)], a_BoneWeights.z);
Fma(t_WorldFromLocalMatrix, u_BoneMatrix[int(a_BoneIndices.w)], a_BoneWeights.w);
t_WorldFromLocalMatrix += u_BoneMatrix[int(a_BoneIndices.x)] * a_BoneWeights.x;
t_WorldFromLocalMatrix += u_BoneMatrix[int(a_BoneIndices.y)] * a_BoneWeights.y;
t_WorldFromLocalMatrix += u_BoneMatrix[int(a_BoneIndices.z)] * a_BoneWeights.z;
t_WorldFromLocalMatrix += u_BoneMatrix[int(a_BoneIndices.w)] * a_BoneWeights.w;
return t_WorldFromLocalMatrix;
#else
Expand Down
16 changes: 8 additions & 8 deletions src/SourceEngine/Materials/Material_Eyes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ precision mediump float;
${MaterialShaderTemplateBase.Common}
layout(std140) uniform ub_ObjectParams {
Mat4x2 u_BaseTransform;
Mat4x2 u_IrisTransform;
layout(std140, row_major) uniform ub_ObjectParams {
mat4x2 u_BaseTransform;
mat4x2 u_IrisTransform;
};
varying vec3 v_PositionWorld;
Expand All @@ -34,13 +34,13 @@ uniform sampler2D u_TextureIris;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
v_TexCoord0.xy = Mul(u_BaseTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.zw = Mul(u_IrisTransform, vec4(t_PositionWorld, 1.0));
v_TexCoord0.xy = u_BaseTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
v_TexCoord0.zw = u_IrisTransform * vec4(t_PositionWorld, 1.0);
// XXX(jstpierre): Move lighting into common helpers
v_Lighting.rgb = vec3(1.0);
Expand Down
40 changes: 20 additions & 20 deletions src/SourceEngine/Materials/Material_Generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct WorldLight {
vec4 Direction;
};
layout(std140) uniform ub_ObjectParams {
layout(std140, row_major) uniform ub_ObjectParams {
#if defined USE_AMBIENT_CUBE
// TODO(jstpierre): Pack this more efficiently?
vec4 u_AmbientCube[6];
Expand All @@ -51,15 +51,15 @@ layout(std140) uniform ub_ObjectParams {
// We support up to N lights.
WorldLight u_WorldLights[${ShaderTemplate_Generic.MaxDynamicWorldLights}];
#endif
Mat4x2 u_BaseTextureTransform;
mat4x2 u_BaseTextureTransform;
#if defined USE_BUMPMAP
Mat4x2 u_BumpmapTransform;
mat4x2 u_BumpmapTransform;
#endif
#if defined USE_BUMPMAP2
Mat4x2 u_Bumpmap2Transform;
mat4x2 u_Bumpmap2Transform;
#endif
#if defined USE_DETAIL
Mat4x2 u_DetailTextureTransform;
mat4x2 u_DetailTextureTransform;
#endif
#if defined USE_ENVMAP_MASK
vec4 u_EnvmapMaskScaleBias;
Expand All @@ -82,7 +82,7 @@ layout(std140) uniform ub_ObjectParams {
vec4 u_SpecTintBoost;
#endif
#if defined USE_PROJECTED_LIGHT
Mat4x4 u_ProjectedLightFromWorldMatrix;
mat4 u_ProjectedLightFromWorldMatrix;
vec4 u_ProjectedLightColor;
vec4 u_ProjectedLightOrigin;
#endif
Expand Down Expand Up @@ -274,13 +274,13 @@ vec3 AmbientLight(in vec3 t_NormalWorld) {
void CalcTreeSway(inout vec3 t_PositionLocal) {
#if defined VERT && defined USE_TREE_SWAY
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
float t_WindIntensity = length(u_TreeSwayWindDir);
vec3 t_WindDirLocal = Mul(vec3(u_TreeSwayWindDir, 0.0), t_WorldFromLocalMatrix).xyz;
vec3 t_WindDirLocal = (vec3(u_TreeSwayWindDir, 0.0) * t_WorldFromLocalMatrix).xyz;
vec3 t_PosOffs = vec3(0.0);
vec3 t_OriginWorld = Mul(t_WorldFromLocalMatrix, vec4(0.0, 0.0, 0.0, 1.0));
vec3 t_OriginWorld = t_WorldFromLocalMatrix * vec4(0.0, 0.0, 0.0, 1.0);
float t_TimeOffset = dot(t_OriginWorld, vec3(1.0)) * 19.0;
float t_SwayTime = (u_TreeSwayTime + t_TimeOffset) * u_TreeSwaySpeed;
Expand Down Expand Up @@ -314,12 +314,12 @@ void mainVS() {
vec3 t_PositionLocal = a_Position;
CalcTreeSway(t_PositionLocal);
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(t_PositionLocal, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(t_PositionLocal, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
vec3 t_NormalWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_Normal.xyz, 0.0)));
vec3 t_NormalWorld = normalize(t_WorldFromLocalMatrix * vec4(a_Normal.xyz, 0.0));
#if defined USE_VERTEX_COLOR
v_Color = a_Color;
Expand Down Expand Up @@ -382,15 +382,15 @@ void mainVS() {
#endif
#if defined HAS_FULL_TANGENTSPACE
vec3 t_TangentSWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_TangentS.xyz, 0.0)));
vec3 t_TangentSWorld = normalize(t_WorldFromLocalMatrix * vec4(a_TangentS.xyz, 0.0));
vec3 t_TangentTWorld = cross(t_TangentSWorld, t_NormalWorld);
v_TangentSpaceBasis0 = t_TangentSWorld * a_TangentS.w;
v_TangentSpaceBasis1 = t_TangentTWorld;
#endif
v_TangentSpaceBasis2 = t_NormalWorld;
v_TexCoord0.xy = Mul(u_BaseTextureTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.xy = u_BaseTextureTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
v_TexCoord0.zw = a_TexCoord01.xy;
#if defined USE_LIGHTMAP || defined USE_DECAL
v_TexCoord1.xy = a_TexCoord01.zw;
Expand Down Expand Up @@ -656,10 +656,10 @@ void mainPS() {
#if defined USE_DETAIL
bool use_seamless_detail = ${MaterialUtil.getDefineBool(m, `USE_SEAMLESS_DETAIL`)};
if (use_seamless_detail) {
float t_SeamlessDetailScale = u_DetailTextureTransform.mx.x;
float t_SeamlessDetailScale = u_DetailTextureTransform[0][0];
t_DetailTexture = DebugColorTexture(SeamlessSampleTex(PP_SAMPLER_2D(u_TextureDetail), t_SeamlessDetailScale));
} else {
vec2 t_DetailTexCoord = Mul(u_DetailTextureTransform, vec4(v_TexCoord0.zw, 1.0, 1.0));
vec2 t_DetailTexCoord = u_DetailTextureTransform * vec4(v_TexCoord0.zw, 1.0, 1.0);
t_DetailTexture = DebugColorTexture(texture(SAMPLER_2D(u_TextureDetail), t_DetailTexCoord));
}
t_Albedo = CalcDetail(t_Albedo, t_DetailTexture);
Expand All @@ -674,7 +674,7 @@ void mainPS() {
bool use_ssbump = ${MaterialUtil.getDefineBool(m, `USE_SSBUMP`)};
// TODO(jstpierre): It seems like $bumptransform might not even be respected in lightmappedgeneric shaders?
vec2 t_BumpmapTexCoord = ${MaterialUtil.ifDefineBool(m, `USE_BUMPMAP`, `Mul(u_BumpmapTransform, vec4(v_TexCoord0.zw, 1.0, 1.0))`, `vec2(0.0)`)};
vec2 t_BumpmapTexCoord = ${MaterialUtil.ifDefineBool(m, `USE_BUMPMAP`, `u_BumpmapTransform * vec4(v_TexCoord0.zw, 1.0, 1.0)`, `vec2(0.0)`)};
vec4 t_BumpmapSample = vec4(0.0);
vec3 t_BumpmapNormal;
Expand All @@ -683,7 +683,7 @@ void mainPS() {
bool use_bumpmap2 = ${MaterialUtil.getDefineBool(m, `USE_BUMPMAP2`)};
if (use_bumpmap2) {
vec2 t_Bumpmap2TexCoord = ${MaterialUtil.ifDefineBool(m, `USE_BUMPMAP2`, `Mul(u_Bumpmap2Transform, vec4(v_TexCoord0.zw, 1.0, 1.0))`, `vec2(0.0)`)};
vec2 t_Bumpmap2TexCoord = ${MaterialUtil.ifDefineBool(m, `USE_BUMPMAP2`, `u_Bumpmap2Transform * vec4(v_TexCoord0.zw, 1.0, 1.0)`, `vec2(0.0)`)};
vec4 t_Bumpmap2Sample = UnpackNormalMap(texture(SAMPLER_2D(u_TextureBumpmap2), t_Bumpmap2TexCoord));
bool use_bumpmask = ${MaterialUtil.getDefineBool(m, `USE_BUMPMASK`)};
Expand Down Expand Up @@ -901,7 +901,7 @@ void mainPS() {
#if defined USE_PROJECTED_LIGHT
// Projected Light (Flashlight, env_projected_texture)
vec4 t_ProjectedLightCoord = Mul(u_ProjectedLightFromWorldMatrix, vec4(v_PositionWorld.xyz, 1.0));
vec4 t_ProjectedLightCoord = u_ProjectedLightFromWorldMatrix * vec4(v_PositionWorld.xyz, 1.0);
t_ProjectedLightCoord.xyz /= t_ProjectedLightCoord.www;
// Clip space is between -1 and 1. Move it into 0...1 space.
Expand Down
12 changes: 6 additions & 6 deletions src/SourceEngine/Materials/Material_Modulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ precision mediump float;
${MaterialShaderTemplateBase.Common}
layout(std140) uniform ub_ObjectParams {
Mat4x2 u_BaseTextureTransform;
layout(std140, row_major) uniform ub_ObjectParams {
mat4x2 u_BaseTextureTransform;
};
varying vec3 v_PositionWorld;
Expand All @@ -32,12 +32,12 @@ uniform sampler2D u_BaseTexture;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
v_TexCoord0.xy = Mul(u_BaseTextureTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.xy = u_BaseTextureTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/SourceEngine/Materials/Material_Refract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ layout(binding = 11) uniform samplerCube u_TextureEnvmap;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
vec3 t_NormalWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_Normal.xyz, 0.0)));
vec3 t_NormalWorld = normalize(t_WorldFromLocalMatrix * vec4(a_Normal.xyz, 0.0));
vec3 t_TangentSWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_TangentS.xyz, 0.0)));
vec3 t_TangentSWorld = normalize(t_WorldFromLocalMatrix * vec4(a_TangentS.xyz, 0.0));
vec3 t_TangentTWorld = cross(t_TangentSWorld, t_NormalWorld);
v_TangentSpaceBasis0 = t_TangentSWorld * a_TangentS.w;
Expand Down
20 changes: 10 additions & 10 deletions src/SourceEngine/Materials/Material_Sky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ layout(binding = 0) uniform sampler2D u_Texture;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
v_TexCoord0.xy = Mul(u_BaseTextureTransform, vec4(a_TexCoord01.xy, 0.0, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
v_TexCoord0.xy = u_BaseTextureTransform * vec4(a_TexCoord01.xy, 0.0, 1.0);
}
#endif
Expand All @@ -58,8 +58,8 @@ precision mediump float;
${MaterialShaderTemplateBase.Common}
layout(std140) uniform ub_ObjectParams {
Mat4x2 u_BaseTextureTransform;
layout(std140, row_major) uniform ub_ObjectParams {
mat4x2 u_BaseTextureTransform;
vec4 u_TextureSizeInfo;
vec4 u_ColorScale;
};
Expand All @@ -77,11 +77,11 @@ layout(binding = 0) uniform sampler2D u_TextureHdrCompressed;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
vec2 t_TexCoord = Mul(u_BaseTextureTransform, vec4(a_TexCoord01.xy, 0.0, 1.0));
vec2 t_TexCoord = u_BaseTextureTransform * vec4(a_TexCoord01.xy, 0.0, 1.0);
v_TexCoord0.xy = t_TexCoord + vec2(-u_TexelXIncr, -u_TexelYIncr);
v_TexCoord0.zw = t_TexCoord + vec2( u_TexelXIncr, -u_TexelYIncr);
Expand Down
24 changes: 12 additions & 12 deletions src/SourceEngine/Materials/Material_SolidEnergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ precision mediump float;
${MaterialShaderTemplateBase.Common}
layout(std140) uniform ub_ObjectParams {
Mat4x2 u_BaseTextureTransform;
layout(std140, row_major) uniform ub_ObjectParams {
mat4x2 u_BaseTextureTransform;
#if defined USE_DETAIL
Mat4x2 u_Detail1TextureTransform;
Mat4x2 u_Detail2TextureTransform;
mat4x2 u_Detail1TextureTransform;
mat4x2 u_Detail2TextureTransform;
#endif
#if defined USE_FLOWMAP
vec4 u_Misc[3];
Expand Down Expand Up @@ -57,28 +57,28 @@ layout(binding = 5) uniform sampler2D u_TextureFlowBounds;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
v_PositionWorld.w = -gl_Position.z;
#if !GFX_CLIPSPACE_NEAR_ZERO()
v_PositionWorld.w = v_PositionWorld.w * 0.5 + 0.5;
#endif
vec3 t_NormalWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_Normal.xyz, 0.0)));
vec3 t_NormalWorld = normalize(t_WorldFromLocalMatrix * vec4(a_Normal.xyz, 0.0));
vec3 t_TangentSWorld = normalize(Mul(t_WorldFromLocalMatrix, vec4(a_TangentS.xyz, 0.0)));
vec3 t_TangentSWorld = normalize(t_WorldFromLocalMatrix * vec4(a_TangentS.xyz, 0.0));
vec3 t_TangentTWorld = cross(t_TangentSWorld, t_NormalWorld);
v_TexCoord0.xy = Mul(u_BaseTextureTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.xy = u_BaseTextureTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
v_TexCoord0.zw = vec2(0.0);
v_TexCoord1.xyzw = vec4(0.0);
#if defined USE_DETAIL
v_TexCoord1.xy = Mul(u_Detail1TextureTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord1.zw = Mul(u_Detail2TextureTransform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord1.xy = u_Detail1TextureTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
v_TexCoord1.zw = u_Detail2TextureTransform * vec4(a_TexCoord01.xy, 1.0, 1.0);
#endif
#if defined USE_FLOWMAP
Expand Down
6 changes: 3 additions & 3 deletions src/SourceEngine/Materials/Material_SpriteCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ layout(binding = 0) uniform sampler2D u_Texture;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0));
v_TexCoord0.xy = CalcScaleBias(a_TexCoord01.xy, u_BaseTextureScaleBias[0]);
v_TexCoord0.zw = CalcScaleBias(a_TexCoord01.xy, u_BaseTextureScaleBias[1]);
v_TexCoord1.xy = CalcScaleBias(a_TexCoord01.xy, u_BaseTextureScaleBias[2]);
Expand Down
16 changes: 8 additions & 8 deletions src/SourceEngine/Materials/Material_UnlitTwoTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ precision mediump float;
${MaterialShaderTemplateBase.Common}
layout(std140) uniform ub_ObjectParams {
Mat4x2 u_Texture1Transform;
Mat4x2 u_Texture2Transform;
layout(std140, row_major) uniform ub_ObjectParams {
mat4x2 u_Texture1Transform;
mat4x2 u_Texture2Transform;
vec4 u_ModulationColor;
};
Expand All @@ -35,13 +35,13 @@ uniform sampler2D u_Texture2;
#if defined VERT
void mainVS() {
Mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = Mul(t_WorldFromLocalMatrix, vec4(a_Position, 1.0));
mat4x3 t_WorldFromLocalMatrix = CalcWorldFromLocalMatrix();
vec3 t_PositionWorld = t_WorldFromLocalMatrix * vec4(a_Position, 1.0);
v_PositionWorld.xyz = t_PositionWorld;
gl_Position = Mul(u_ProjectionView, vec4(t_PositionWorld, 1.0));
gl_Position = u_ProjectionView * vec4(t_PositionWorld, 1.0);
v_TexCoord0.xy = Mul(u_Texture1Transform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.zw = Mul(u_Texture2Transform, vec4(a_TexCoord01.xy, 1.0, 1.0));
v_TexCoord0.xy = u_Texture1Transform * vec4(a_TexCoord01.xy, 1.0, 1.0);
v_TexCoord0.zw = u_Texture2Transform * vec4(a_TexCoord01.xy, 1.0, 1.0);
}
#endif
Expand Down
Loading

0 comments on commit e889f8f

Please sign in to comment.