Page 1 of 1

Making water (more) opaque

Posted: Tue Jul 03, 2007 7:12 pm
by dichtfux
I've got a water shader here that uses original id textures (shader by id modified by pjw modified by me).

The water looks good but I'd like to get it more opaque / less transparent. Can this by achieved by modifying the shaderscript (if so: how) or would this task involve messing with the texture?

Code: Select all

// water - modified version of an original id shader
// modified by pjw, taken from pjwctfduel1 by pjw - http://www.planetquake.com/pjw
// further modified by spirit
textures/spirit3ctfduel1_ctf/ctfwater
{
	qer_editorimage textures/liquids/pool3d_5c2.tga
	//qer_trans .99
	q3map_lightSubdivide 256
	q3map_globalTexture

	//surfaceparm trans
	surfaceparm nonsolid
	surfaceparm water
	surfaceparm noimpact
	cull disable

	//q3map_surfacelight 25
	{
		map textures/liquids/pool3d_5c2.tga
		blendFunc GL_dst_color GL_zero
		rgbgen identity
		tcmod scale .5 .5
		tcmod transform 1.5 0 1.5 1 1 2
		tcmod scroll -.05 .001
	}

	{
		map textures/liquids/pool3d_4b2.tga
		blendfunc add
		tcmod scale .125 .125
		rgbgen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ONE
	}
}
Here is how it looks in-game atm:

Image

Posted: Tue Jul 03, 2007 7:42 pm
by Shallow
You could easily make it fully opaque by removing the blendfunc in the first stage, but that's not what you're after.

It would probably be best to start messing about with copies of the textures. Currently it's using filter and additive blends, which only modify existing colours behind the shader rather than replacing them like an alpha blend would.

Best candidate would be adding an alpha channel to the texture for the first stage and making the whole shader more solid that way. You could hack it by just using an alphagen const directive, but it will look better with a proper variable alpha. Change the blendfunc for that stage to blendfunc blend. Start with a pretty dark channel and make it lighter until it looks like what you want.

Another thing you could try is putting a dark green fog brush into the water.

Posted: Tue Jul 03, 2007 9:50 pm
by o'dium
Hmmm, tough one. Adding more stages will give the effect of making it what your after but it will reduce FPS (Increase fill rate). Changing alpha will also do what your after, but it will unfortunatly mean you cant re-dist the texture.

The best bet is as Shallow said, fog. Add a light fog and make it thicker as you please, it will work pretty much just as you intended anyway. Water is slightly murky anyway, so it will probably look better. The only problem is that you might want to work with the fog colour a little closer, as making it green or to green will look less like water and more like acid.

Posted: Tue Jul 03, 2007 10:22 pm
by Shallow
o'dium wrote:Changing alpha will also do what your after, but it will unfortunatly mean you cant re-dist the texture.
No, as long as it is under a different folder/name so it won't overwrite the base asset, it's perfectly fine. Unless id have had a change in policy, it always used to be OK to distribute modified texture assets as long as it's for the same game, and it's part of a map or mod.

That's a sorta special exemption thing from ages ago, not a general copyright law thing by the way... Copyright does indeed say that you shouldn't redistribute modified content, but the community was told that it was OK to tweak textures etc. as long as they weren't blatantly giving them to people who didn't have the game.

Posted: Tue Jul 03, 2007 11:48 pm
by obsidian
Editing the texture is the easiest way.

Otherwise, try alphaGen const N.N (sets constant vertex alpha value) with rgbGen vertex (specifies use of vertex values) in the texture stages, where N.N is a normalized value.

BTW, comment out/remove q3map_lightSubdivide and surfaceparm noimpact (swimmable water shouldn't have this). And surfaceparm trans should be enabled for all transparent shaders. I don't think you really want the lightmap on the last stage.

Code: Select all

// water - modified version of an original id shader
// modified by pjw, taken from pjwctfduel1 by pjw - http://www.planetquake.com/pjw
// further modified by spirit
// further, further modified by Obsidian :)
textures/test/ctfwater
{
	qer_editorimage textures/liquids/pool3d_5c2.tga
	//qer_trans .99
	q3map_globalTexture
	surfaceparm trans
	surfaceparm nonsolid
	surfaceparm water
	cull disable
	{
		map textures/liquids/pool3d_5c2.tga
		blendFunc blend
		rgbgen vertex		//Specifies use of vertex values
		alphaGen const 0.75	//Sets constant vertex alpha value
		tcmod scale .5 .5
		tcmod transform 1.5 0 1.5 1 1 2
		tcmod scroll -.05 .001 
	}
	{
		map textures/liquids/pool3d_4b2.tga
		blendfunc add
		tcmod scale .125 .125
		rgbgen identity
	}
//	{
//		map $lightmap
//		blendFunc GL_DST_COLOR GL_ONE
//	}
}

Posted: Wed Jul 04, 2007 12:56 am
by pjw
This is super minor, but if you leave the URL in there, then please change it to:

http://pjw.planetquake.gamespy.com

Thanks. :)

(I'd provide suggestions on the shader, but it sounds like you've gotten some good ones...)

Posted: Wed Jul 04, 2007 3:05 am
by a13n
Shallow wrote:No, as long as it is under a different folder/name so it won't overwrite the base asset, it's perfectly fine. Unless id have had a change in policy, it always used to be OK to distribute modified texture assets as long as it's for the same game, and it's part of a map or mod.
Thats' good news.
I've been wondering why so many people distribute so many modified official textures so far. :icon27:

@dichtfux
I would remvoe "rgbGen identiy" from the stage where "blendFunc add" is specified, defaulting to "rgbGen identityLighting".
AFAIK, the combination of these makes the texture oversaturated, resulting in expansion of the flatness. (One example would be an officail red armor. It is spoiling subtle detail due to this combination.)
And this is just my biased taste. (It ain't the way it has to be.)

Posted: Wed Jul 04, 2007 5:38 pm
by dichtfux
Thanks for all the suggestions! I'll give them a try asap and report what they achieved.

@pjw: I'll change that URI.

Posted: Thu Jul 12, 2007 3:12 pm
by dichtfux
Thanks again to everyone, it worked very well.

I didn't change the texture, only the shader. Here's what I've come up with:

Code: Select all

// water - modified version of an original id shader
// modified by pjw, taken from pjwctfduel1 by pjw - http://pjw.planetquake.gamespy.com
// further modified by spirit
// further, further modified by Obsidian :)
// finally, modified by spirit again ;-)
textures/spirit3ctfduel1_ctf/ctfwater
{
   qer_editorimage textures/liquids/pool3d_5c2.tga
   q3map_globalTexture
   surfaceparm trans
   surfaceparm nonsolid
   surfaceparm water
   fogparms ( .5 .8 .5 ) 4096
   cull disable
   {
      map textures/liquids/pool3d_5c2.tga
      blendFunc blend
      rgbgen vertex
      alphaGen const 0.95
      tcmod scale .5 .5
      tcmod transform 1.5 0 1.5 1 1 2
      tcmod scroll -.05 .001
   }
   {
      map textures/liquids/pool3d_4b2.tga
      blendfunc add
      tcmod scale .125 .125
      rgbgen identity
   }
}
I'll post a screenshot later, the map is almost finished.

Posted: Thu Jul 12, 2007 7:50 pm
by Shallow
You should probably add surfaceparm nolightmap to that, since you aren't using a lightmap stage. It will prevent unused lightmap data from being generated and stored in the BSP. Probably a trivial amount of data, but, y'know.