Render a half cube using the same texture as a full cube

Playground: Babylon.js Playground

I am trying to make a half-cube using a square texture. The issue with this is that i can’t figure out how to clip the texture so its only the top/bottom half of it.
So i end up with bottom edges down too far:

1 Like

You could experiment with Map Materials to Individual Mesh Faces | Babylon.js Documentation

well i cant really use a texture atlas, thats not how the texture files render
or are you saying use the texture image as an atlas?

Yes, set the uvs for each face to select the portion of the texture you need. Worth a try!?

looks like faceUV only works on CreateBox which wont work since each side of the block could have a different texture

Are you using a custom mesh for your half cube? A playground would be useful to show your specific issue.

there is a playground link in the post

Oops, sorry. Try upscale, vscale and offsets on your plane textures More Materials | Babylon.js Documentation.

Have to go now

i added this:

[leftTex1, leftTex2, rightTex1, rightTex2].forEach((t) => {
    t.vScale = 0.5;

and it changed nothing

You should be able to play with the tiling properties to achieve your goal:

You can normally with this display or tile all the regions you need,


is there a way to make a rectangular plane? or do i have to merge 2 planes together

You can use the MeshBuilder APIs instead as they provide more options:

BABYLON.MeshBuilder.CreatePlane(`top`, { width: 1, height: 4 }, scene);