mikolalysenko / ao-mesher

Voxel mesher with ambient occlusion
http://mikolalysenko.github.io/ao-shader/index.html
MIT License
40 stars 7 forks source link

Add support for per-side voxel texturing #1

Closed deathcap closed 10 years ago

deathcap commented 10 years ago

Currently, the texture index is extracted directly from the voxel ID (voxel&0xff), so all faces have the same texture. This PR adds an optional voxelSideTextureIDs 2d ndarray argument to computeMesh(), which can be used to assign different textures to each of the sides.

Using this in https://github.com/deathcap/voxel-stitch/commit/c05021b5efe433da8a935f8a8c58d049021315e8

deathcap commented 10 years ago

Hm, I'm not sure if the side calculation is correct, it seems side passed to voxelTexture is always either 0 or 3 (if flipped). Testing texturing each of the six faces differently, but only the right-facing face (side 3) has a different texture, all others use the side 0 index:

screen shot 2014-04-05 at 2 05 31 pm

deathcap commented 10 years ago

Fixed =) d+(flip?3:0)

screen shot 2014-04-05 at 2 23 48 pm

mikolalysenko commented 10 years ago

Thanks! Merged