deathcap / voxel-texture-shader

custom shader for texturing voxels in voxeljs (for three.js-based voxel-engine, no longer needed with voxel-engine-stackgl)
MIT License
8 stars 1 forks source link

Use transparent material params for alpha transparent textures #7

Closed deathcap closed 10 years ago

deathcap commented 10 years ago

voxel-texture creates a MeshFaceMaterial with two materials:

this.material = new this.THREE.MeshFaceMaterial([
  opaque,
  transparent
]);

and uses the first if !isTransparent, second otherwise. They only differ in that transparent: true is set in the material parameters.

voxel-texture-shader always uses the first material, with transparent: false, so it cannot handle alpha transparency. However the vertex shader does include:

'   if (gl_FragColor.a < 0.001) discard; // transparency',

for full transparency (glass), but it won't work for, e.g., water.

Should restore the secondary transparent material parameters.

deathcap commented 10 years ago

Fixed, here's what an example transparent texture now looks like:

screen shot 2014-02-22 at 6 55 11 pm

Note this is the same as voxel-texture:

screen shot 2014-02-22 at 6 55 25 pm

greenlion commented 10 years ago

Very nice!

Sent from my iPhone

On Feb 22, 2014, at 7:02 PM, deathcap notifications@github.com wrote:

Fixed, here's what an example transparent texture now looks like:

Note this is the same as voxel-texture:

— Reply to this email directly or view it on GitHub.