diff --git a/src/BanjoKazooie/render.ts b/src/BanjoKazooie/render.ts index 40cd1462f..2550fbc38 100644 --- a/src/BanjoKazooie/render.ts +++ b/src/BanjoKazooie/render.ts @@ -33,8 +33,8 @@ export class F3DEX_Program extends DeviceProgram { public override both = ` precision mediump float; -layout(std140) uniform ub_SceneParams { - Mat4x4 u_Projection; +layout(std140, row_major) uniform ub_SceneParams { + mat4 u_Projection; #ifdef LIGHTING #ifdef TEXTURE_GEN vec4 u_LookAtVectors[2]; @@ -47,9 +47,9 @@ layout(std140) uniform ub_SceneParams { #endif }; -layout(std140) uniform ub_DrawParams { - Mat4x3 u_BoneMatrix[BONE_MATRIX_COUNT]; - Mat4x2 u_TexMatrix[2]; +layout(std140, row_major) uniform ub_DrawParams { + mat4x3 u_BoneMatrix[BONE_MATRIX_COUNT]; + mat4x2 u_TexMatrix[2]; }; layout(std140) uniform ub_CombineParameters { @@ -93,7 +93,8 @@ vec3 ConvertToSignedInt(vec3 t_Input) { void main() { int t_BoneIndex = int(a_Position.w); - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_BoneMatrix[t_BoneIndex]), vec4(a_Position.xyz, 1.0))); + vec3 t_PositionView = u_BoneMatrix[t_BoneIndex] * vec4(a_Position.xyz, 1.0); + gl_Position = u_Projection * vec4(t_PositionView, 1.0); v_Color = t_One; #ifdef USE_VERTEX_COLOR @@ -104,15 +105,16 @@ void main() { v_Color.rgb = Monochrome(v_Color.rgb); #endif - v_TexCoord.xy = Mul(u_TexMatrix[0], vec4(a_TexCoord, 1.0, 1.0)); - v_TexCoord.zw = Mul(u_TexMatrix[1], vec4(a_TexCoord, 1.0, 1.0)); + v_TexCoord.xy = u_TexMatrix[0] * vec4(a_TexCoord, 1.0, 1.0); + v_TexCoord.zw = u_TexMatrix[1] * vec4(a_TexCoord, 1.0, 1.0); ${this.generateClamp()} #ifdef LIGHTING // convert (unsigned) colors to normal vector components vec4 t_Normal = vec4(ConvertToSignedInt(a_Color.rgb), 0.0); - t_Normal = normalize(Mul(_Mat4x4(u_BoneMatrix[t_BoneIndex]), t_Normal)); + vec3 t_NormalView = u_BoneMatrix[t_BoneIndex] * vec4(t_Normal.xyz, 0.0); + t_Normal = normalize(vec4(t_NormalView, 0.0)); #ifdef PARAMETERIZED_LIGHTING v_Color = ${this.generateLightingExpression()}; diff --git a/src/SuperMarioGalaxy/ImageEffect.ts b/src/SuperMarioGalaxy/ImageEffect.ts index 7abd8799b..857dc7bec 100644 --- a/src/SuperMarioGalaxy/ImageEffect.ts +++ b/src/SuperMarioGalaxy/ImageEffect.ts @@ -1,25 +1,23 @@ -import { SceneObjHolder, SceneObj } from "./Main.js"; -import { NameObj, CalcAnimType, MovementType } from "./NameObj.js"; -import { getMatrixTranslation } from "../MathHelpers.js"; import { vec3 } from "gl-matrix"; -import { AreaObj, AreaObjMgr, AreaFormType } from "./AreaObj.js"; -import { JMapInfoIter, getJMapInfoArg7, getJMapInfoArg0, getJMapInfoArg1, getJMapInfoArg2, getJMapInfoArg3 } from "./JMapInfo.js"; -import { ZoneAndLayer } from "./LiveActor.js"; -import { fallback } from "../util.js"; -import { connectToScene, getAreaObj } from "./ActorUtil.js"; -import { DeviceProgram } from "../Program.js"; -import { TextureMapping } from "../TextureHolder.js"; -import { nArray, assert } from "../util.js"; -import { GfxWrapMode, GfxTexFilterMode, GfxBindingLayoutDescriptor, GfxMipFilterMode, GfxBlendMode, GfxBlendFactor, GfxMegaStateDescriptor, GfxFormat, GfxProgram, GfxTextureDimension, GfxSamplerFormatKind } from "../gfx/platform/GfxPlatform.js"; -import { fillVec4 } from "../gfx/helpers/UniformBufferHelpers.js"; -import { GfxRenderInst, GfxRenderInstManager } from "../gfx/render/GfxRenderInstManager.js"; import { fullscreenMegaState, makeMegaState, setAttachmentStateSimple } from "../gfx/helpers/GfxMegaStateDescriptorHelpers.js"; -import { MathConstants } from "../MathHelpers.js"; -import { GfxrAttachmentSlot, GfxrRenderTargetDescription, GfxrGraphBuilder, GfxrRenderTargetID } from "../gfx/render/GfxRenderGraph.js"; import { GfxShaderLibrary, glslGenerateFloat } from "../gfx/helpers/GfxShaderLibrary.js"; import { IsDepthReversed } from "../gfx/helpers/ReversedDepthHelpers.js"; +import { fillVec4 } from "../gfx/helpers/UniformBufferHelpers.js"; +import { GfxBindingLayoutDescriptor, GfxBlendFactor, GfxBlendMode, GfxFormat, GfxMegaStateDescriptor, GfxMipFilterMode, GfxProgram, GfxSamplerFormatKind, GfxTexFilterMode, GfxTextureDimension, GfxWrapMode } from "../gfx/platform/GfxPlatform.js"; +import { GfxrAttachmentSlot, GfxrGraphBuilder, GfxrRenderTargetDescription, GfxrRenderTargetID } from "../gfx/render/GfxRenderGraph.js"; +import { GfxRenderInst, GfxRenderInstManager } from "../gfx/render/GfxRenderInstManager.js"; import { GXShaderLibrary } from "../gx/gx_material.js"; +import { getMatrixTranslation } from "../MathHelpers.js"; +import { DeviceProgram } from "../Program.js"; +import { TextureMapping } from "../TextureHolder.js"; +import { assert, fallback, nArray } from "../util.js"; +import { connectToScene, getAreaObj } from "./ActorUtil.js"; +import { AreaFormType, AreaObj, AreaObjMgr } from "./AreaObj.js"; +import { JMapInfoIter, getJMapInfoArg0, getJMapInfoArg1, getJMapInfoArg2, getJMapInfoArg3, getJMapInfoArg7 } from "./JMapInfo.js"; +import { ZoneAndLayer } from "./LiveActor.js"; +import { SceneObj, SceneObjHolder } from "./Main.js"; +import { CalcAnimType, MovementType, NameObj } from "./NameObj.js"; const scratchVec3 = vec3.create(); diff --git a/src/WorldOfWarcraft/data.ts b/src/WorldOfWarcraft/data.ts index 51a923a7a..939361daa 100644 --- a/src/WorldOfWarcraft/data.ts +++ b/src/WorldOfWarcraft/data.ts @@ -63,6 +63,7 @@ import { getDerivativeBezier, getPointBezier } from "../Spline.js"; import { makeStaticDataBuffer } from "../gfx/helpers/BufferHelpers.js"; import { reverseDepthForCompareMode } from "../gfx/helpers/ReversedDepthHelpers.js"; import { + fillMatrix4x2, fillMatrix4x4, fillVec3v, fillVec4, @@ -1043,11 +1044,9 @@ export class ModelBatch { } public setModelParams(renderInst: GfxRenderInst) { - const numVec4s = 4; - const numMat4s = 3; let offset = renderInst.allocateUniformBuffer( ModelProgram.ub_MaterialParams, - numVec4s * 4 + numMat4s * 16, + 4 * 4 + 8 * 4, ); const uniformBuf = renderInst.mapUniformBufferF32( ModelProgram.ub_MaterialParams, @@ -1076,23 +1075,22 @@ export class ModelBatch { color[2], this.getVertexColorAlpha(), ); - offset += fillMatrix4x4( + offset += fillMatrix4x2( uniformBuf, offset, this.getTextureTransform(0), ); - offset += fillMatrix4x4( + offset += fillMatrix4x2( uniformBuf, offset, this.getTextureTransform(1), ); - const textureWeight: vec4 = [ + offset += fillVec4(uniformBuf, offset, this.getTextureWeight(0), this.getTextureWeight(1), this.getTextureWeight(2), this.getTextureWeight(3), - ]; - offset += fillVec4v(uniformBuf, offset, textureWeight); + ); } } diff --git a/src/WorldOfWarcraft/program.ts b/src/WorldOfWarcraft/program.ts index 82b4efa80..464607d8e 100644 --- a/src/WorldOfWarcraft/program.ts +++ b/src/WorldOfWarcraft/program.ts @@ -94,9 +94,9 @@ vec2 envmapTexCoord(const vec3 viewSpacePos, const vec3 viewSpaceNormal) { public static commonDeclarations = ` precision mediump float; -layout(std140) uniform ub_SceneParams { - Mat4x4 u_Projection; - Mat4x3 u_View; +layout(std140, row_major) uniform ub_SceneParams { + mat4 u_Projection; + mat4x3 u_View; vec4 u_CameraPos; // lighting @@ -249,21 +249,23 @@ void mainVS() { int colorIndex = int(a_ColorIndex); v_Color = vec4(1.0); if (colorIndex == ${SkyboxColor.Top}) { - v_Color = skyTopColor; + v_Color = skyTopColor; } else if (colorIndex == ${SkyboxColor.Middle}) { - v_Color = skyMiddleColor; + v_Color = skyMiddleColor; } else if (colorIndex == ${SkyboxColor.Band1}) { - v_Color = skyBand1Color; + v_Color = skyBand1Color; } else if (colorIndex == ${SkyboxColor.Band2}) { - v_Color = skyBand2Color; + v_Color = skyBand2Color; } else if (colorIndex == ${SkyboxColor.Smog}) { - v_Color = skySmogColor; + v_Color = skySmogColor; } else if (colorIndex == ${SkyboxColor.Fog}) { - v_Color = skyFogColor; + v_Color = skyFogColor; } else { - v_Color = vec4(1.0, 0.0, 1.0, 1.0); + v_Color = vec4(1.0, 0.0, 1.0, 1.0); } - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_View), vec4(a_Position, 0.0))); + + vec3 t_PositionView = u_View * vec4(a_Position, 0.0); + gl_Position = u_Projection * vec4(t_PositionView, 1.0); } #endif @@ -298,8 +300,8 @@ export class WmoProgram extends BaseProgram { public override both = ` ${BaseProgram.commonDeclarations} -layout(std140) uniform ub_ModelParams { - Mat4x3 u_Transform; +layout(std140, row_major) uniform ub_ModelParams { + mat4x3 u_Transform; }; layout(std140) uniform ub_BatchParams { @@ -338,12 +340,12 @@ layout(location = ${WmoProgram.a_TexCoord3}) attribute vec2 a_TexCoord3; ${GfxShaderLibrary.MulNormalMatrix} void mainVS() { - v_Position = Mul(u_Transform, vec4(a_Position, 1.0)).xyz; + v_Position = u_Transform * vec4(a_Position, 1.0); v_Normal = MulNormalMatrix(u_Transform, a_Normal); - vec3 viewPosition = Mul(_Mat4x4(u_View), vec4(v_Position, 1.0)).xyz; - vec3 viewNormal = Mul(_Mat4x4(u_View), vec4(v_Normal, 0.0)).xyz; - gl_Position = Mul(u_Projection, vec4(viewPosition, 1.0)); + vec3 viewPosition = u_View * vec4(v_Position, 1.0); + vec3 viewNormal = u_View * vec4(v_Normal, 0.0); + gl_Position = u_Projection * vec4(viewPosition, 1.0); int numColorBuffers = int(shaderParams.z); v_Color0 = numColorBuffers >= 1 ? a_Color0.bgra : vec4(0.0, 0.0, 0.0, 1.0); @@ -599,41 +601,6 @@ void mainPS() { `; } -export class DebugWmoPortalProgram extends BaseProgram { - public static a_Position = 0; - - public static ub_ModelParams = 1; - - public static bindingLayouts: GfxBindingLayoutDescriptor[] = [ - { - numUniformBuffers: super.numUniformBuffers + 1, - numSamplers: super.numSamplers, - }, - ]; - - public override both = ` -${BaseProgram.commonDeclarations} - -layout(std140) uniform ub_ModelParams { - Mat4x4 u_ModelMatrix; -}; - -#ifdef VERT -layout(location = ${DebugWmoPortalProgram.a_Position}) attribute vec3 a_Position; - -void mainVS() { - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_View), Mul(u_ModelMatrix, vec4(a_Position, 1.0)))); -} -#endif - -#ifdef FRAG -void mainPS() { - gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0); -} -#endif -`; -} - export class LoadingAdtProgram extends BaseProgram { public static a_Position = 0; @@ -651,8 +618,8 @@ ${BaseProgram.commonDeclarations} varying vec4 v_Color; -layout(std140) uniform ub_ModelParams { - Mat4x4 u_ModelMatrix; +layout(std140, row_major) uniform ub_ModelParams { + mat4x3 u_ModelMatrix; vec4 u_Params; // time, _, _, _ }; @@ -660,10 +627,10 @@ layout(std140) uniform ub_ModelParams { layout(location = ${LoadingAdtProgram.a_Position}) attribute vec3 a_Position; void mainVS() { - vec4 color1 = vec4(0.55); - vec4 color2 = vec4(0.75); v_Color = mix(skyFogColor, skyBand1Color, sin(u_Params.x) * 0.5 + 0.2); - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_View), Mul(u_ModelMatrix, vec4(a_Position, 1.0)))); + vec3 t_PositionWorld = u_ModelMatrix * vec4(a_Position, 1.0); + vec3 t_PositionView = u_View * vec4(t_PositionWorld, 1.0); + gl_Position = u_Projection * vec4(t_PositionView, 1.0); } #endif @@ -693,13 +660,13 @@ export class WaterProgram extends BaseProgram { ${BaseProgram.commonDeclarations} varying vec3 v_Color; -varying vec4 v_Position; +varying vec3 v_Position; varying vec2 v_TexCoord; varying float v_Depth; -layout(std140) uniform ub_WaterParams { +layout(std140, row_major) uniform ub_WaterParams { vec4 u_WaterParams; // LiquidCategory, _, _, _ - Mat4x4 u_ModelMatrix; + mat4x3 u_ModelMatrix; }; layout(binding = 0) uniform sampler2D u_Texture0; @@ -712,8 +679,10 @@ layout(location = ${WaterProgram.a_Depth}) attribute float a_Depth; void mainVS() { v_TexCoord = a_TexCoord; v_Depth = a_Depth; - v_Position = Mul(u_ModelMatrix, vec4(a_Position, 1.0)); - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_View), v_Position)); + + v_Position = u_ModelMatrix * vec4(a_Position, 1.0); + vec3 t_PositionView = u_View * vec4(v_Position, 1.0); + gl_Position = u_Projection * vec4(t_PositionView, 1.0); } #endif @@ -800,7 +769,8 @@ void mainVS() { v_Color = a_Color; v_Lighting = a_Lighting; v_Normal = a_Normal; - gl_Position = Mul(u_Projection, Mul(_Mat4x4(u_View), vec4(a_Position, 1.0))); + vec3 t_PositionView = u_View * vec4(a_Position, 1.0); + gl_Position = u_Projection * vec4(t_PositionView, 1.0); v_Position = a_Position.xyz; } #endif @@ -893,12 +863,12 @@ export class ModelProgram extends BaseProgram { if (uv.startsWith("t")) { let n = parseInt(uv[1]); if (n < 2) { - return ` v_UV${uvIndex} = Mul(texMat${n - 1}, vec4(a_TexCoord${n - 1}, 0.0, 1.0)).xy;`; + return ` v_UV${uvIndex} = texMat${n - 1} * vec4(a_TexCoord${n - 1}, 0.0, 1.0);`; } else { - return ` v_UV${uvIndex} = v_UV${n};`; + return ` v_UV${uvIndex} = v_UV${n};`; } } else if (uv === "env") { - return ` v_UV${uvIndex} = envCoord;`; + return ` v_UV${uvIndex} = envCoord;`; } else { throw `unrecognized uv ${uv}`; } @@ -912,36 +882,30 @@ ${BaseProgram.commonDeclarations} ${GfxShaderLibrary.MulNormalMatrix} struct DoodadInstance { - Mat4x3 transform; + mat4x3 transform; vec4 interiorAmbientColor; vec4 interiorDirectColor; vec4 lightingParams; // [applyInteriorLighting, applyExteriorLighting, interiorExteriorBlend/skyboxBlend, isSkybox] }; struct M2Light { - vec4 ambientColor; - vec4 diffuseColor; - vec4 position; // x, y, z, boneIndex - vec4 params; // attenuationStart, attenuationEnd, visible, _ -}; - -struct BoneParams { - Mat4x4 transform; - Mat4x4 postBillboardTransform; - vec4 params; // isSphericalBillboard, _, _, _ + vec4 ambientColor; + vec4 diffuseColor; + vec4 position; // x, y, z, boneIndex + vec4 params; // attenuationStart, attenuationEnd, visible, _ }; -layout(std140) uniform ub_DoodadParams { +layout(std140, row_major) uniform ub_DoodadParams { M2Light modelLights[4]; DoodadInstance instances[${MAX_DOODAD_INSTANCES}]; }; -layout(std140) uniform ub_MaterialParams { +layout(std140, row_major) uniform ub_MaterialParams { vec4 shaderTypes; // [pixelShader, vertexShader, _, _] vec4 materialParams; // [blendMode, unfogged, unlit, _] vec4 meshColor; - Mat4x4 texMat0; - Mat4x4 texMat1; + mat4x2 texMat0; + mat4x2 texMat1; vec4 textureWeight; }; @@ -973,69 +937,51 @@ float edgeScan(vec3 position, vec3 normal){ return clamp(2.7 * dotProductClamped * dotProductClamped - 0.4, 0.0, 1.0); } -Mat4x3 convertMat4(mat4 m) { - mat4 t = transpose(m); - Mat4x3 result; - result.mx = t[0]; - result.my = t[1]; - result.mz = t[2]; - return result; -} - -mat4 convertMat4x4(Mat4x4 m) { - return transpose(mat4(m.mx, m.my, m.mz, m.mw)); -} - -mat4 convertMat4x4(Mat4x3 m) { - return transpose(mat4(m.mx, m.my, m.mz, vec4(0, 0, 0, 1))); -} - -void calcBillboardMat(inout mat4 m) { +void calcBillboardMat(inout mat4x3 m) { vec3 upVec = vec3(0, 0, 1); vec3 forwardVec = normalize(u_CameraPos.xyz - m[3].xyz); vec3 leftVec = normalize(cross(upVec, forwardVec)); upVec = normalize(cross(forwardVec, leftVec)); - m[0] = vec4(forwardVec, 0.0); - m[1] = vec4(leftVec, 0.0); - m[2] = vec4(upVec, 0.0); + m[0] = forwardVec; + m[1] = leftVec; + m[2] = upVec; } -mat4 getBoneTransform(uint boneIndex) { +mat4x3 getBoneTransform(uint boneIndex) { vec4 mx = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(1, boneIndex), 0); vec4 my = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(2, boneIndex), 0); vec4 mz = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(3, boneIndex), 0); - return transpose(mat4(mx, my, mz, vec4(0, 0, 0, 1))); + return transpose(mat3x4(mx, my, mz)); } -mat4 getPostBillboardTransform(uint boneIndex) { +mat4x3 getPostBillboardTransform(uint boneIndex) { vec4 mx = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(4, boneIndex), 0); vec4 my = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(5, boneIndex), 0); vec4 mz = texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(6, boneIndex), 0); - return transpose(mat4(mx, my, mz, vec4(0, 0, 0, 1))); + return transpose(mat3x4(mx, my, mz)); } vec4 getBoneParams(uint boneIndex) { return texelFetch(TEXTURE(u_TextureBoneMatrix), ivec2(0, boneIndex), 0); } -Mat4x3 getBoneMatrix(uint index) { +mat4x3 getBoneMatrix(uint index) { DoodadInstance params = instances[gl_InstanceID]; vec4 boneParams = getBoneParams(index); - mat4 modelMatrix = convertMat4x4(params.transform); - mat4 transform = modelMatrix * getPostBillboardTransform(index); + mat4x3 transform = mat4x3(mat4(params.transform) * mat4(getPostBillboardTransform(index))); if (boneParams.x > 0.0) { calcBillboardMat(transform); } - transform = transform * getBoneTransform(index); - return convertMat4(transform); + transform = mat4x3(mat4(transform) * mat4(getBoneTransform(index))); + return transform; } -Mat4x3 getCombinedBoneMat() { - Mat4x3 result = _Mat4x3(0.0); - Fma(result, getBoneMatrix(a_BoneIndices.x), a_BoneWeights.x); - Fma(result, getBoneMatrix(a_BoneIndices.y), a_BoneWeights.y); - Fma(result, getBoneMatrix(a_BoneIndices.z), a_BoneWeights.z); - Fma(result, getBoneMatrix(a_BoneIndices.w), a_BoneWeights.w); +mat4x3 getCombinedBoneMat() { + mat4x3 result = mat4x3(0.0); + result += getBoneMatrix(a_BoneIndices.x) * a_BoneWeights.x; + result += getBoneMatrix(a_BoneIndices.y) * a_BoneWeights.y; + result += getBoneMatrix(a_BoneIndices.z) * a_BoneWeights.z; + result += getBoneMatrix(a_BoneIndices.w) * a_BoneWeights.w; return result; } @@ -1043,15 +989,15 @@ void mainVS() { DoodadInstance params = instances[gl_InstanceID]; bool isSkybox = params.lightingParams.w > 0.0; float w = isSkybox ? 0.0 : 1.0; - Mat4x3 boneTransform = getCombinedBoneMat(); - v_Position = Mul(_Mat4x4(boneTransform), vec4(a_Position, 1.0)).xyz; + mat4x3 boneTransform = getCombinedBoneMat(); + v_Position = boneTransform * vec4(a_Position, 1.0); v_Normal = MulNormalMatrix(boneTransform, a_Normal); - vec3 viewPosition = Mul(_Mat4x4(u_View), vec4(v_Position, w)).xyz; - vec3 viewNormal = Mul(_Mat4x4(u_View), vec4(v_Normal, 0.0)).xyz; + vec3 viewPosition = u_View * vec4(v_Position, w); + vec3 viewNormal = u_View * vec4(v_Normal, 0.0); - gl_Position = Mul(u_Projection, vec4(viewPosition, 1.0)); + gl_Position = u_Projection * vec4(viewPosition, 1.0); v_InstanceID = float(gl_InstanceID); // FIXME: hack until we get flat variables working vec4 combinedColor = clamp(meshColor, 0.0, 1.0); @@ -1130,7 +1076,7 @@ void mainPS() { float attenuationStart = light.params.x; float attenuationEnd = light.params.y; bool visible = light.params.z > 0.0; - vec3 posToLight = v_Position - Mul(_Mat4x4(doodad.transform), vec4(light.position.xyz, 1.0)).xyz; + vec3 posToLight = v_Position - (doodad.transform * vec4(light.position.xyz, 1.0)).xyz; float distance = length(posToLight); float diffuse = max(dot(posToLight, v_Normal) / distance, 0.0); float attenuation = 1.0 - clamp((distance - attenuationStart) * (1.0 / (attenuationEnd - attenuationStart)), 0.0, 1.0); @@ -1355,7 +1301,7 @@ export class ParticleProgram extends BaseProgram { ${BaseProgram.commonDeclarations} struct DoodadInstance { - Mat4x3 transform; + mat4x3 transform; }; layout(std140) uniform ub_EmitterParams { @@ -1363,7 +1309,7 @@ layout(std140) uniform ub_EmitterParams { vec4 ub_texScale; // x, y, _, _ }; -layout(std140) uniform ub_DoodadParams { +layout(std140, row_major) uniform ub_DoodadParams { DoodadInstance instances[${MAX_DOODAD_INSTANCES}]; }; @@ -1388,8 +1334,8 @@ void mainVS() { v_Color = texelFetch(TEXTURE(u_DataTex), ivec2(1, texelY), 0); vec2 scale = texelFetch(TEXTURE(u_DataTex), ivec2(2, texelY), 0).xy; vec2 texPos = texelFetch(TEXTURE(u_DataTex), ivec2(3, texelY), 0).xy; - v_Position = Mul(_Mat4x4(doodad.transform), vec4(pos, 1.0)).xyz; - vec4 viewSpacePos = Mul(_Mat4x4(u_View), vec4(v_Position, 1.0)); + v_Position = doodad.transform * vec4(pos, 1.0); + vec3 viewSpacePos = u_View * vec4(v_Position, 1.0); vec2 texScale = ub_texScale.xy; if (vertNum == 0) { viewSpacePos.x -= scale.x; @@ -1409,7 +1355,7 @@ void mainVS() { v_UV0 = texPos + vec2(0.0, 1.0) * texScale; } - gl_Position = Mul(u_Projection, vec4(viewSpacePos.xyz, 1.0)); + gl_Position = u_Projection * vec4(viewSpacePos.xyz, 1.0); } #endif diff --git a/src/WorldOfWarcraft/render.ts b/src/WorldOfWarcraft/render.ts index 7b2e76559..69620f576 100644 --- a/src/WorldOfWarcraft/render.ts +++ b/src/WorldOfWarcraft/render.ts @@ -944,7 +944,7 @@ export class LoadingAdtRenderer { let offs = renderInst.allocateUniformBuffer( LoadingAdtProgram.ub_ModelParams, - 16 + 4, + 12 + 4, ); const mapped = renderInst.mapUniformBufferF32( LoadingAdtProgram.ub_ModelParams, @@ -961,7 +961,7 @@ export class LoadingAdtRenderer { ADT_SIZE / 2, 500, ]); - offs += fillMatrix4x4(mapped, offs, this.scratchMat4); + offs += fillMatrix4x3(mapped, offs, this.scratchMat4); offs += fillVec4(mapped, offs, this.frequency * this.time); renderInst.setVertexInput( @@ -1112,13 +1112,13 @@ export class WaterRenderer { let offs = renderInst.allocateUniformBuffer( WaterProgram.ub_WaterParams, - 16 + 4, + 4 + 12, ); const mapped = renderInst.mapUniformBufferF32( WaterProgram.ub_WaterParams, ); offs += fillVec4(mapped, offs, liquidType.category); - offs += fillMatrix4x4(mapped, offs, modelMatrix); + offs += fillMatrix4x3(mapped, offs, modelMatrix); const liquidTextures = this.liquidTexturesByType.get( liquid.liquidType,