Back Shader for Tree Models?


(Gringo Starr) #1

I heard there was a way to put a different texture on the backs of shaders. The reason I ask, is because I don’t like the way the trees in my map are being lit. If I can do that, how would I make them darker? I know how to brighten things in a map, but not darken them. lol Is the problem with the model? I mean, what if you let the leaves be culled, but add another slab of material on the back for viewing from that direction. Will that alone fix it?


(ydnar) #2
  1. Remove “cull none” from your leaf shader.

  2. Add “q3map_cloneShader path/to/new/shader”

  3. Create an identical copy of your shader, but append “_back” to the name.

  4. Instead of “q3map_cloneShader” the backside shader has “q3map_invert”

Example:


models/mapobjects/multiplant/fern
{
	qer_editorImage models/mapobjects/multiplant/fern.tga
	qer_alphaFunc gequal 0.5 
	
	q3map_cloneShader models/mapobjects/multiplant/fern_back
	
	surfaceparm alphashadow
	surfaceparm pointlight
	surfaceparm trans
	
	{
		map models/mapobjects/multiplant/fern.tga
		rgbGen vertex
		alphaFunc GE128
		depthWrite
	}
}


models/mapobjects/multiplant/fern_back
{
	q3map_invert
	
	// note: no alphashadow because the front takes care of this
	surfaceparm pointlight
	surfaceparm trans
	
	{
		map models/mapobjects/multiplant/fern.tga
		rgbGen vertex
		alphaFunc GE128
		depthWrite
	}
}

y


(Gringo Starr) #3

Awesome y! I’ll give it a try. :slight_smile:


(Gringo Starr) #4

Dude, you rock! That was annoying me for quite some time.


(rgoer) #5

Cool. Now all you need is some bounced light or some skylight in your sky to fill in that pitch black, and then you’ll be rockin and rollin.


(Gringo Starr) #6

Yeah, I’m still tweaking that. :slight_smile: What you see there is this:

q3map_sunExt 241 190 165 120 270 16 3 16
q3map_lightmapFilterRadius 0 64
q3map_skyLight 25 2


(obsidian) #7

I assume qer_alphaFunc allows for the use of alpha channels on blended textures in the editor? I tried adding it to a shader using a texture with an alpha channel, but it didn’t seem to work. What am I doing wrong and how is this different from qer_trans 1.0 + qer_editorImage?


(Gringo Starr) #8

lol Oops? :slight_smile:


(ydnar) #9

@Gringo:

Use these light parameters:

q3map_sunExt 241 190 165 120 270 16 3 16
q3map_skyLight 120 4

Don’t use the filtering, as it looks shoddy on nonplanar stuff like terrain.

y


(Gringo Starr) #10

Ok, it’s starting to look a lot better. What you see in the following screens is:

q3map_sunExt 241 190 165 120 270 14 3 16
q3map_skyLight 45 4

But, there are still issues. I’m using Q3map2 2.5.11 with the following commands for light from Q3mapToolz:

“C:\Program Files\GtkRadiant-1.4\q3map2.exe” -light -fast -patchshadows -bounce 8 -super 2

This screenshot shows jaggedness on the terrain. Here is a sample of the terrain shader:

textures/ww_mg3/terrain_3
{
	q3map_nonplanar 
   	q3map_shadeangle 180
	q3map_lightmapsamplesize 24
	q3map_lightmapsampleoffset 4
	q3map_lightmapaxis z
	//q3map_texturesize 512 512
	q3map_tcGen ivector ( 384 0 0 ) ( 0 384 0 )
	{
		map textures/ww_machogrande/kb_redrock2.jpg
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
	}
}

textures/ww_mg3/terrain_0to1
{
	q3map_nonplanar 
   	q3map_shadeangle 180
	q3map_lightmapsamplesize 24
	q3map_lightmapsampleoffset 4
	q3map_lightmapaxis z
	//q3map_texturesize 512 512
	q3map_tcGen ivector ( 384 0 0 ) ( 0 384 0 )
	
	{
		map textures/ww_machogrande/kb_redrock.jpg
	}
	{
		map textures/ww_machogrande/ma_redground.jpg
		alphaGen vertex
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		tcGen lightmap
	}
}

The next screenshot shows how the shadows for the plants are bigger than the plants themselves. It makes it look sort of cartoonish. Here is a plant shader:

textures/ww_machogrande/models/reeds02
{
	qer_editorimage textures/ww_machogrande/models/reeds02.tga
	q3map_cloneShader textures/ww_machogrande/models/reeds02_back
	q3map_forcemeta
	q3map_lightmapsamplesize 20
	q3map_lightmapGamma 1
	surfaceparm alphashadow
	surfaceparm nomarks
	//cull none
	{
		map textures/ww_machogrande/models/reeds02.tga
		rgbgen identity
		alphaFunc GE128
	}
	{
		map $lightmap
		blendFunc filter
		rgbgen identity
		alphaFunc GE128
	}
}

This one shows how my river looks milky in the dark areas of the map.

Looking at the shader, I guess it’s not being lightmapped? Can, or should it be?

///WATER from Pazur's custom RTCW map mp_natterbase
textures/ww_machogrande/mg_river
{
	allowCompress
	qer_editorimage  textures/ww_machogrande/fluss_seq.tga
	//qer_trans .5
	q3map_globaltexture
	//deformVertexes wave 128 sin 0 1 0 .3
	surfaceparm trans
	surfaceparm nonsolid
	surfaceparm nomarks
	surfaceparm nolightmap
	//cull disable
	sort 8
	surfaceparm nomarks
	{
		map textures/ww_machogrande/water_fluss.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
    		rgbgen identity
      		tcmod scale .5 .5
		tcmod scroll -.24 .00
		tcmod turb .01 .05 0 .125
	}

	{
		animMap 6 textures/ww_machogrande/fluss_seq.tga textures/ww_machogrande/fluss_seq1.tga textures/ww_machogrande/fluss_seq2.tga textures/ww_machogrande/fluss_seq3.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		tcmod scroll -.07 .00
		tcmod turb .01 .035 0 .25
		tcmod stretch sin 1 .005 0 .06
		tcmod scroll -.05 .00
	}
}

Sorry for all the questions. Maybe I’m lazy, as I immediately go directly to the source! :slight_smile:


(Gringo Starr) #11

I turned off alphashadow on the back shaders, but I think it’s casting a non-alpha’d shadow anyway. See this screenshot, and let me know what you think. The shadow looks bigger than the model which is casting it! I guess I’ll try enabling alphashadow on the back shaders too.


(ydnar) #12

Make sure the back shader has “surfaceparm trans” otherwise it won’t be invisible to light.

y


(ydnar) #13

Also, use the absolute latest version of Q3Map2. It has fixes that address problems you’re having, in particular bugs with cloneShader/invert and q3map_skyLight.

Your skylight brightness is way too low, incidentally.


(Gringo Starr) #14

Cool thank you.

About the skylight though, what do you suggest I use for a sunset map? The settings you suggested made it look like high noon. :slight_smile: Should I raise the sunlight and skylight, so it retains the same contrast?


(ydnar) #15

Just try different numbers, increasing brightness here and there until it’s the right balance.