Water textures

Get some help with creating maps or modding.
Need a map editor or other tools, look here!
Post Reply
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Water textures

Post by NoQ »

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?
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: Water textures

Post by MaNGusT »

NoQ wrote:are they both made uniformly transparent?
yep
Why do they end up looking so dark, even though the texture images are so light?
cuz of texture of the bottom. I mean that brightness calculation is water1+water2+bottom texture=darkened result.
Image
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: Water textures

Post by vexed »

MaNGusT wrote:cuz of texture of the bottom. I mean that brightness calculation is water1+water2+bottom texture=darkened result.
Erm.. Nope.

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);
Set texture and filtering. (pretty much the same for both of them)

Code: Select all

	glTranslatef(waterOffset, 0, 0);
this texture moves +x axis, and the other texture moves along the -x axis.

Code: Select all

pie_SetRendMode(REND_MULTIPLICATIVE);
This makes each texture multiply blending values with each one.
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.
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?
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Water textures

Post by NoQ »

This makes each texture multiply blending values with each one.
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!
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?
Because i was seeking to apply this knowledge to mapping/modding some day >_<
Post Reply