So I’ve tried every API call I can think of in getting this to work (Blend, BlendFunc, DepthTest, AlphaTest) and still no dice.
I’m making a 3D application with two ‘layers’.
The first is a tilted orthographic layer (game world) and the second is a flat orthographic layer (UI).
Both are saved using GL.Accum(AccumOp.Accum, 1f) and retrieved using GL.Accum(AccumOp.Return, 1f).
For the second layer I wrote small methods for binding and drawing textures, as well as drawing basic rectangles (always handy) and they worked great.
The only issue is that when they’re not over a plain black surface, they seem to additively blend into the layer behind them instead of opaque/alpha-blending.
When I try GL.Accum(AccumOp.Load, 1f) on the second layer it just paints black over the layer beneath it, so that doesn’t help.
http://users.tpg.com.au/bjcohn/voxel/accum0.png - No blending
http://users.tpg.com.au/bjcohn/voxel/accum1.png - Partial
http://users.tpg.com.au/bjcohn/voxel/accum2.png - Full
Can anyone help me out?
I know it must only be a matter of putting the right line in the right place.
(my syntax may look a little weird as I’m using a C# wrapper, but any C/C++ calls you supply would still be accessible on my end)
Do not use accum. First, it is not needed to do this, and second, it is very rarely supported and obsolete.
Use blending, like :
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); // for premultiplied decals (preferred)
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // otherwise (but may exhibit slight grey halos around opaque parts)
I’m using accum because I need to have one layer at an angle and another completely flat. Without it my UI is rendered on an angle as well.
Is there a better way to readjust the camera and continue drawing than accum?
Rendering multiple view angles has absolutely nothing to do with accum.
Read this : http://www.opengl.org/wiki/Viewing_and_T…3D_rendering.3F
Then show your code if you are still stuck.
Jeez, there’s a lot of it.
Here’s the immediate pre-draw stuff.
GL.Ortho(-(windowWidth / 2), (windowWidth / 2), (windowHeight / 2), -(windowHeight / 2), -1536f, 1536f);
Matrix4 m = Matrix4.CreateOrthographic(windowWidth, windowHeight, -1536f, 1536f);
Matrix4 lookat = Matrix4.LookAt(cameraCurrentX, cameraCurrentY, cameraCurrentZ, cameraPositionX, cameraPositionY, 0.0f, 0.0f, 1.0f, 0f);
Holy [censored], I just removed all of my accum calls and it’s working flawlessly now!
[b]Almost there, but it seems to be playing around with translucency, opaquely drawing everything including transparent parts.
FYI, I’ve had:
in the code the whole time.[/b]
Disabled depthtest, drew 2D objects, re-enabled depthtest.
All good now.
Thanks a bunch!