help: applying phong shading to terrain


(jah) #1

hi

i’m trying to give my terrain a more smooth shape by applying phong shaders to my terrain… but i’m missing something because it ain’t happening :banghead:

i’ve read about the switches needed by q3map and the ones going inside the shaders themselves… but no results…

i’m new to mapping so any pointers would be appreciated… (a lot btw)…

any links to tutorials on the subject would be cool too… i’ve searched google but in vain :frowning:

here’s my batch file:



@echo off
"F:\Programas\GTK Radiant\q3map2.exe" -leaktest -game et "F:\Programas\Wolfenstein - Enemy Territory\etmain\maps\123_02.map"
if exist %1.lin goto leaked
"F:\Programas\GTK Radiant\q3map2.exe" -vis  -game et  "F:\Programas\Wolfenstein - Enemy Territory\etmain\maps\123_02.bsp"
"F:\Programas\GTK Radiant\q3map2.exe" -light -extrawide -patchshadows -shade -shadeangle 90 -game et  "F:\Programas\Wolfenstein - Enemy Territory\etmain\maps\123_02.bsp"
goto end
:leaked
@echo ***********************
@echo ***** L E A K E D *****
@echo ***********************
pause
pause
:end
pause
pause


i can post my shader if required and/or map screenshots :expressionless:

please help this n00b :banana:

thx in advance,

:jah:


(ydnar) #2

Yes, post your shaders and screenshots.

Using -shadeangle in the commandline is not the preferred way of doing phong shading. You should be setting q3map_nonplanar/q3map_shadeAngle in the shader(s) themselves.

y


(jah) #3

thx for replying ydnar

here are some screenies:

and one of my terrain shaders:


textures/123/terrain_0
{
	q3map_baseshader textures/123/terrain_base
	surfaceparm landmine
	surfaceparm gravelsteps
	{
		map textures/mp_omaha/sand_bubbles_bright.tga
		tcMod scale 0.1 0.1
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
	}
}

and my base terrain shader:


textures/123/terrain_base
{
	q3map_nonplanar 
	q3map_shadeangle 90
	q3map_lightmapaxis z
	q3map_lightmapmergable
	q3map_lightmapsize 512 512
	q3map_tcGen ivector ( 512 0 0 ) ( 0 512 0 )
}

thx again for helping me out :slight_smile:

:jah:


(rgoer) #4

Hmmmm… I’m not sure it’s going to get much smoother than that, bro.


(chavo_one) #5

If that’s not smooth enough for you, bump the shadeangle up to 120 or so.


(ydnar) #6

Dude, lose the tcMod scale from the texture stage in your shader. The q3map_tcGen ivector line in the base shader sets the terrain texture coordinates. Using per-stage tcMod scales causes a performance hit.

y


(wviperw) #7

I’m sure this is in some documentation somewhere (which, btw, you should maybe have a sticky to the q3map2 docs/guides, there seems to be a dozen of them), but how exactly does the value passed to shadeangle affect the shading? I was under the impression that you want shadeangle 179 for terrain, but I’m not exactly sure why.


(onu) #8

That’s something I’ve been wondering about to. Does the shadeangle value merely decide which triangles will be phong shaded, or does it actually effect the algorithm used to smooth shading across the surfaces? If it was the latter I’d be hard-pressed to be far more precise with the things…


(jah) #9

thx for helping out dudes :beer:

ydnar: if i remove tcmod from the shader as you said the textures just shrink like hell :S and i’ve been looking on some of the SD shaders for terrain and they use it too :S

wviperw: yeah a sticky thread would be a nice idea :slight_smile:


(ydnar) #10

If the textures are shrunk, then Q3Map2 is not finding your shaders or your shaders have errors.

[ ] Is the shader listed in shaderlist.txt?
[ ] Is the base shader before the sub-shaders?

The tcMod scales we used in the ET terrain shaders were only on detail stages. Only a few of our terrain shaders had detail stages, and any other old shaders with tcMod scales aren’t used.

y


(DeAtHmAsTeR) #11

Hey i just want to ask if this would work for phonging my easy gen terrain? if i add

  q3map_nonplanar 
   q3map_shadeangle 90

to all my shaders like i have here

textures/snowtrench/terrain_1
{
	surfaceparm nolightmap
                surfaceparm landmine
                 surfaceparm snowsteps
	q3map_novertexshadows
	q3map_forcesunlight
                q3map_nonplanar 
                q3map_shadeangle 90 
{
	map textures/snow/s_cathedrale_c24b.jpg
	rgbGen vertex
	tcmod scale 0.250 0.250
	}
}

would it work?


(ydnar) #12

Yes, that’d be fine. Terrain is automatically set to use shadeAngle 179, so putting it in your terrain shaders is pointless.

Also, don’t use the default EasyGen TA-style terrain. Look at the terrain shaders used in the 6 ET maps for examples of how to properly set up lightmapped terrain.

y


(jah) #13

[1] yeap
[2] err… didn’t know that the order inside .shader files would matter :S :banghead: :banghead: :bash:

fixed… thx a lot ydnar! :smiley: :banana:

:drink:


(|NV|S) #14

http://www.s8s.info/phong_tutorial.asp

Here is a tutorial for phongshaded terrain on a smaller scale.


(Loffy) #15

I use EasyGen-made terrain, in my current map. (See my terrain shaders below.)
I’ve had a look at the ET maps’ shader files, but I dont have the skills to determine what is “wrong” with my shaders. Could anyone point me in the right direction? How could the shader files be improved!

Here are my shaders for the terrain. It is an outdoor map, with the wurzburg sky applied (a cool, dark sky that came with ET). The only lights in the map are the sky and some additional lights (values 100-1000).

I use radiant 1.3.11 beta and Q3map2 2.5.5.


textures/berserk_beta4/terrain_0
{
q3map_baseshader textures/berserk_beta4/terrain_base
surfaceparm landmine
surfaceparm gravelsteps
{
map textures/berserktex/graes.tga
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_1
{
q3map_baseshader textures/berserk_beta4/terrain_base
surfaceparm landmine
surfaceparm gravelsteps
{
map textures/berserktex/rockgrav.tga
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_2
{
q3map_baseshader textures/berserk_beta4/terrain_base
surfaceparm landmine
surfaceparm gravelsteps
{
map textures/berserktex/dirtbrun.tga
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_3
{
q3map_baseshader textures/berserk_beta4/terrain_base
surfaceparm landmine
surfaceparm gravelsteps
{
map textures/berserktex/grasstig.tga
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_0to1
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/graes.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/rockgrav.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_0to2
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/graes.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/dirtbrun.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_0to3
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/graes.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/grasstig.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_1to2
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/rockgrav.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/dirtbrun.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_1to3
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/rockgrav.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/grasstig.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_2to3
{
q3map_baseshader textures/berserk_beta4/terrain_base
{
map textures/berserktex/dirtbrun.tga
tcMod scale 0.100 0.100
}
{
map textures/berserktex/grasstig.tga
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
alphaGen vertex
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

textures/berserk_beta4/terrain_base
{
q3map_lightmapaxis z
q3map_lightmapmergable
q3map_lightmapsize 512 512
q3map_tcGen ivector ( 640 0 0 ) ( 0 640 0 )
}


Not urgent
MANY thanks in advance!
// Loffy

PS: I compile with
-bsp
-vis
-v -light -fast -super 2 -filter -bounce 1 -external -lightmapsize 256 -approx 4


(Loffy) #16

I was thinking that maybe I should change q3map_lightmapsize 512 512 to 256 256. Because I compile with 256 (-v -light -fast -super 2 -filter -bounce 1 -external -lightmapsize 256 -approx 4).
But I am not sure.
I should also mention that the light entities in my map are nonlinear.
// Loffy


(chavo_one) #17

I believe that q3map_lightmapsize will override the compiler flag -lightmapsize for the applicable surfaces.

So the surfaces that have q3map_lightmapsize 512 512 will be written to 512x512 tgas, while everything else will be written to 256x256 tgas.


(ydnar) #18

I looked at your compile batch file again, and it’s missing some key stuff.

The BSP phase should always be run with -meta. You can lose the -leaktest stuff too. That’s unnecessary.

Instead of -extrawide, use -super 2 -filter (or just use -samples 2). The -extrawide switch is deprecated.

Your terrain shaders should not have any per-stage tcMod scale directives. Remove those.

Yes, q3map_lightmapSize overrides the -lightmapsize switch. That is why the terrain in ET uses 512x512 lightmaps and the rest of the lightmaps are 256x256.

y


(Loffy) #19

Hi!
Thanks for your reply.
If interpret you right, I should remove every tcMod code? Eg. remove the code in red (see below):

textures/berserk_beta4/terrain_0
{
q3map_baseshader textures/berserk_beta4/terrain_base
surfaceparm landmine
surfaceparm gravelsteps
{
map textures/berserktex/graes.tga
tcMod scale 0.100 0.100
}
{
map $lightmap
blendFunc GL_DST_COLOR GL_ZERO
}
}

I will try it. Appreciated your advice, thanks!
// Loffy