lightmapped terrain.


(urgrund) #1

hey, I’m having trouble getting lightmapped terrain working.

Here’s what I did:
Followed everystep from both…
http://www.nibsworld.com/rtcw/tutorial_lightmapped_terrain.shtml
http://shaderlab.com/q3map2/lmt.txt

So…
I have the base

textures/gc_terrain/radarbase
{

	q3map_tcGen ivector ( 32 0 0 ) ( 0 32 0 )
	q3map_lightmapaxis z
	surfaceparm grasssteps
	q3map_lightmapsampleoffset 8.0
	q3map_lightmapmergable	
}

the normal terrain shaders

textures/gc_terrain/terrain_0
{
	q3map_baseshader textures/gc_terrain/radarbase
	q3map_lightimage textures/gc_terrain/gcgrass.jpg
	
	{
		map textures/gc_terrain/gcgrass.jpg
		
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		
	}
}

and the blends

textures/gc_terrain/terrain_0to1
{

	q3map_baseshader textures/gc_terrain/radarbase
	q3map_lightimage textures/gc_terrain/gcgrass.jpg

		{
			map textures/gc_terrain/gcgrass.jpg
		}
		{
			map textures/gc_terrain/gcgrass2.jpg
			blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
			alphaGen vertex
		}
		{
			map $lightmap
			blendFunc GL_DST_COLOR GL_ZERO
		}
}

The shader file is added to shaderlist.txt.
q3map_terrain is added to the common/terrain shaders.
cell and q3map are added to the scripts dir.

The results are, what I’d assume, still vertex lit. When I type r_lightmap 1 the terrain stays textured, and the shadows are typical of vertex lighting.

Oh, I also changed the key words in the terrain func_group… (shader = _shader ect)

In Nibs RtCW tut… i noticed he had rgbGen identity & alphaGen vertex still in the shader… removing or keeping made no difference (to me).

any help?
cheers


(urgrund) #2

anyone?


(RabidCow) #3

Ok, I’ll take a stab at it. You are using q3map_lightmapmergable, but you are not using q3map_lightmapsize or q3map_lightmapgamma to create one big external lightmap. You probably are forcing your entire terrain to use one 128x128 internal lightmap…?? I don’t know if it still applies but in the past it was necessary to use the .tga extension in shaders sometimes, even when the texture was a .jpg. Like I said, not sure if that ever causes a problem anymore…
Good luck!


(Old_Fellow) #4

Try what follows.

The base

textures/gc_terrain/radarbase
{

	q3map_tcGen ivector ( 32 0 0 ) ( 0 32 0 )
	surfaceparm grasssteps
	q3map_lightmapsampleoffset 8.0
	q3map_lightmapmergable	
}

the normal terrain shaders

textures/gc_terrain/terrain_0
{
	q3map_baseshader textures/gc_terrain/radarbase
	q3map_lightimage textures/gc_terrain/gcgrass.tga
	
	{
		map textures/gc_terrain/gcgrass.tga
		
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
	}
}

and the blends

textures/gc_terrain/terrain_0to1
{

	q3map_baseshader textures/gc_terrain/radarbase
	q3map_lightimage textures/gc_terrain/gcgrass.tga

		{
			map textures/gc_terrain/gcgrass.tga
		}
		{
			map textures/gc_terrain/gcgrass2.tga
			blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
			alphaGen vertex
		}
		{
			map $lightmap
			blendFunc GL_DST_COLOR GL_ZERO
         tcGen lightmap
		}
}

You are calling jpg instead of tga.
gc_terrain must be in shaderlist.txt.
The base shader must be in the gc_terrain.shader file.


(BoltyBoy) #5

if you use Easygen it genreates the terrain shader for ya, Q3map2 compatible and lightmapped by default…a sample…

textures/a_map/terrain_0
{
	q3map_lightmapsamplesize 64
	q3map_lightmapaxis z
	q3map_texturesize 256 256
	q3map_tcGen ivector ( 312 0 0 ) ( 0 333 0 )
	{
		map textures/a_map/a_metal2.jpg
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
	}
}

textures/a_map/terrain.vertex
{
	{
		map textures/a_map/a_metal2.jpg
		rgbGen vertex
	}
}

Confess unsure why last line is rgbGen Vertex and what terrain.vertex does but this terrain is lightmapped. Would this be for people running in vertex light mode?


(Old_Fellow) #6

The way that EasyGen writes shader files is actually borked.
It always calls jpg instead of tga and terrain.vertex is not a valid name.


(ydnar) #7

That’s actually my fault. I gave him a semi-bogus template for the last version of EasyGen.

The vertex shader should have a “_vx” suffix instead of “.vertex”.

y