I’m making a water shader similar too (aka ripped off from) the battery water shader. I have terrain also to create the foamy parts and I added a second terrain texture that is transparent so that the water seems to fade away into the fog. Problem is, it’s fading in the wrong direction:
http://homepage.ntlworld.com/dave88/water.jpg
And here is the sahder causing the grief:
textures/water1/terrain_0
{
q3map_baseshader textures/water1/terrain_base
cull none
deformVertexes wave 1317 sin 0 15 0 0.15
deformVertexes wave 317 sin 0 10 0 0.30
{
map textures/liquids_sd/seawall_specular.tga
blendFunc GL_ONE GL_ONE
rgbGen vertex
tcGen environment
depthWrite
tcMod scale 0.063 0.063
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc blend
rgbGen identity
//alphaGen const 0.8
tcMod scale 0.063 0.063
tcmod scroll 0.005 0.03
}
}
textures/water1/terrain_1
{
q3map_baseshader textures/water1/terrain_base
cull none
deformVertexes wave 1317 sin 0 15 0 0.15
deformVertexes wave 317 sin 0 10 0 0.30
{
map textures/liquids_sd/seawall_specular.tga
blendFunc GL_ONE GL_ONE
rgbGen vertex
tcMod scale 0.063 0.063
tcGen environment
depthWrite
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc blend
rgbGen identity
//alphaGen const .8
tcMod scale 0.063 0.063
tcmod scroll 0.005 0.03
}
{
map textures/liquids_sd/seawall_foam.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.2 0.1 0 0.2
alphaGen vertex
tcMod scale 0.063 0.063
tcMod turb 0 0.05 0 0.15
tcmod scroll -0.01 0.08
}
{
map textures/liquids_sd/seawall_foam.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.15 0.1 0.1 0.15
alphaGen vertex
tcMod scale 0.063 0.063
tcMod turb 0 0.05 0.5 0.15
tcmod scroll 0.01 0.09
}
}
textures/water1/terrain_2
{
q3map_baseshader textures/water1/terrain_base
cull none
{
map textures/mp_subpen/empty.tga
blendFunc blend
rgbGen identity
tcMod scale 0.063 0.063
}
}
textures/water1/terrain_0to1
{
q3map_baseshader textures/water1/terrain_base
cull none
deformVertexes wave 1317 sin 0 15 0 0.15
deformVertexes wave 317 sin 0 10 0 0.30
{
map textures/liquids_sd/seawall_specular.tga
blendFunc GL_ONE GL_ONE
rgbGen vertex
tcGen environment
tcMod scale 0.063 0.063
depthWrite
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc blend
//rgbGen identity
//alphaGen const .8
tcMod scale 0.063 0.063
tcmod scroll 0.005 0.03
}
{
map textures/liquids_sd/seawall_foam.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.2 0.1 0 0.2
alphaGen vertex
tcMod turb 0 0.05 0 0.15
tcMod scale 0.063 0.063
tcmod scroll -0.01 0.08
}
{
map textures/liquids_sd/seawall_foam.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.15 0.1 0.1 0.15
alphaGen vertex
tcMod turb 0 0.05 0.5 0.15
tcMod scale 0.063 0.063
tcmod scroll 0.01 0.09
}
}
textures/water1/terrain_0to2
{
q3map_baseshader textures/water1/terrain_base
deformVertexes wave 1317 sin 0 15 0 0.15
deformVertexes wave 317 sin 0 10 0 0.30
{
map textures/liquids_sd/seawall_specular.tga
blendFunc GL_ONE GL_ONE
rgbGen vertex
tcGen environment
alphaGen vertex
tcMod scale 0.063 0.063
depthWrite
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc blend
//rgbGen identity
//alphaGen const .8
alphaGen vertex
tcMod scale 0.063 0.063
tcmod scroll 0.005 0.03
}
{
map textures/mp_subpen/empty.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
//alphaGen vertex
tcMod scale 0.063 0.125
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}
textures/water1/terrain_1to2
{
q3map_baseshader textures/water1/terrain_base
deformVertexes wave 1317 sin 0 15 0 0.15
deformVertexes wave 317 sin 0 10 0 0.30
{
map textures/subpen/empty.tga
//alphagen const 0.0
//tcMod scale 0.063 0.063
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.2 0.1 0 0.2
alphaGen vertex
tcMod turb 0 0.05 0 0.15
tcmod scroll -0.01 0.08
tcMod scale 0.063 0.063
}
{
map textures/liquids_sd/sea_bright_na.tga
blendFunc GL_SRC_ALPHA GL_ONE
rgbGen wave sin 0.15 0.1 0.1 0.15
alphaGen vertex
tcMod turb 0 0.05 0.5 0.15
tcmod scroll 0.01 0.09
tcMod scale 0.063 0.063
}
}
textures/water1/terrain_base
{
qer_editorimage textures/liquids_sd/seawall_ocean.tga
qer_trans 0.5
q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
//tcMod scale 0.063 0.063
q3map_globalTexture
surfaceparm nonsolid
surfaceparm trans
surfaceparm nomarks
surfaceparm lightfilter
surfaceparm pointlight
nopicmip
}
I know it’s a mess and got other problems besides the vertx alpha problem.
Anyway, the terrain0to2 is the shader at fault. And it seems to me, no matter how I edit the shader, I cannot get the blending to be performed the other direction. Is this even possible or am I going to have to remake the shader and alphamap to make it blend in the right direction?
