SoF2 Lightmapped Terrain v.s. Nightvision or Worldspawn Fog


(StonedAvenger) #1

I’ve been having this problem on all my terrains. Everything looks ok until you equip night-vision goggles (NV). With NV on all the blended areas of the terrain appear darker.

I’m having trouble finding an answer to this one. I’ve tried a few different terrain shaders, following examples online, but none of the changes affected this issue. This is one of those “SoF2 Specific Problems” that is hard to find any advice on, so if anyone knows the solution (ydnar)…please post it here!

If I use a fog key in the worldspawn it causes a similar, if not identical, effect. With, or without NV.

textures/terra1/baseterrain
{
q3map_surfacemodel models/objects/colombia/jungle/grass2.md3 128 0.004 0.50 1.75 0 360 1
q3map_material Snow
q3map_lightmapsamplesize 32
q3map_lightmapaxis z
q3map_texturesize 1024 1024
q3map_tcGen ivector ( 384 0 0 ) ( 0 384 0 )
}

textures/terra1/terrain_0
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge_snow.jpg
rgbGen identity
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_1
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge.jpg
rgbGen identity
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_2
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/snow01.jpg
rgbGen identity
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_3
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/snow_2.jpg
rgbGen identity
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_0to1
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge_snow.jpg
}
{
map textures/kamchatka/rock_huge.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_0to2
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge_snow.jpg
rgbGen identity
}
{
map textures/kamchatka/snow01.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_0to3
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge_snow.jpg
rgbGen identity
}
{
map textures/kamchatka/snow_2.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_1to2
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge.jpg
rgbGen identity
}
{
map textures/kamchatka/snow01.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_1to3
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/rock_huge.jpg
rgbGen identity
}
{
map textures/kamchatka/snow_2.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain_2to3
{
q3map_baseshader textures/terra1/baseterrain
{
map textures/kamchatka/snow01.jpg
rgbGen identity
}
{
map textures/kamchatka/snow_2.jpg
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
rgbGen identity
alphaGen vertex
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
tcGen lightmap
rgbGen identity
}
}

textures/terra1/terrain.vertex
{
{
map textures/kamchatka/rock_huge_snow.jpg
rgbGen vertex
rgbGen identity
}
}

Thank you
StonedAvenger


(ydnar) #2
  1. Use a more specific name. “textures/terra1/terrain” is pretty generic and you’ll set yourself up for shader collisions with someone else’s map.
  2. You don’t need the vertex shader.
  3. For the single-stage shaders, try duplicating the first texture stage:

textures/terra1/terrain_0
{
	q3map_baseshader textures/terra1/baseterrain
	{
		map textures/kamchatka/rock_huge_snow.jpg
		rgbGen identity
	}
	{
		map textures/kamchatka/rock_huge_snow.jpg
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
		rgbGen identity
	}
}

If that doesn’t work, try:


textures/terra1/terrain_0
{
	q3map_baseshader textures/terra1/baseterrain
	{
		map textures/kamchatka/rock_huge_snow.jpg
		rgbGen identity
	}
	{
		map textures/kamchatka/rock_huge_snow.jpg
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbGen identity
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
		rgbGen identity
	}
}

y


(StonedAvenger) #3
  1. Really? I thought the name would always be terrain to that the common.shader terrain shader would be mysteriously invoked. I guess I need to take a closer look, and try to change the name. I’m guessing I change it in the terrain entity also? I’ll mess with that and try to figure it out.

  2. Good…I wasn’t getting a good vibe from that vertex part anyway. Sort of a black sheep if you ask me. Especially since the problematic areas all have “alphaGen vertex” in them while the unblended areas do not. So I remove it from every stage…do I remove this ugly thing too?

textures/terra1/terrain.vertex
{
{
map textures/kamchatka/rock_huge_snow.jpg
rgbGen vertex
rgbGen identity
}

  1. You suggested this the first time I posted this in quakeworld, but wouldn’t it only server to make the rest of the terrain dark like that? I Don’t think it would look right to have averything have the same washed out, green NV look except the terrain. Player models would surely stand out against that. Or should I just shutup and try it and not try to second guess this one? Am I misunderstandign the point of making the 2 stage shaders into 3 stage blended shaders?

I’m using a “fog brush”, could the fog shader have anything to do with it? The fogbrush looks ok, since global worldspwan fog does pretty much the same thing the NV does. Am I supposed to be able to use fog key in the worldspawn and still have a lightmapped terrain?

I’m not really happy with the lightmap on my terrain. I tried using the lightmap mergable command and it looked better in some respects, but offered very low detail. On the other hand, if I use the shader as it is posted here, I get some ugly shadows. Almost seems as if you can see the underlying grid of the terrain effecting the terrain lightmap. It seems to accentuate the actual brushwork, instead of helping to make the terrain look better. I don’t know exactly how to describe it, but I’ll take a screenshot if you don’t already know what I mean. Anyway, I’d like to have some nice clean shadows, but not at great expense to performance…having enought trouble there already. I have 1 spot where a spotlight is pointed at a dead_tree md3. There is a shadow on the terrain, but it isn’t very defined at all…sort of just smudges. What can I do to make the shadows more bold and less blocky?

Thanks for your help ydnar. I really appriciate it : ) The first time I tested this map out, it went for over an hour. People really seemed to like it. I think I’m a little greedy when it comes to FPS killing visual details. But I’m really really happy that I’m finally figuring out how to make and organic, natural terrain. The model distribution feature helps considerably…and I think I’ve got the settings under control as far as quantity/vs performance. I’m pretty much bored to death of playing inside brightly lit square boxes…I want to go outside! SoF2 has RMG maps, which are pretty cool sometimes. But they are quite often just too huge and generally boring. I want something similar, yet smaller and less foggy. You’ve already helped me alot, and again, I thank you!


(ratty redemption) #4

rgbgen vertex also sets up alphagen vertex, so you don`t need to use the latter unless your using a different rgbgen like wave …eg stage from one of my water shaders…

 {
  map textures/_water_test/shader_images/image05.tga
  tcgen vector ( 0.00130208333 0 0 ) ( 0 0.00130208333 0 )  // 768
  rgbgen wave sin 0.6 0.3 0 0.3
  tcmod turb 0 0.1 0.3 0.1
  tcmod scroll  -0.15 0
  alphagen vertex
  blendfunc blend
 }

and we can only have one rgbgen per shader stage, so having rgbgen identity after rgbgen vertex would use the latter and ignore the first.

also in wolf, we have some problems with global fog making the lightmapped blend stages of terrain not fog properly… but since your normal vision terrain seems to work with fog, that probably isn`t an issue with the nv fogging in sof2.