Water Shader


(broloi) #1

Well, I’ve tried to search the forums, but i cant really find anything on the information i needed, and i didn’t have time.

Anyway, I cant get my water shader to work :frowning: … I’m a noob at shaders, and I didn’t have time to read all the stuff out there, so i just took one of the default shaders in the liquid folder and changed some things, but it doesn’t work, the texture is solid, and not nonsolid.

So anyone wanna look into my shade, or just drop a link for some help?

textures/broloi/broloi_siwa_water.tga
{
	qer_editorimage textures/broloi/broloi_siwa_water.tga
	qer_trans .5
	q3map_globaltexture
	cull disable
	nocompress
	nofog
	surfaceparm nomarks
	surfaceparm nonsolid
	surfaceparm trans
	surfaceparm water
	waterfogvars ( 0.1 0.1 0.1 ) 300
	{
		map $lightmap
		blendFunc GL_dst_color GL_zero
		rgbgen identity
		fog on	
	}
	{
		map textures/broloi/broloi_siwa_water.tga
		rgbgen identity
		tcmod scale .4 .3
		tcmod scroll .0035 -.0012
		tcmod stretch sin 1 .005 0 .03
		fog on
	}
	{
		map textures/broloi/broloi_siwa_water.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity
		tcmod scale .4 .3
		tcmod scroll -.00075 .00025
		tcmod transform 1.5 0 1.5 1 1 2
	}
	{
		map textures/broloi/broloi_siwa_water.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity
		tcmod scale .18 .28
	}
}

Thx - (THC)KingBroloi

I’m a NOOB at shaders, i know.


(d3coy) #2

hrmm… did you put the common/nodrawwater shader on your water brush before adding the water texture to the top face of the water brush?


(Constra) #3

Offtopic but may i ask how can i add waves ?


(Flippy) #4

You probably applied this texture/shader to ALL faces of the brush, which is wrong.

You need to apply “common/nodrawwater” on the complete brush first (select the brush with shift+click, then click on the texture), and then select only the face you want the water texture to appear (usually the top face) (ctrl + shift (+alt) + click) and click your water texture.

@Constra,
To make it wave i believe you need a tcMod parameter… but not sure. Have a look at either siwa_water or siwa_water2, one of them waves… (dont know which one)


(Constra) #5

It just depends witch 1 is at et_beach… :wink:
IT waves there too .


(broloi) #6

@ Flippy & d3coy i always use the nodrawwater on it and then put the water texture on top of it.


(C) #7

To make waves, use the deformVertexes command:
deformVertexes wave div func base amplitude phase freq
It has to be used before the first render-stage.

textures/mapname/watershader
{
	qer_editorimage textures/mapname/water.tga
	//--- if You have several water-brushes connecting eachother
	q3map_globaltexture
	q3map_nonplanar
	//---
	surfaceparm water
	surfaceparm trans
	surfaceparm nonsolid
	cull none
	tessSize 512
	// choose values for deformVertexes at Your own taste..
	// this is just an example of where to put it.
	deformVertexes wave 224 sin 0 3 0.5 0.23
	{
		// 1st render stage.
		// blah blah blah...
	}
	{
		// maybe more render stages.. it's up to You.
		// blah blah blah...
	}
}

to broloi:
Your water-shader is called textures/broloi/broloi_siwa_water.tga , with an extension .tga
You should leave the extension and just call Your shader textures/broloi/broloi_siwa_water
Put it in Your shader file in the scripts directory of Your map, and apply the shader to the top-surface of the water-brush as explained earlier.
Maybe that will work…


(broloi) #8

@ C - nope that didn’t work :frowning:


(C) #9

Is Your shader-file listed/added in etmain/scripts/shaderlist.txt (as the top-most entry) ??

// this file lists all the separate shader files
broloi
_unsorted
alpha
alpha_sd
assault
...etc.

(broloi) #10

I always add them to the shaderlist, but not at the top-most one…


(carnage) #11

just a note that when using the deform vertices’s command you quite likely need to use the

tessSize [“512”]

command. this will divide a brush into many smaller brushes giving it more verities to deform (a rather simplistic way to think about it though and not entirely acurate). there are situations where you would not want to use this when u want much finer control over the waves in a map

if you look at the map warbell with /r_showtris 1 you will see the river water is divided up manually to try give the impression that waves are flowing down the river rather on a static pool of water


(Father) #12

Please, can someone explain me… :?

I found strange bug… with textures & shaders.

Star Gate with Tram Siege vs Beach Invsaion --> texture bug
Star Gate vs Beach Invsaion --> no texture bug
Tram Siege with Star Gate vs Beach Invsaion --> texture bug
Tram Siege vs Beach Invsaion --> no texture bug

Just… when map (actually .pk3 files) Star Gate (SG_1945_final.pk3) and Tram Siege (low_tram.pk3 or mp_tram.pk3) are on server with map Beach Invasion… it makes strange (for me :-p ) bug. In console it says that it couldn’t find ocean_m2.tga - yeah, beacouse this texture isn’t supplied with any those maps. Only ocean_m1.tga is supplied with Beach Invasion - it looks that reason it dirty .shader supplied with Star Gate, but… when on server isn’t map Tram Siege - it works fine :shock: . But in .shader file for map Tram Siege, I cannot find any ralations with map Beach Invasion (i checked shaders, textures, mapscripts…).
So… why this bug not happend till Tram Sïge is on server too…? :?:

In .shader file supplied with map Star Gate I found this parts:

textures/liquids/water_beach_old


//	*********************************************************
//	*     			 Maxx				*
//	*      		Comment all changes                   	*
//	*********************************************************
		
	{
		qer_editorimage textures/liquids/ocean_m1.tga
		qer_trans .5
		q3map_globaltexture
		surfaceparm trans
		surfaceparm nonsolid
		surfaceparm water
	
		cull disable
	//	deformVertexes wave 64 sin 3 .7 .8 .25
		deformVertexes wave 32 sin 0 5 .75 .2
	//	deformVertexes wave 32 sin 0 20 .25 .1	
		{ 
			map textures/liquids/ocean_m1.tga
		//	blendFunc GL_dst_color GL_one
			rgbgen identity
			tcmod scale .4 .2
		//	tcmod stretch 0 1 .01 0 .25 1
			tcmod scroll .00 .01
		}	

	
		{ 
		//	map textures/liquids/water_m1.tga
			map textures/liquids/ocean_m2.tga
			blendFunc GL_dst_color GL_one
			rgbgen identity		
			tcmod scale -.6 .5
		//	tcmod stretch 0 1 .01 0 .25 1
		//	tcmod rotate 5 
			tcmod scroll .01 .01
		}

	
	
		{
			map $lightmap
			blendFunc GL_dst_color GL_zero
			rgbgen identity		
		}
	

//	END
	}
textures/liquids/water_beach
{
	qer_editorimage textures/liquids/ocean_m1b.tga
	qer_trans .5
	q3map_globaltexture
	surfaceparm trans
	surfaceparm nonsolid
	surfaceparm water
	surfaceparm nomarks	// don't play ripple effects when shooting into water
	tesssize 256
	
	cull disable
	nofog
	deformVertexes wave 160 sin 0 10 0 .3	// the chop

	waterfogvars ( 0.1 0.1 0.1 ) 512
//	waterfogvars ( 0.1 0.1 0.1 ) .005
	{
		fog on
		map $lightmap
		blendFunc GL_dst_color GL_zero
		rgbgen identity		
	}

	{ 
		fog on
		map textures/liquids/ocean_m1.tga
		rgbgen identity
		tcmod scale .4 .2
		tcmod scroll .00 -.01
	}	

	
	{ 
		map textures/liquids/ocean_m2.tga
		blendFunc GL_dst_color GL_one
		rgbgen identity		
		tcmod scale -.6 .5
		tcmod scroll -.01 -.01
	}
}

I don’t need solution (I have it…), I want just some explainations of this bug.
Thanx in advance