3D Texture Examples


I’m attempting to use 3D textures - that is to say, a texture that is 3D data, and can be used to texture arbitrary shapes (the app I’m working on has user-generated geometry). As an example, my ideal end result would be being able to apply a 3D texture that is essentially a cube of wood, including grain structures etc., to any shape, to make it appear as though that shape was machined/carved out of wood.

Anyway, my attempts to use RawTexture3D are so far failing; I am simply getting a black object. See my playground here:

Does anyone have any experience of 3D textures in BabylonJS, or know where I’m going wrong?

Many thanks,

Welcome aboard!

A 3D texture requires to be sampled differently from a 2D texture, namely with a sampler3D instead of a sampler2D. The standard material (and PBR material) only uses 2D sampler, so it won’t work with those materials.

I think you need to write your own custom shader to be able to use 3D textures.