Procedural mesh, textured outside, with coloured layers

Hi all,

Not sure how to word this so bear with me.

I’m generating a procedural mesh, which is a 9x9 grid of cubes. I’ve written it so that none of the internal faces are rendered, until a cube above it had been removed, at which point the new faces are added. Think Minecraft voxels.

What I’d like to do is to have a texture over the entire outside of the cube, and then for each layer of the cube down towards its centre, have a different colour.

So the outside would have some arbitrary texture, and when a hole is punched in it, it shows a green cube beneath, and then a yellow cube beneath that, and so on down.

Is this something that is best achieved with a customer shader, or can anyone suggest another way of doing this?

Thanks

I wouldn’t reach for a shader here but I suppose you could.

You’re welcome to look at my MakeGeo project which has a pile of random procedural geometry routines in it, including generating fresh geometry and assigning UVs and materials.

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo