Transparency has to be done in shaders. You should add something like this to your model.shader (or create a custom .shader file):
Code:
[FX]
... // some code here
// Uniforms
...
float opacity = 1.0; // variable that controls opacity of the object
// contexts
context TRANSLUCENT
{
VertexShader = compile GLSL VS_GENERAL;
PixelShader = compile GLSL FS_TRANSLUCENT;
ZWriteEnable = false;
BlendMode = Blend;
}
... // some code here
[[FS_TRANSLUCENT]]
// =================================================================================================
uniform sampler2D albedoMap;
varying vec2 texCoords;
uniform float opacity;
void main( void )
{
// gl_FragColor = texture2D( albedoMap, texCoords * vec2( 1, -1 ) ); // use this line to use transparency from the texture (png, tga with alpha channel)
vec3 newCoords = vec3( texCoords, 0 );
newCoords.t *= -1.0; // Flip texture vertically to match the GL coordinate system
vec4 albedo = texture2D( albedoMap, newCoords.st );
gl_FragColor = vec4( albedo.rgb, opacity ); // use this line to control transparency from material
}
Then, in your material, you should write something like this:
Code:
<Uniform name="opacity" a="0.5" /> // for 50% transparency
Note: you should use this with forward pipeline. Deferred pipeline has some issues with rendering transparent surfaces.