Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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. |
||||
|
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: true, gl.ONE, gl.ONE_MINUS_SRC_COLOR (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. |
||||
|
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:
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. |
||||
|
Ah, sorry for the misunderstanding. As far as I know, WebGL doesn't support glalphaFunc, so what you are doing is right. |
||||
|
okey, then I know! well, then I will keep running the alpha-test from the shader until further notice! :-) |
||||
|
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. thanks |
|