Skip to content

Commit

Permalink
Mdx 1100 parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanTretyakov committed Jan 11, 2025
1 parent bbfa0ba commit 46140b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
20 changes: 19 additions & 1 deletion mdx/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ function parseMaterials (model: Model, state: State, size: number): void {
material.PriorityPlane = state.int32();
material.RenderMode = state.int32();

if (model.Version >= 900) {
if (model.Version >= 900 && model.Version < 1100) {
material.Shader = state.str(80);
}

Expand Down Expand Up @@ -285,6 +285,24 @@ function parseMaterials (model: Model, state: State, size: number): void {
}
}

if (model.Version >= 1100) {
state.int32(); // hd flag
const textureCount = state.int32();

for (let j = 0; j < textureCount; j++) {
const textureId = state.int32(); //layer_texture.id
layer.CoordId = state.int32(); //slot

const keyword = state.keyword()
if (keyword === 'KMFT') {
layer.TextureID = state.animVector(AnimVectorType.INT1);
} else {
layer.TextureID = textureId;
state.pos -=4
}
}
}

while (state.pos < startPos2 + size2) {
const keyword = state.keyword();

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"exports": {
".": {
"require": "./dist/war3-model.js",
"import": "./dist/es/war3-model.js"
"import": "./dist/es/war3-model.js",
"types": "./dist/war3-model.d.ts"
},
"./dist/": "./dist/"
}
Expand Down
12 changes: 7 additions & 5 deletions renderer/modelRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2051,15 +2051,17 @@ export class ModelRenderer {
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, framebuffer);
this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.TEXTURE_2D, this.brdfLUT, 0);

this.gl.useProgram(this.integrateBRDF.program);

if (this.isHD) {
this.gl.useProgram(this.integrateBRDF.program);
}
this.gl.viewport(0, 0, BRDF_LUT_SIZE, BRDF_LUT_SIZE);
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);

this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.squareVertexBuffer);
this.gl.enableVertexAttribArray(this.integrateBRDF.attributes.aPos);
this.gl.vertexAttribPointer(this.integrateBRDF.attributes.aPos, 2, this.gl.FLOAT, false, 0, 0);

if (this.isHD) {
this.gl.enableVertexAttribArray(this.integrateBRDF.attributes.aPos);
this.gl.vertexAttribPointer(this.integrateBRDF.attributes.aPos, 2, this.gl.FLOAT, false, 0, 0);
}
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);

this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
Expand Down

0 comments on commit 46140b6

Please sign in to comment.