Water textures
Water textures
Because so far i've been ignorant enough to never learn anything about OpenGL, and also tl;dr: could anybody quickly explain, in a few words, what's going on with the two water textures in drawWater() in terrain.cpp, apart from the fact that they seem to be moving in opposite directions? How exactly are page-80-water-1.png and page-81-water-2.png loaded and composed? Since none of these textures is originally (semi)transparent, does some image composition happen (eg. the second texture is used as an alpha channel for the first texture), or are they both made uniformly transparent? Why do they end up looking so dark, even though the texture images are so light?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
Re: Water textures
yepNoQ wrote:are they both made uniformly transparent?
cuz of texture of the bottom. I mean that brightness calculation is water1+water2+bottom texture=darkened result.Why do they end up looking so dark, even though the texture images are so light?
Re: Water textures
Erm.. Nope.MaNGusT wrote:cuz of texture of the bottom. I mean that brightness calculation is water1+water2+bottom texture=darkened result.
Code: Select all
pie_SetTexturePage(iV_GetTexture("page-80-water-1.png")); glErrors();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, paramsX);
glTexGenfv(GL_T, GL_OBJECT_PLANE, paramsY);
glMatrixMode(GL_TEXTURE);
Code: Select all
glTranslatef(waterOffset, 0, 0);
Code: Select all
pie_SetRendMode(REND_MULTIPLICATIVE);
So, texture A * texture B = final result for this operation.
We don't use REND_ADDITIVE.
For what it is worth, this is what they actually do:
Code: Select all
case REND_OPAQUE:
glDisable(GL_BLEND);
break;
case REND_ALPHA:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
case REND_ADDITIVE:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
break;
case REND_MULTIPLICATIVE:
glEnable(GL_BLEND);
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
break;
case REND_PREMULTIPLIED:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break;
so, think about it as color = src * A + dst * B or...one of the above.
/facepalm ...Grinch stole Warzone contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
Super busy, don't expect a timely reply back.
Re: Water textures
Aha, that makes sense. When added, textures become even brighter. When multiplied, they become darker; but still too light. And then, their semi-transparence against the seabed is also a "multiply" rather than "composite", right? o_O and they finally start to look like in-game. I think i got it, thanks!This makes each texture multiply blending values with each one.
Because i was seeking to apply this knowledge to mapping/modding some day >_<Why is this topic here, shouldn't it be in the dev area, since, mods can't do anything to the blending modes we use?
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam