PDA

View Full Version : Quake3 Shaders



01-04-2002, 07:21 PM
// Sample quake 3 shader
textures/test/test_shader
{

{
map $lightmap
rgbGen identity
}

{
map launchpad_diamond.jpg
rgbGen identity
blendfunc gl_dst_color gl_zero
}

{
map launchpad_dot.jpg
blendfunc gl_one gl_one
}

}

{
map launchpad_arrow.tga
blendfunc gl_one gl_one
}


// ok i want to convert this to opengl code so is this right

glBindTexture(GL_TEXTURE_2D, tList[face_lightmap]);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
renderface();

glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, tList([launchpad_diamond]);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
renderface();

glBindTexture(GL_TEXTURE_2D, tList[launchpad_dot]);
glBlendFunc(GL_ONE, GL_ONE);
renderface();

glBindTexture(GL_TEXTURE_2D, tList[launchpad_arrow]);
glBlendFunc(GL_ONE, GL_ONE);
renderface();

DFrey
01-04-2002, 07:39 PM
That is one way of doing it. However a couple optimaztions you could make would be to use multitexture to combine the first two and last two passes, so you only need to draw two passes then (assuming only 2 texture units). Also, before drawing the second pass, disable Z buffer writes (but leave depth testing enabled) as there is no point wasting bandwidth to write depth values that have already been written.

01-04-2002, 07:48 PM
Thanks for that, assuming i dont want to use multitexture just yet and am happy to use 4 passes. could u drop some psuedo code there for me pweddy please http://www.opengl.org/discussion_boards/ubb/smile.gif

01-04-2002, 07:57 PM
Another Q, when uploading a RGB texture should i be adding an alpha channel myself to create RGBA, or just leave it as RGB?