Skip to content

Commit a23da70

Browse files
committed
Address PR comments
1 parent 86b881a commit a23da70

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

packages/dev/core/src/Materials/materialHelper.functions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { Texture } from "./Textures/texture";
2323
import type { CubeTexture } from "./Textures/cubeTexture";
2424
import type { Color3 } from "core/Maths/math.color";
2525
import type { Geometry } from "../Meshes/geometry";
26-
import { Vector3 } from "core/Maths/math.vector";
2726

2827
// For backwards compatibility, we export everything from the pure version of this file.
2928
export * from "./materialHelper.functions.pure";
@@ -681,14 +680,14 @@ export function PrepareVertexPullingUniforms(geometry: Geometry): Nullable<Map<s
681680
* @param metadata The vertex pulling metadata
682681
*/
683682
export function BindVertexPullingUniforms(effect: Effect, metadata: Map<string, IVertexPullingMetadata>): void {
684-
if (!metadata || !effect) {
683+
if (!effect) {
685684
return;
686685
}
687686

688687
for (const [attribute, data] of metadata.entries()) {
689688
const uniformName = `vp_${attribute}_info`;
690689
// Pack into vec3: (offset, stride, type)
691-
effect.setVector3(uniformName, new Vector3(data.offset, data.stride, data.type));
690+
effect.setFloat3(uniformName, data.offset, data.stride, data.type);
692691
}
693692
}
694693

packages/dev/core/src/Materials/shaderMaterial.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,14 +901,27 @@ export class ShaderMaterial extends PushMaterial {
901901
}
902902
}
903903

904+
const renderingMesh = subMesh ? subMesh.getRenderingMesh() : mesh;
905+
if (renderingMesh && this.useVertexPulling) {
906+
// Add vertex buffer metadata defines for proper stride/offset handling
907+
const geometry = renderingMesh.geometry;
908+
if (geometry) {
909+
this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry);
910+
if (this._vertexPullingMetadata) {
911+
for (const [attribute] of this._vertexPullingMetadata.entries()) {
912+
uniforms.push(`vp_${attribute}_info`);
913+
}
914+
}
915+
}
916+
}
917+
904918
if (this.customShaderNameResolve) {
905919
uniforms = uniforms.slice();
906920
uniformBuffers = uniformBuffers.slice();
907921
samplers = samplers.slice();
908922
shaderName = this.customShaderNameResolve(this.name, uniforms, uniformBuffers, samplers, defines, attribs);
909923
}
910924

911-
const renderingMesh = subMesh ? subMesh.getRenderingMesh() : mesh;
912925
if (renderingMesh && this.useVertexPulling) {
913926
defines.push("#define USE_VERTEX_PULLING");
914927

@@ -919,12 +932,6 @@ export class ShaderMaterial extends PushMaterial {
919932
defines.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS");
920933
}
921934
}
922-
923-
// Add vertex buffer metadata defines for proper stride/offset handling
924-
const geometry = renderingMesh.geometry;
925-
if (geometry) {
926-
this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry);
927-
}
928935
}
929936

930937
const drawWrapper = storeEffectOnSubMeshes ? subMesh._getDrawWrapper(undefined, true) : this._drawWrapper;

packages/dev/core/src/ShadersWGSL/iblVoxelGrid.vertex.fx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ uniform invWorldScale: mat4x4f;
3333
varying vNormalizedPosition : vec3f;
3434
flat varying f_swizzle: i32;
3535

36-
uniform vp_position_info: vec3f; // (bufferIndex, offset, stride, type)
36+
uniform vp_position_info: vec3f; // (offset, stride, type)
3737

3838
fn convertToFloat(word: u32, byteInWord: u32, dataType: u32) -> f32 {
3939
switch (dataType) {

0 commit comments

Comments
 (0)