QuaziGNRLnose , I don't know too much about how alphtesting affects optimizations- I basically just re-enabled it. Your code had a syntax error with it, and a comment saying that having it enabled didn't seem to do anything- so I assumed the syntax error was the reason why it appeared not to do anything. Fixing the syntax error allowed alphatest to get applied.
I think alphatest is useful if you aren't using a shader, since you can discard fragments in the shader to get the same effect.
I wanted to try and get shadows working with alphatest using a custom depth material, like you said.
When I was writing a shader, I wanted to use texture2D to grab color data from a texture, but there wasn't any clear way to specify the texture in the uniforms, so I had to force it to get picked after the shader was loaded from the qfx file.
for example-
I figured out that this worked in the uniform section:
<uniforms>(function(){
var uniform = {
uniformCall : function(){
return {
texture: { type: 't', value: new THREE.Texture() },
amplitude: {type:'f', value: 0},
textureWidth: {type:'f', value: 256.0},
textureHeight: {type:'f', value: 256.0},
u_time: {type:'f', value: 0},
u_resolution: {type:'v2', value: new THREE.Vector2() },
camPos: {type: 'v3',value: new THREE.Vector3() }
};
}
}
return uniform;
})();
</uniforms>[/code:1mgxtn89]
But I wasn't sure how to reference the texture, so I had to add the following in runtime of q3dmodel plugin to get it to work:
[code:1mgxtn89]if(typeof _this.mat.uniforms !== 'undefined'){
if(typeof _this.mat.uniforms.texture !== 'undefined')_this.mat.uniforms.texture.value = _this.texturebank[0].frames[0].webGL_texture;
if(_this.matType !== -1 && _this.mat) _this.mat.transparent = ( _this.properties[34] === 0 );
}[/code:1mgxtn89]