Skip to content

Commit d497beb

Browse files
committed
feat: add bodge for outline
Signed-off-by: Michael Pollind <[email protected]>
1 parent 9a2fb28 commit d497beb

File tree

4 files changed

+62
-41
lines changed

4 files changed

+62
-41
lines changed

source/qcommon/snap_write.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ static bool SNAP_SnapCullEntity( cmodel_state_t *cms, edict_t *ent, edict_t *cle
909909
if( frame->allentities )
910910
return false;
911911

912+
if(ent->s.type == ET_PLAYER || ent->s.type == ET_CORPSE)
913+
return false;
914+
912915
// filters: transmit only to clients in the same team as this entity
913916
// broadcasting is less important than team specifics
914917
if( ( ent->r.svflags & SVF_ONLYTEAM ) && ( clent && ent->s.team != clent->s.team ) )

source/ref_gl/r_backend_program.c

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum
3636
BUILTIN_GLSLPASS_SKYBOX,
3737
BUILTIN_GLSLPASS_OVERLAY_OUTLINE_0,
3838
BUILTIN_GLSLPASS_OVERLAY_OUTLINE_1,
39+
BUILTIN_GLSLPASS_OVERLAY_OUTLINE_2,
3940
MAX_BUILTIN_GLSLPASSES
4041
};
4142

@@ -118,6 +119,14 @@ static void RB_InitBuiltinPasses( void )
118119
pass->alphagen.type = ALPHA_GEN_OUTLINE;
119120
pass->tcgen = TC_GEN_NONE;
120121
pass->program_type = GLSL_PROGRAM_TYPE_OUTLINE_1;
122+
123+
// overlay outline
124+
pass = &r_GLSLpasses[BUILTIN_GLSLPASS_OVERLAY_OUTLINE_2];
125+
pass->flags = 0;
126+
pass->rgbgen.type = RGB_GEN_OUTLINE;
127+
pass->alphagen.type = ALPHA_GEN_OUTLINE;
128+
pass->tcgen = TC_GEN_NONE;
129+
pass->program_type = GLSL_PROGRAM_TYPE_OUTLINE_2;
121130

122131

123132
// skybox
@@ -1388,14 +1397,11 @@ static void RB_RenderMeshGLSL_Shadowmap( const shaderpass_t *pass, r_glslfeat_t
13881397
*/
13891398
static void RB_RenderMeshGLSL_StencilOutline_0( const shaderpass_t *pass, r_glslfeat_t programFeatures )
13901399
{
1391-
if( rb.currentModelType == mod_brush ) {
1392-
programFeatures |= GLSL_SHADER_OUTLINE_OUTLINES_CUTOFF;
1393-
}
1394-
1400+
Vector4Copy( rb.currentEntity->outlineColorGhost, rb.entityOutlineColor );
1401+
rb.entityOutlineColor[0] *= .7f;
1402+
rb.entityOutlineColor[1] *= .7f;
1403+
rb.entityOutlineColor[2] *= .7f;
13951404
programFeatures |= RB_RGBAlphaGenToProgramFeatures( &pass->rgbgen, &pass->alphagen );
1396-
1397-
programFeatures |= RB_FogProgramFeatures( pass, rb.fog );
1398-
13991405
// update uniforcms
14001406
int program = RB_RegisterProgram( GLSL_PROGRAM_TYPE_OUTLINE, NULL,
14011407
rb.currentShader->deformsKey,
@@ -1408,10 +1414,6 @@ static void RB_RenderMeshGLSL_StencilOutline_0( const shaderpass_t *pass, r_glsl
14081414
mat4_t texMatrix;
14091415
Matrix4_Identity( texMatrix );
14101416
RB_UpdateCommonUniforms( program, pass, texMatrix );
1411-
1412-
if( programFeatures & GLSL_SHADER_COMMON_FOG ) {
1413-
RB_UpdateFogUniforms( program, rb.fog );
1414-
}
14151417

14161418
// submit animation data
14171419
if( programFeatures & GLSL_SHADER_COMMON_BONE_TRANSFORMS ) {
@@ -1423,25 +1425,15 @@ static void RB_RenderMeshGLSL_StencilOutline_0( const shaderpass_t *pass, r_glsl
14231425
RB_SetStencilOp( GL_REPLACE, GL_ZERO, GL_REPLACE);
14241426
RB_SetStencilFunc( GL_ALWAYS, 1, 0xFF );
14251427

1426-
RB_SetShaderpassState( pass->flags | GLSTATE_STENCIL_TEST | GLSTATE_DEPTHFUNC_GT | GLSTATE_NO_COLORWRITE );
1427-
RP_UpdateOutlineUniforms( program, rb.currentEntity->outlineHeight * r_outlines_scale->value );
1428+
RB_SetShaderpassState( pass->flags | GLSTATE_STENCIL_TEST | GLSTATE_DEPTHFUNC_GT);// | GLSTATE_NO_COLORWRITE );
1429+
RP_UpdateOutlineUniforms( program, rb.currentEntity->outlineGhost);
14281430
RB_DrawElementsReal( &rb.drawElements );
14291431
}
14301432

1431-
1432-
/*
1433-
* RB_RenderMeshGLSL_Outline
1434-
*/
14351433
static void RB_RenderMeshGLSL_StencilOutline_1( const shaderpass_t *pass, r_glslfeat_t programFeatures )
14361434
{
1437-
if( rb.currentModelType == mod_brush ) {
1438-
programFeatures |= GLSL_SHADER_OUTLINE_OUTLINES_CUTOFF;
1439-
}
1440-
1435+
Vector4Copy( rb.currentEntity->outlineColorGhost, rb.entityOutlineColor );
14411436
programFeatures |= RB_RGBAlphaGenToProgramFeatures( &pass->rgbgen, &pass->alphagen );
1442-
1443-
programFeatures |= RB_FogProgramFeatures( pass, rb.fog );
1444-
14451437
// update uniforcms
14461438
int program = RB_RegisterProgram( GLSL_PROGRAM_TYPE_OUTLINE, NULL,
14471439
rb.currentShader->deformsKey,
@@ -1454,10 +1446,6 @@ static void RB_RenderMeshGLSL_StencilOutline_1( const shaderpass_t *pass, r_glsl
14541446
mat4_t texMatrix;
14551447
Matrix4_Identity( texMatrix );
14561448
RB_UpdateCommonUniforms( program, pass, texMatrix );
1457-
1458-
if( programFeatures & GLSL_SHADER_COMMON_FOG ) {
1459-
RB_UpdateFogUniforms( program, rb.fog );
1460-
}
14611449

14621450
// submit animation data
14631451
if( programFeatures & GLSL_SHADER_COMMON_BONE_TRANSFORMS ) {
@@ -1473,6 +1461,36 @@ static void RB_RenderMeshGLSL_StencilOutline_1( const shaderpass_t *pass, r_glsl
14731461
RB_DrawElementsReal( &rb.drawElements );
14741462
}
14751463

1464+
static void RB_RenderMeshGLSL_StencilOutline_2( const shaderpass_t *pass, r_glslfeat_t programFeatures )
1465+
{
1466+
Vector4Copy( rb.currentEntity->outlineColorGhost, rb.entityOutlineColor );
1467+
programFeatures |= RB_RGBAlphaGenToProgramFeatures( &pass->rgbgen, &pass->alphagen );
1468+
// update uniforcms
1469+
int program = RB_RegisterProgram( GLSL_PROGRAM_TYPE_OUTLINE, NULL,
1470+
rb.currentShader->deformsKey,
1471+
rb.currentShader->deforms,
1472+
rb.currentShader->numdeforms,
1473+
programFeatures );
1474+
if( !RB_BindProgram( program ) )
1475+
return;
1476+
1477+
// submit animation data
1478+
if( programFeatures & GLSL_SHADER_COMMON_BONE_TRANSFORMS ) {
1479+
RP_UpdateBonesUniforms( program, rb.bonesData.numBones, rb.bonesData.dualQuats );
1480+
}
1481+
mat4_t texMatrix;
1482+
Matrix4_Identity( texMatrix );
1483+
RB_UpdateCommonUniforms( program, pass, texMatrix );
1484+
1485+
RB_SetStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
1486+
RB_SetStencilFunc( GL_EQUAL, 1, 0xFF );
1487+
RB_SetStencilMask( 0x00 );
1488+
1489+
RB_SetShaderpassState( pass->flags | GLSTATE_NO_DEPTH_TEST | GLSTATE_STENCIL_TEST );
1490+
RP_UpdateOutlineUniforms( program, rb.currentEntity->outlineGhost );
1491+
RB_DrawElementsReal( &rb.drawElements );
1492+
}
1493+
14761494
/*
14771495
* RB_RenderMeshGLSL_Outline
14781496
*/
@@ -1522,16 +1540,6 @@ static void RB_RenderMeshGLSL_Outline( const shaderpass_t *pass, r_glslfeat_t pr
15221540
RB_Cull( faceCull );
15231541

15241542
if(rb.currentEntity->outlineGhost) {
1525-
Vector4Copy( rb.currentEntity->outlineColorGhost, rb.entityOutlineColor );
1526-
RB_UpdateCommonUniforms( program, pass, texMatrix );
1527-
1528-
RB_SetStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
1529-
RB_SetStencilFunc( GL_EQUAL, 1, 0xFF );
1530-
RB_SetStencilMask( 0x00 );
1531-
1532-
RB_SetShaderpassState( pass->flags | GLSTATE_NO_DEPTH_TEST | GLSTATE_STENCIL_TEST );
1533-
RP_UpdateOutlineUniforms( program, rb.currentEntity->outlineGhost * r_outlines_scale->value );
1534-
RB_DrawElementsReal( &rb.drawElements );
15351543
}
15361544
}
15371545

@@ -2022,6 +2030,9 @@ void RB_RenderMeshGLSLProgrammed( const shaderpass_t *pass, int programType )
20222030
case GLSL_PROGRAM_TYPE_OUTLINE_1:
20232031
RB_RenderMeshGLSL_StencilOutline_1(pass, features );
20242032
break;
2033+
case GLSL_PROGRAM_TYPE_OUTLINE_2:
2034+
RB_RenderMeshGLSL_StencilOutline_2(pass, features );
2035+
break;
20252036
case GLSL_PROGRAM_TYPE_OUTLINE:
20262037
RB_RenderMeshGLSL_Outline( pass, features );
20272038
break;
@@ -2532,6 +2543,9 @@ void RB_DrawShadedElements( void )
25322543
if( addGLSLOutline )
25332544
RB_RenderPass( &r_GLSLpasses[BUILTIN_GLSLPASS_OUTLINE] );
25342545

2546+
if(rb.currentEntity->outlineGhost)
2547+
RB_RenderPass( &r_GLSLpasses[BUILTIN_GLSLPASS_OVERLAY_OUTLINE_2] );
2548+
25352549
// fog
25362550
if( rb.texFog && rb.texFog->shader )
25372551
{

source/ref_gl/r_cull.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,16 @@ int R_CullModelEntity( const entity_t *e, vec3_t mins, vec3_t maxs, float radius
302302
return 1;
303303
}
304304

305-
if( e->flags & (RF_NODEPTHTEST | RF_OUTLINE_STENCIL_1 | RF_OUTLINE_STENCIL_0) )
306-
return 0;
307-
308305
// account for possible outlines
309306
if( e->outlineHeight )
310307
radius += e->outlineHeight * r_outlines_scale->value * 1.73/*sqrt(3)*/;
311308

309+
if( e->outlineGhost > 0)
310+
return 0;
311+
312+
if( e->flags & (RF_NODEPTHTEST | RF_OUTLINE_STENCIL_1 | RF_OUTLINE_STENCIL_0) )
313+
return 0;
314+
312315
if( sphereCull )
313316
{
314317
if( R_CullSphere( e->origin, radius, rn.clipFlags ) )

source/ref_gl/r_program.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ enum
5656
GLSL_PROGRAM_TYPE_COLORCORRECTION,
5757
GLSL_PROGRAM_TYPE_OUTLINE_0,
5858
GLSL_PROGRAM_TYPE_OUTLINE_1,
59+
GLSL_PROGRAM_TYPE_OUTLINE_2,
5960

6061
GLSL_PROGRAM_TYPE_MAXTYPE
6162
};

0 commit comments

Comments
 (0)