Correct texture blend

BlitzMax Forums/OpenGL Module/Correct texture blend

Snixx(Posted 2009) [#1]
I have been trying to multitexture some water, I have a base water texture and a texture I would like to overlay for some basic foam... the problem is that when I add the foam it acts as an alpha mask and looks totally wrong.

I have tried many blend modes and non seem to work. Basically I just need both textures to keep their own colors but I need the foam texture to keep its alpha also.

example:

This is the result I require, currently I have to use just one texture with foam and water but I would like to have one texture for the "foam" and one for the body of water that I can transform seperatly.



Also there was a way to setup an Ortho projection but still use coords such as -1.0 etc instead of pixel coords but I cannot remember?


ImaginaryHuman(Posted 2009) [#2]
For the ortho yes you can just use glOrtho2d or gluOrtho or whatever and give it whatever numbers you want, it doesn't have to match the number of pixels.

Don't you just need to ALPHABLEND the foam texture?


Snixx(Posted 2009) [#3]
seems not, the alpha in the texture seems to just act like a mask and so you only see the foam area.


_JIM(Posted 2009) [#4]
You're trying to do this with 2 textures on one mesh?

If all else fails, why not try to draw the mesh once with the water texture, then again with the foam texture. That should work flawlessly.

It should also not impact FPS too much since drawing the mesh again should be a piece of cake for the video card.


Snixx(Posted 2009) [#5]
Ya I have tried using multitexture but went toward using 2x mesh, its not like a huge amount of tris.


ImaginaryHuman(Posted 2009) [#6]
If alphablending is enabled surely you should be seeing something show underneath the foam?


Armitage 1982(Posted 2009) [#7]
I did it this way for my game : http://blitzmax.com/Community/posts.php?topic=85762#971012
Working really well (the slow down was caused by using old mod).

My caustic texture is white on black and I choose the colour of my water from the drawpoly.
Actually the foam could be another layer of texture or you can add it to the caustic one (like I did for the little sun ray effect).