Phong and vertex shading help... probably really easy!


(Grand Nagus) #1

Hey guys! You probably already know this, but Ydnar and Q3Map2 absolutely ROCK. Hands down. Period. :smiley:

First off, here’s my compiler options (yep, it’s for Elite Force):

MAP: -game ef -meta -patchmeta
VIS: -game ef -vis
LIGHT: -game ef -light -fast -filter -patchshadows -samples 3 -bounce 4

And now for the problems… I’ve been playing around with shading options, and I can’t seem to get phong shading to work right. Here’s a pic of my results…

The left (with the ‘V’) is supposed to be vertex lit. Sometimes you’ll see the seams, but they’re not too evident. How do I eliminate the seams? Here’s the shader I used for that grass:

textures/m_castl01/grass_vertex
{
    qer_editorimage textures/m_castl01/c_grass02.tga
    q3map_bounce 0.25
    surfaceparm pointlight
    {
        map textures/m_castl01/c_grass02.tga
        blendFunc GL_ONE GL_ZERO
        rgbGen vertex
    }
}

The right (with the ‘P’) is supposed to be phong shaded. The terrain geometry is a duplicate of what you see on the left, and there’s absolutely no seams (unlike the vertex lit shader). But you can immediately see where the triangles are lit incorrectly. That ‘P’ is flat, like the ‘V’, but the lighting makes it look a little funky. Also, you can see the two triangular shadows in the phong-shaded grass to the right of the four colums. How do I get the phong shading to happen where there aren’t any triangular shadows generated? Here’s the phong shader that I used to get this result:

textures/m_castl01/grass_phong
{
    qer_editorimage textures/m_castl01/c_grass02.tga
    q3map_bounce 0.25
    q3map_shadeangle 120
    q3map_splotchfix
    surfaceparm nolightmap
    {
        map textures/m_castl01/c_grass02.tga
        blendFunc GL_ONE GL_ZERO
        rgbGen vertex
    }
}

Please note that there’s no terrain meshes used in the above pic. Heck, there aren’t any meshes in this map! :smiley: But this is the terrain method that I’m using for a much bigger map I’m working on, so I’d like to get the compiler and shader options figured out before I go gung-ho on lighting the big map. I’m sure the problems are either with my compiler options or my shader files, so if you see any errors can you post corrected examples?

Thanks in advance for the help, I really appreciate it!


(kat) #2

iirc you need to make anything you want phong apply to a func_group (not nessarily a ‘terrain entity’)


(Grand Nagus) #3

Yeah, they’re func_groups. Sorry, I guess that’s something I shoulda specified. I even tried compiling without func_groups and then compiling after putting the right terrain, left terrain, ‘V’ and ‘P’ into their own func_groups… Made absolutely no difference. Since I’m not trying to make the ‘grass’ brushes ‘terrain’, I shouldn’t have to make those brushes into a func_group. Besides, my big map has a lot of brush entities, and I think that func_groups count toward that entity limit (255).

Thanks for the help, though. :slight_smile:

EDIT - Now that I think about it, are there any keys I should put into those func_group? I just simply highlighted all of the relevant brushes and then made 'em into func_groups with no keys and values.


(kat) #4

The func_group thing isn’t about creating a terrain per-say, what it’s doing is basically telling the compiler to look at all the brushes in that group and light it accordingly, as if it was one object… if you leave them ungrouped you won’t get such an even result as it’s seeing all the brushes as individual units (basically).

I use phong shading quite a bit in the maps I’m currently doing but it’s not a shader parameter, it’s just enabled during compile (using q3map2toolz) w the -shade -shadeangle XX switch and it seems to work quite well. It might be worth seeing what results you get just using a straight texture rather than a shadertexture, as well as phong one of the other features of q3map2 is a kind of ‘auto smoothing’ that gets applied to func_grouped brushes.

As you did a copy/paste try a grab and move of the vertex points on the mesh as sometimes that ‘resets’ the way q3map2 looks at the brushwork (in a manor of speaking…!).