Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperLicht
Enable Alpha test
Author Text

Registered User
2011-10-21 11:51:48

To get transparancy to work for my 3d objects, I use a shader, and I have to use a alpha test to avoid writing the pixles that should be transparent.

But according to some sites Ive been reading there are some OpenGL functions that can set this alpha check directly, so I dont have to do it in the shader, mainly the functions glAlphaFunc() and glEnable().

Are there a way to access these functions, or similar functions within Copperlicht? i know you can get some things from the getWebGL() function, but I got a error message when trying to use the above functions with it.

2011-10-21 13:56:15

When you create your own material, you can specify the blend function yourself. The renderer::createMaterialType() function acccepts the following parameters:

createMaterialType(vertexShaderSource, fragmentShaderSource, blendenabled, blendsfactor, blenddfactor)

For addititve blending for example, set the last three parametersto this:

(Where 'gl' is the webgl object, you can get it using renderer.getWebGL())

See the 'Custom materials and shaders' tutorial in the documentation for details.

Registered User
2011-10-21 14:16:11

Yes, that I have already done, and using a shader works fine. Thats not the problem. When I create the shader material, Im using gl.SRC_ALPHA and gl.ONE_MINUS_SRC_ALPHA for my. But it doesnt blend out the black pixles in the texture.

But, if I add:

if(FirstTex.a < 0.5)

into the shader it does the blending. And as far as I read on the internet, this is because of the depth buffer in OpenGL. And to save the trouble of the shader call above, it says you can use glAlphaFunc() and glEnable() like so:


so I was wondering if there was a way to use the glAlphaFun and glEnable in Copperlicht.

2011-10-21 14:23:04

Ah, sorry for the misunderstanding. As far as I know, WebGL doesn't support glalphaFunc, so what you are doing is right.

Registered User
2011-10-21 14:30:09

okey, then I know! well, then I will keep running the alpha-test from the shader until further notice! :-)

Registered User
2019-06-10 10:50:26

want to know if it is possible to modify transparancy of an png image attached to a 2D mesh through js scripting/actions etc.

2D_Overlay meshes do have the "Alpha" property but i cant use them, as my image and 2d Mesh are to large (approx 10x device.width)

feature needed for the android platform.


Create reply:

Posted by: (you are not logged in)

Enter the missing letter in: "Intern?tional" (you are not logged in)




Possible Codes

Feature Code
Link [url] [/url]
Bold [b]bold text[/b]
Image [img][/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]



Copyright© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact