TiledBox warning when tileSize was not equal to size and faceColors was defined

Hey, I used the CreateTiledBox method created a tiled box,defined the faceColors property in the options,but if the tileSize was not equal to the size,the box render with errors and webgl report warnings on the console panel.

Here is the demo:

Checking!

I have no error in the console :frowning:

I can not repro either

Oh,I see what happend,I tested this demo on MacOS using Edge,and I changed the platform to Windows,eveything was normal

MacOS version 15.6.1 M series chip;
Edge version 139.0.3405.119

The WebGL error is caused by an issue in the part of the code which builds the vertex positions.
The mesh from the PG has 2400 / 3 = 800 vertices :wink: What?

Since the color buffer is built correctly with the correct size but the positions buffer is overpopulated the buffer sizes just don’t match up. MacOS’s Metal is quite unforgiving on this thus you see the error. Windows just doesn’t give a f*ck about it.

Quick fix:
Omit faceColors from the options. Since you set it to white it’ll do no harm.

Permanent fix:
We have to check what is happening with the vertices, why are there so many of them.

@sebavan @Deltakosh I’ll take care of it.

2 Likes

Thanks for your help

1 Like

I just wanna share my progress: It seems that sideOrientation: BABYLON.Mesh.DOUBLESIDE not doubles but quadruples the number of faces.

Yes, I found the same problem when I changed this property in a previous test

I see something from the souce code when tiled box process the sideOreintation.At first it used CreateTiledPlaneVertexData method processed the sideOreintation already,and then at the end of the source code of the CreateTiledBoxVertexData it process the sideOrientation again,right?

I love you

1 Like

Enough to share your Netflix pwd?

1 Like

Man! I think we reached that point now! I’m ready!!

Netflix is basic. If you really loved me, you’d hand over your Hulu account. :kissing_face_with_smiling_eyes:

:smiley:

We are not yet there but keep courting me and maybe we can :smiley:

Only a few hours in and you’re already acting like the long-suffering partner LOL

1 Like

The problem is that after the whole tiled box is constructed using multiple calls to CreateTiledPlaneVertexData this function is called VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs) which as you can see takes into account the sideOrientation parameter. If it’s set to VertexData.DOUBLESIDE it doubles the vertex positions once again.

Since we get everyting (positions, normals, uvs) prepared from the CreateTiledPlaneVertexData function calls, I believe that extra call to _ComputeSides can be safely removed.

I also optimized another part of the code and got rid of the awful map and reduce calls and rewrote that part of the code to be faster and much easier to understand.

Now there was another problem. Each side of the box can be subdivided into multiple faces (controlled by tileSize, tileWidth, tileHeight). The original implementation didn’t take this into account. It treated the mesh as it had always only one face at a side. I fixed this issue as well. I’m curious for how long wasn’t this nasty bug discovered… Seems no one uses tiled boxes :smiley:

PR on the way:

@Deltakosh I made several tests, seems to be OK. I hope I didn’t screw anything. However, as you already know I’ll be on vacation starting tomorrow so if I f*cked up something please be so kind and take care of it, honey :smiley: When I come back I’ll cook you something yummy and maybe I’ll take you to the cinema as well :smiley:

Wow,thanks,have a good vacation!:smiling_face_with_three_hearts:

1 Like