for (l = 0 ; l<2 ; l++)
{
glEnable(GL_BLEND);
if (l==0)
{
glBlendFunc(GL_DST_COLOR,GL_ZERO);
material.texture();
}
if (l==1)
{
glBlendFunc(GL_ZERO, GL_ONE);
material.alphatexture();
}
}
Strange blending
Okey, I''ve two questions about blending. First I''ll tell you about the code. I have made a milkshape ascii loader, and a alpha-bledning function in it. But it''s damn difficult to get the blending right. As milkshape has two 24bits textures for alpha, instead of one 32bits, the code gets more complex... I think. Anyway. First I load the the texture and the alpha texture. Then I use blending on them, and it works but still a problem occurs and I can solve it.
Here''s the code, ofcourse it''s more to it, but this is the part I''m wondering about..
The things that dosent work correct is shown below in the screenshot. Pic 1 and 2 displays two trees. Since I removed the texture on the ground, it''s not clearly that the blending works, but it does. Well, it works with the ground but not with another blended tree. When overlapping each others the first tree''s blended parts makes the second tree''s parts invisible. Yeah, the screenshot shows it and I hope you understand what I mean. And pic #3 shows fog in blending. I read that it''s hard to make it work together, but it must be possible since many games uses it, so does anybody know how?
I need to solve this so any help and ideas is very helpful to me.
The first problem is caused by writing the whole polygon into Z buffer, so when the second tree is drawn behind it it thinks it''s occluded and doesn''t draw the "hidden" part. Sort the trees (and any other translucent polygons) from back to front (and disable depth write).
You could also use alphatest instead of alpha blending. The edges of the sprite will look sharper which you may or may not like... But it''s faster and will probably fix the problems you''re having.
You could also use alphatest instead of alpha blending. The edges of the sprite will look sharper which you may or may not like... But it''s faster and will probably fix the problems you''re having.
AP is correct on the first point, but don''t alpha test. It looks ugly on cards which cheat at "FS"AA and only smooth the edges. (radeon 9700 for example).
Alpha blending is dependent on the order of the objects, and it is also more expensive...
Height Map Editor | Eternal Lands | Fast User Directory
Height Map Editor | Eternal Lands | Fast User Directory
If you use Alpha testing, you will not have this bug with the fog. Else, if you want to keep Blending, just disable FOG when drawing your trees, and fade them to the color of the fog depending the distance...
So, its more easy and powerful to use Alpha testing
So, its more easy and powerful to use Alpha testing
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement