cel outline updates + r_celoutline 0/1 non-cheat

git-svn-id: https://svn.code.sf.net/p/q3cellshading/code/trunk@17 db09e94b-7117-0410-a7e6-85ae5ff6e0e9
This commit is contained in:
paied 2006-07-20 17:52:37 +00:00
parent 312d942064
commit 13742c7f2d
5 changed files with 229 additions and 48 deletions

View file

@ -231,13 +231,22 @@ $COMMON_CFLAGS = '-pipe -fsigned-char ';
if ($config eq 'debug')
{
# use -Werror for better QA
$BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';
# use -Werror for better QA
# REMIND ME TO ASK THE OTHER GUYS TO CLEAN OR FOR PERMISSION TO CLEAN THE UNUSED VARIABLES IN TR_IMAGE.C
# 2006-07-19 - bob.
# $BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';
$BASE_CFLAGS = $COMMON_CFLAGS . '-g -O ';
$BSPC_BASE_CFLAGS = $COMMON_CFLAGS . '-g -O -DLINUX -DBSPC -Dstricmp=strcasecmp ';
}
else
{
$BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
{
# edited at the request of the compiler. (warning about depo).
# 2006-07-19 - bob.
# $BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
$BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -falign-loops=2 -falign-jumps=2 -falign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
$BSPC_BASE_CFLAGS = $BASE_CFLAGS . '-DLINUX -DBSPC -Dstricmp=strcasecmp ';
}

View file

@ -1,3 +1,92 @@
# nasty ugly to get build system working from Anjuta
# /*//. Makefile to compile Q3 on Linux /
# ../ Bob 'tIKi_mAn' Majdak Jr /
# ../ http://www.opsat.net - bob@opsat.net .//*/
# first thing, this will not compile right out of the zip because of windows
# line endings apparently, so the first thing you should do after unzipping
# is `make fix`
# `make all` will build the engine and the game, whereas
# `make binary` will build the game engine binaries, and
# `make vm` will build the game code.
# `make sweep` will dump both the build and output directories.
# oh, by the way. this file goes in the code directory.
# example: /home/bob/src/quake3-1.32b/code/Makefile
# (yes overwrite the one there, lol)
# updated instructions from the ones above (after fixing the directory of course).
# `make binary` builds debug version (the default).
# `make binary-release` builds release version.
# `make fresh` cleans cleans things up.
# `make install-bin` will copy the compiled binary to the Q3_DIR/Q3_BIN.BUILD_TYPE.
# so basicly /path/quake3.x86.dbg or /path/quake3.x86.rel.
# `make final` takes the installed bin and moves it to its final resting place.
# so basicly /path/quake3.x86.dbg -> /path/quake3.x86
# backup your original q3 binary before running final-bin.
# a typical make command you will see me type.
# `make fresh binary install-bin`
# boom boom boom.
# edit these.
Q3_DIR="/home/games/quake3"
Q3_BIN="quake3.x86.cel"
# leave this one be.
BUILD_TYPE=`cat build.type`
all:
if [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 -- novm noso ; else ./unix/cons ; fi
perl unix/cons
all-release:
perl unix/cons -- release
fix:
perl -pi.bk -e 's/\r//' game/*.c game/*.h
perl -pi.bk -e 's/\r//' cgame/*.c cgame/*.h
perl -pi.bk -e 's/\r//' ui/*.c ui/*.h
perl -pi.bk -e 's/\r//' q3_ui/*.c q3_ui/*.h
binary:
echo "dbg" > build.type
perl unix/cons -- nosmp novm noso
binary-release:
echo "rel" > build.type
perl unix/cons -- release nosmp novm noso
vm:
perl unix/cons -- nosmp noso
vm-release:
perl unix/cons -- release nosmp noso
fresh:
rm -rf install
rm -rf debug-x86-Linux-2.3
rm -rf release-x86-Linux-2.3
rm -rf build.type
install-bin:
@case $(BUILD_TYPE) in \
*dbg*) \
echo "Debug Build"; \
cp -vf install/linuxquake3 $(Q3_DIR)/$(Q3_BIN).$(BUILD_TYPE);; \
*rel*) \
echo "Release Build"; \
cp -vf install/linuxquake3 $(Q3_DIR)/$(Q3_BIN).$(BUILD_TYPE);; \
*) \
echo "No Build Detected.";; \
esac
final:
@case $(BUILD_TYPE) in \
*dbg*) \
cp -vf $(Q3_DIR)/$(Q3_BIN).$(BUILD_TYPE) $(Q3_DIR)/$(Q3_BIN);; \
*rel*) \
cp -vf $(Q3_DIR)/$(Q3_BIN).$(BUILD_TYPE) $(Q3_DIR)/$(Q3_BIN);; \
*) \
echo "No Build Detected.";; \
esac

View file

@ -105,7 +105,9 @@ cvar_t *r_roundImagesDown;
cvar_t *r_colorMipLevels;
cvar_t *r_picmip;
// Next one added for cell shading algorithm selection
cvar_t *r_celshadalgo;
cvar_t *r_celshadalgo;
//. next one for enable/disable cel bordering all together.
cvar_t *r_celoutline;
cvar_t *r_showtris;
cvar_t *r_showsky;
cvar_t *r_shownormals;
@ -993,7 +995,9 @@ void R_Register( void )
r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT);
r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT);
// for cell shading algorithm selection
r_celshadalgo = ri.Cvar_Get ("r_celshadalgo", "1", CVAR_LATCH);
r_celshadalgo = ri.Cvar_Get ("r_celshadalgo", "1", CVAR_LATCH);
// cel outline option
r_celoutline = ri.Cvar_Get("r_celoutline","1", CVAR_ARCHIVE);
r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT);
r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT);
r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT);

View file

@ -1051,7 +1051,8 @@ extern cvar_t *r_vertexLight; // vertex lighting mode for better performance
extern cvar_t *r_uiFullScreen; // ui is running fullscreen
extern cvar_t *r_logFile; // number of frames to emit GL logs
extern cvar_t *r_celshadalgo; // Cell shading, chooses method: 0 = disabled, 1 = kuwahara, 2 = whiteTexture
extern cvar_t *r_celshadalgo; // Cell shading, chooses method: 0 = disabled, 1 = kuwahara, 2 = whiteTexture
extern cvar_t *r_celoutline; //. cel outline. 1 on, 0 off. (maybe other options later)
extern cvar_t *r_showtris; // enables wireframe rendering of the world
extern cvar_t *r_showsky; // forces sky in front of all surfaces
extern cvar_t *r_shownormals; // draws wireframe normals

View file

@ -195,7 +195,85 @@ static void R_DrawElements( int numIndexes, const glIndex_t *indexes ) {
// anything else will cause no drawing
}
static void R_DrawCel( int numIndexes, const glIndex_t *indexes ) {
if(
//. ignore the 2d projection. do i smell the HUD?
(backEnd.projection2D == qtrue) ||
//. ignore general entitites that are sprites. SEE NOTE #3.
(backEnd.currentEntity->e.reType == RT_SPRITE) ||
//. ignore these liquids. why? ever see liquid with tris on the surface? exactly. SEE NOTE #4.
(tess.shader->contentFlags & (CONTENTS_WATER | CONTENTS_LAVA | CONTENTS_SLIME | CONTENTS_FOG)) ||
//. ignore things that are two sided, meaning mostly things that have transparency. SEE NOTE #1.
(tess.shader->cullType == CT_TWO_SIDED)
) {
return;
}
int primitives;
primitives = r_primitives->integer;
// default is to use triangles if compiled vertex arrays are present
if ( primitives == 0 ) {
if ( qglLockArraysEXT ) {
primitives = 2;
} else {
primitives = 1;
}
}
//. correction for mirrors. SEE NOTE #2.
if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_FRONT); }
else { qglCullFace (GL_BACK); }
qglEnable (GL_BLEND);
qglBlendFunc (GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
qglColor3f (0.0f,0.0f,0.0f);
qglLineWidth(4.0f);
if(primitives == 2) {
qglDrawElements( GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, indexes );
} else if(primitives == 1) {
R_DrawStripElements( numIndexes, indexes, qglArrayElement );
} else if(primitives == 3) {
R_DrawStripElements( numIndexes, indexes, R_ArrayElementDiscrete );
}
//. correction for mirrors. SEE NOTE #2.
if(backEnd.viewParms.isMirror == qtrue) { qglCullFace (GL_BACK); }
else { qglCullFace (GL_FRONT); }
qglDisable (GL_BLEND);
return;
/* Notes
1. this is going to be a pain in the arse. it fixes things like light `beams` from being cel'd but it
also will ignore any other shader set with no culling. this usually is everything that is translucent.
but this is a good hack to clean up the screen untill something more selective comes along. or who knows
group desision might actually be that this is liked. if so i take back calling it a `hack`, lol.
= bob.
2. mirrors display correctly because the normals of the displayed are inverted of normal space. so to
continue to have them display correctly, we must invert them inversely from a normal inversion.
= bob.
3. this turns off a lot of space hogging sprite cel outlines. picture if you will five people in a small
room all shooting rockets. each smoke puff gets a big black square around it, each explosion gets a big
black square around it, and now nobody can see eachother because everyones screen is solid black.
= bob.
4. ignoring liquids means you will not get black tris lines all over the top of your liquid. i put this in
after seeing the lava on q3dm7 and water on q3ctf2 that had black lines all over the top, making the
liquids look solid instead of... liquid.
= bob.
*/
}
/*
=============================================================
@ -240,6 +318,32 @@ static void R_BindAnimatedImage( textureBundle_t *bundle ) {
GL_Bind( bundle->image[ index ] );
}
static void DrawCel (shaderCommands_t *input) {
GL_Bind( tr.whiteImage );
qglColor3f (1,1,1);
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT) {
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawCel( input->numIndexes, input->indexes );
if (qglUnlockArraysEXT) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
}
/*
================
@ -250,16 +354,11 @@ Draws triangle outlines for debugging
*/
static void DrawTris (shaderCommands_t *input) {
GL_Bind( tr.whiteImage );
qglColor3f (0,0,0);
// Added by gmiranda
qglHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
qglEnable(GL_LINE_SMOOTH);
qglColor3f (1,1,1);
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
// Fixed!
//qglDepthRange( 0, 1 ); /*was 0,0*/
qglDepthRange( 0, 0 );
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
@ -276,17 +375,10 @@ static void DrawTris (shaderCommands_t *input) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
// FIXED! (gmiranda)
//qglDepthRange( 0, 1 );
// Added by gmiranda & rutdaun
qglDisable(GL_LINE_SMOOTH);
qglDepthRange( 0, 1 );
}
/*
================
DrawNormals
@ -341,7 +433,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) {
tess.shaderTime = tess.shader->clampTime;
}
}
/*
@ -364,7 +455,6 @@ static void DrawMultitextured( shaderCommands_t *input, int stage ) {
// this is an ugly hack to work around a GeForce driver
// bug with multitexture and clip planes
if ( backEnd.viewParms.isPortal ) {
/*modificat*/
qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
}
@ -392,9 +482,6 @@ static void DrawMultitextured( shaderCommands_t *input, int stage ) {
R_BindAnimatedImage( &pStage->bundle[1] );
// Draw as usual
R_DrawElements( input->numIndexes, input->indexes );
//
@ -1011,7 +1098,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
// draw
//
R_DrawElements( input->numIndexes, input->indexes );
}
// allow skipping out to show just lightmaps during development
if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) )
@ -1054,17 +1140,13 @@ void RB_StageIteratorGeneric( void )
qglEnable( GL_POLYGON_OFFSET_FILL );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
// Cell Shading
// Big line size
qglLineWidth(4.0);
// Invert cullface. Normals in q3 are inverted.
qglCullFace(GL_BACK);
// Paint back with wireframe
DrawTris(input);
// Reset
qglCullFace(GL_FRONT);
qglLineWidth(1.0);
//. show me cel outlines.
//. there has to be a better place to put this.
if(r_celoutline->integer == 1) {
DrawCel(&tess);
}
//
// if there is only a single pass then we can enable color
// and texture arrays before we compile, otherwise we need
@ -1335,8 +1417,8 @@ void RB_StageIteratorLightmappedMultitexture( void ) {
void RB_EndSurface( void ) {
shaderCommands_t *input;
input = &tess;
input = &tess;
if (input->numIndexes == 0) {
return;
}
@ -1374,13 +1456,9 @@ void RB_EndSurface( void ) {
//
// draw debugging stuff
//
/*modificat*/
if ( r_showtris->integer ) {
DrawTris (input);
}
if ( r_shownormals->integer ) {
DrawNormals (input);
}