PDA

View Full Version : Multipass to multitexturing for tile engine



gossi
04-05-2009, 07:49 AM
Currently I am building a tile map engine for a 2D game using OpenGL ES.
The tiles are on one big atlas texture with RGBA. For smooth transitions between diffrent terrains and objects on the playfield several tiles have to be rendered over each other (up to 4 terrain parts + 1 object or wall).
Currently I am using Multipass rendering which gives me the wanted results but too slow.

Currently I am trying to set up multitexturing but I don't get the expected results.
My current approaches deliver the results I want for the RGB values but the transparency does not work :-(
For RGB I use GL_INTERPOLATE.

Which mode must I use for the Transparency? None of the modes seems to do what I expect.

Because of hardware restrictions I can only use 2 texture stages and have to fall back to mutipass rendering if the number of tiles to be overlayed exceeds 2.

How Do I set up the texture stages to get the same result as with glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) ?

BionicBytes
04-06-2009, 01:32 AM
You could set up a shader and an FBO.
You could then replicate a simple blend in GLSL by reading the SRC texture and it's alpha and use GLSL mix function to blend with a second SRC texture.

src = Texture2D (srcdecal1, texcoord);
src2 = Texture2D (srcdecal2, texcoord);

gl_FragColor = mix (src, src2, src.a);