PDA

View Full Version : OpenGL Texture masking problem



JC_
04-04-2010, 11:37 AM
Hello,

im trying mask textrures but it blend colors, how fix it or exist other way ?

http://img406.imageshack.us/img406/4687/maskbad.png



glEnable(GL_BLEND); // Enable Blending

Images['ground_dirt'].draw(5,5,0); // dirt texture

glBlendFunc(GL_DST_COLOR,GL_ZERO);
Images['transition01'].draw(5,5,0); // mask texture

glBlendFunc(GL_ONE, GL_ONE);
Images['ground_grass'].draw(5,5,0); // grass texture

glDisable(GL_BLEND);

chronozphere
05-04-2010, 09:18 AM
Have you tried inverting the "transition" image (black becomes white, white becomes black)?

Also, how does it look when you do this?



glEnable(GL_BLEND); // Enable Blending

Images['ground_dirt'].draw(5,5,0); // dirt texture

glBlendFunc(GL_DST_COLOR,GL_ZERO);
Images['transition01'].draw(5,5,0); // mask texture

//Leave grass texture out!

glDisable(GL_BLEND);

JC_
05-04-2010, 10:06 AM
inverted colors:
http://img130.imageshack.us/img130/1324/maskrevcol.png

no grass texture made this:
http://img405.imageshack.us/img405/841/maskproblem.png

JC_
13-11-2010, 05:00 PM
well.. blend func is not good way and i cant find tutorial for texture splatting (like this Direct3d - http://www.gamedev.net/reference/articles/article2238.asp), can anyone help ?

WILL
13-11-2010, 07:58 PM
Don't know if this helps, but if you had a mask that was alpha blended, that might work. Trick is you need a graphics program that will generate the proper alpha blending where you need it. Not all of them are the most intuitive when it comes to drawing in alpha.

chronozphere
14-11-2010, 01:15 AM
You can do it in two different ways:

Single-pass: I'd recommend you to start using shaders. You can combine 4 textures in your shader, of say dirt, grass, snow, rock in your terrain and use one RGBA texture where each channel represents one texture. This works pretty fast on today's hardware.
You could probably do something similar in OpenGL by setting the right states, but I'm not sure how (I know it's possible in D3D, like the article shows).

Multi-pass: You can render the terrain multiple times using alpha-blending. This is not the most efficient way and therefore not my favorite. But it might be good if you don't want go down the shader path. :)