Page 1 of 1

Problems with phong shading

Posted: Fri Jan 08, 2010 10:32 am
by dONKEY
I am experiencing a problem with phong shading on my terrain.
I was doodling some cave sections in GTK for a CTF level. My cave has a base rock texture and two separate alpha blended section, one on the floor, one on the ceiling. All in all I have 3 separate shaders, one for the rock-to-floor blend, one for the rock-to-ceiling blend and one phong shaded rock.
My problem is that the phong shaded rock isn't being smoothed:
Image
All the dark area is the non-blended shader.
I've spent anytime aligning textures yet, this was just a first test. However I got stuck when I ran into this problem. I guess I could simply use the two blending shaders, but being a bit anal I wanted to solve the problem not go around it.
Just in case it's my scripts here they are...the blending script first and then the phong only script:

Code: Select all

textures/fi/rock_to_rock2
{
		qer_editorimage textures/fi/2.tga
		q3map_nonplanar 
		q3map_shadeAngle 179

	{
		map textures/fi/rock.tga
		rgbGen identity
	}
	{
		map textures/fi/rock_2.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		rgbGen identity
		alphaGen oneMinusVertex
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

textures/fi/rock_phong
{
		qer_editorimage textures/fi/3.tga
		q3map_nonplanar 
		q3map_shadeAngle 179

	{
		map textures/fi/rock.tga
		rgbGen identity
	}

	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
		rgbGen identity
	}
}

The screenshot was taken after a light -fast compile

Thanks

Re: Problems with phong shading

Posted: Fri Jan 08, 2010 11:20 am
by dONKEY
hmm, could just be the angle of my brush edges and the light source...dunno, smoothing on models in idtech4 is far easier :)

Re: Problems with phong shading

Posted: Fri Jan 08, 2010 3:38 pm
by obsidian
If everything is just one big smoothing group, I think Q3Map2 may have problems UV'ing the lightmap pages onto a complex shape like that. My hunch is that Q3Map2 is trying to take a flat lightmap texture and wrap it around something complex like an inverted sphere.

You may have to break it up into a couple of chunks (func_grouping and playing with the entity keys them might help). Depending on how big the room is, larger sized external lightmaps might help too.

Re: Problems with phong shading

Posted: Wed Jan 13, 2010 4:19 am
by Kat
Strip it back to a standard shader with phong to test whether it *is* the brushwork or not, that way you at least know where the problem is (which relates to what obsidian said). Also, phong-fu doesn't like really sharp corners (greater that 90 degrees) so check that isn't an issue.

Re: Problems with phong shading

Posted: Wed Jan 13, 2010 10:12 am
by dONKEY
Belated thanks to both. I *think* it was more the brush angle issue. I have two versions of a test map, one made from brushes, the other a model. The smoother angles on the mesh work much better.