Skip to content

Commit 209f435

Browse files
committed
- preliminary deformvertex ripples
- some hacky new modes for deformvertex normal - refactor map2-8/animmap2-8/videomap2-8/clampanimmap2-8
1 parent d8d2458 commit 209f435

File tree

6 files changed

+439
-1135
lines changed

6 files changed

+439
-1135
lines changed

code/renderer_oa/tr_init.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,30 @@ cvar_t *r_skytess; // leilei - lower detail of skies
223223
cvar_t *r_leidebug; // Leilei - debug
224224
cvar_t *r_leidebugeye; // Leilei - eye debug
225225

226-
cvar_t *r_suggestiveThemes; // leilei - mature content control
227-
226+
cvar_t *r_suggestiveThemes; // leilei - mature content control
228227
cvar_t *r_textureDither; // leilei - Dithered texture
229-
230228
cvar_t *r_lerpbias; // Leilei - lerping bias
229+
cvar_t *r_ripples; // leilei - Ripples
230+
231+
// leilei - hardware support cvars, for shaders to think about
232+
233+
cvar_t *glhw_3dfx; // 1 = V1/Rush, 2 = V2, 3 = Banshee/V3, 4=Voodoo4/5
234+
// V1 cannot handle depth function effects. No clamping on earlier ICDs.
235+
cvar_t *glhw_rage; // 1 = Rage Pro, 2 = Rage XL, 3 = Rage128
236+
// Rage Pro cannot do hardware alpha blends nor can modulate them.
237+
cvar_t *glhw_mga; // 1 = Mystique, 2 = G100, 3 = G200
238+
// Mystique / G100 does not have blending functions and the only alpha blending is dithered.
239+
cvar_t *glhw_powervr; // 1 = PCX2, 2 = Neon250, 3 = KYRO , 4 = GMA
240+
// PCX2 does not have blending functions and will always render RGBA4444 textures as a blend.
241+
// None of these cards have depth testing. No clamping or rectangle textures on PCX2.
242+
cvar_t *glhw_geforce; // 1 = 256, 2 = 2, 3 = 3, 4 = 4Ti, 5 = FX, 6 = 6, 7 = 7, 8 = 8, 9 = 9, 10 = Tesla
243+
// 256 and 2 have early driver issues.
244+
cvar_t *glhw_radeon; // 1 = 7x00, 2 = 8x00-9200, 3 = 9500-x800, 4 = x1x00, 5 = HD2, 6 = HD3-4-5-6, 7 = GCN, 8 = Vega, 9 = RNA
245+
// Vega and RNA have driver issues wrt OpenGL 2.
246+
cvar_t *glhw_s3; // 1 = ViRGE, 2 = Trio3D, 3 = Savage3D , 4 = Savage4/ProSavage, 5 = Savage 2000
247+
cvar_t *glhw_software; // 1 = Microsoft, 2 = SGI/Cosmo, 3 = Mesa, 4 = LLVMPipe Gallium, 5 = TinyGL
248+
// Varies of pain
249+
231250

232251
// leilei - fallback shader hack
233252

@@ -1319,6 +1338,7 @@ void R_Register( void )
13191338
r_leidebugeye = ri.Cvar_Get( "r_leidebugeye", "0" , CVAR_CHEAT);
13201339

13211340
r_lerpbias = ri.Cvar_Get( "r_lerpbias", "-2" , CVAR_ARCHIVE);
1341+
r_ripples = ri.Cvar_Get( "r_ripples", "1" , CVAR_ARCHIVE);
13221342

13231343
r_iconmip = ri.Cvar_Get ("r_iconmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - icon mip
13241344
r_iconBits = ri.Cvar_Get ("r_iconBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); // leilei - icon bits
@@ -1612,6 +1632,10 @@ void R_Init( void )
16121632
#ifdef GLSL_BACKEND
16131633
R_GLSL_Init();
16141634
#endif
1635+
1636+
tr.refdef.enableRipples = 0; // leilei - set this 0 before shaders load, so we can keep the engine calm
1637+
// on processing unless we really do have a shader with a deformvertexes ripple in it
1638+
// in which this will be 1.
16151639
R_InitShaders();
16161640

16171641
R_InitSkins();
@@ -1620,7 +1644,6 @@ void R_Init( void )
16201644

16211645
R_InitFreeType();
16221646

1623-
16241647
err = qglGetError();
16251648
if ( err != GL_NO_ERROR )
16261649
ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err);

code/renderer_oa/tr_local.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ typedef enum {
208208
DEFORM_TEXT5,
209209
DEFORM_TEXT6,
210210
DEFORM_TEXT7,
211+
DEFORM_RIPPLE,
212+
DEFORM_AUTOSPRITE3,
211213
DEFORM_LFX
212214
} deform_t;
213215

@@ -539,6 +541,26 @@ typedef struct shader_s {
539541
#define SHADMAT_CONCRETE 7 // unused? redundant?
540542
#define SHADMAT_ICE 8 // from slick
541543

544+
// leilei - ripple
545+
#define MAX_RIPPLES 120 // ripple verts will go through all of them, so we cant have too many to check
546+
547+
548+
typedef struct ripple_s {
549+
vec3_t origin;
550+
float radius;
551+
float radiusLp;
552+
float time;
553+
float life;
554+
float decay; // leilei - will clean this
555+
float amp; // changed by time
556+
float ampLp;
557+
float timeStart;
558+
float timeEnd;
559+
float ogRadius; // doesnt change from creation
560+
float ogAmp; // ditto
561+
} ripple_t;
562+
563+
542564
// trRefdef_t holds everything that comes in refdef_t,
543565
// as well as the locally generated scene information
544566
typedef struct {
@@ -573,6 +595,10 @@ typedef struct {
573595
int numDrawSurfs;
574596
struct drawSurf_s *drawSurfs;
575597

598+
int num_ripple;
599+
struct ripple_s *ripple;
600+
int enableRipples;
601+
576602
} trRefdef_t;
577603

578604

@@ -1474,6 +1500,7 @@ extern cvar_t *r_iconmip; // leilei - icon mip - picmip for 2d icons
14741500
extern cvar_t *r_iconBits; // leilei - icon color depth for 2d icons
14751501

14761502
extern cvar_t *r_lerpbias; // Leilei - lerping bias
1503+
extern cvar_t *r_ripples; // Leilei - ripples
14771504

14781505
extern cvar_t *r_lightmapBits; // leilei - lightmap color depth
14791506
extern cvar_t *r_lightmapColorNorm; // leilei - lightmap color normalize
@@ -2123,7 +2150,8 @@ void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *vert
21232150
void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
21242151
void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
21252152
void RE_RenderScene( const refdef_t *fd );
2126-
2153+
void RE_AddRippleToScene( const vec3_t org, float intensity ); // leilei - ripples
2154+
void RE_ManageRipples( void ); // leilei - ripples
21272155
/*
21282156
=============================================================
21292157
@@ -2345,6 +2373,7 @@ typedef struct {
23452373
trRefEntity_t entities[MAX_REFENTITIES];
23462374
srfPoly_t *polys;//[MAX_POLYS];
23472375
polyVert_t *polyVerts;//[MAX_POLYVERTS];
2376+
ripple_t ripples[MAX_RIPPLES];
23482377
renderCommandList_t commands;
23492378
} backEndData_t;
23502379

@@ -2404,5 +2433,7 @@ void LFX_ShaderInit(void);
24042433
void LFX_ParticleEffect (int effect, const vec3_t org, const vec3_t dir);
24052434
void RE_GetViewPosition(vec3_t point);
24062435

2436+
2437+
24072438
#endif //TR_LOCAL_H
24082439

code/renderer_oa/tr_particles.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha)
293293
float height;
294294
float time, time2;
295295
float ratio;
296-
int fogNum = 0;
296+
int fogNum = tess.fogNum;
297297
float invratio;
298298
vec4_t color;
299299

@@ -313,6 +313,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha)
313313
ratio = time / time2;
314314

315315
// Do us some fogging fogger
316+
/*
316317
{
317318
byte fogFactors[3] = {255, 255, 255};
318319
if(tr.world && p->fogNum > 0 && p->fogNum < tr.world->numfogs) {
@@ -324,7 +325,7 @@ void R_AddParticleToScene (particle_t *p, vec3_t org, float alpha)
324325
325326
}
326327
}
327-
328+
*/
328329

329330

330331
{
@@ -2600,7 +2601,7 @@ void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir)
26002601
R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 15, 240, 22, 1);
26012602

26022603
R_LFX_Spark (sprOrg, sprVel, 175, 5, colory, colory2, colory3, colory4, colory4, 25, 1240, 0.8f, 1);
2603-
2604+
RE_AddRippleToScene( origin, 300 );
26042605
}
26052606

26062607
// BFG
@@ -2656,6 +2657,8 @@ void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir)
26562657
R_LFX_Burst (sprOrg, sprVel, 175, 15, colory, colory2, colory3, colory4, colory4, 15, 140, 32, 1);
26572658

26582659
R_LFX_Spark (sprOrg, sprVel, 175, 5, colory, colory2, colory3, colory4, colory4, 15, 1040, 0.8f, 1);
2660+
2661+
RE_AddRippleToScene( origin, 300 );
26592662
}
26602663

26612664
// Nail Hit
@@ -2696,7 +2699,7 @@ void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir)
26962699
colory4[1] = 0.0;
26972700
colory4[2] = 0.0;
26982701
colory4[3] = 0.0;
2699-
2702+
RE_AddRippleToScene( origin, 64 );
27002703
VectorMA( origin, 4, dir, sprOrg );
27012704
VectorScale( dir, 1, sprVel );
27022705

@@ -2827,6 +2830,8 @@ void LFX_ParticleEffect200X (int effect, const vec3_t org, const vec3_t dir)
28272830
colory4[2] = 0.0;
28282831
colory4[3] = 0.0;
28292832
VectorScale( dir, 39, sprVel );
2833+
RE_AddRippleToScene( origin, 64 );
2834+
28302835
R_LFX_Shock (origin, dir, 0, 0, colory, colory2, colory3, colory4, colory4, 1, 800, 80,14);
28312836
R_LFX_Burst (sprOrg, sprVel, 22, 266, colory, colory2, colory3, colory4, colory4, 1, 1900, 5, 7);
28322837
R_LFX_Spark (sprOrg, sprVel, 134, 4, colory, colory2, colory3, colory4, colory4, 7, 1286, 0.5f, 1);

code/renderer_oa/tr_scene.c

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ int r_firstScenePoly;
3535

3636
int r_numpolyverts;
3737

38+
int r_numripples;
39+
int r_firstSceneRipple;
3840

3941
/*
4042
====================
@@ -57,6 +59,9 @@ void R_InitNextFrame( void ) {
5759
r_firstScenePoly = 0;
5860

5961
r_numpolyverts = 0;
62+
63+
r_numripples = 0;
64+
r_firstSceneRipple = 0;
6065
}
6166

6267

@@ -70,6 +75,7 @@ void RE_ClearScene( void ) {
7075
r_firstSceneDlight = r_numdlights;
7176
r_firstSceneEntity = r_numentities;
7277
r_firstScenePoly = r_numpolys;
78+
r_firstSceneRipple = r_numripples;
7379
}
7480

7581
/*
@@ -292,6 +298,8 @@ RE_AddLightToScene
292298
*/
293299
void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) {
294300
RE_AddDynamicLightToScene( org, intensity, r, g, b, qfalse );
301+
302+
//RE_AddRippleToScene( org, intensity );
295303
}
296304

297305
/*
@@ -304,6 +312,90 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, flo
304312
RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue );
305313
}
306314

315+
316+
317+
/*
318+
=====================
319+
RE_AddRippleToScene
320+
321+
leilei - manage the ripples here. do a delay. just do something
322+
323+
=====================
324+
*/
325+
326+
float riptime = 0;
327+
328+
329+
void RE_AddRippleToScene( const vec3_t org, float intensity ) {
330+
ripple_t *r;
331+
332+
if ( !tr.registered ) {
333+
return;
334+
}
335+
if ( r_numripples >= MAX_RIPPLES ) {
336+
return;
337+
}
338+
if ( !tr.refdef.enableRipples ) {
339+
return;
340+
}
341+
if ( !r_ripples->value ) {
342+
return;
343+
}
344+
345+
r = &backEndData->ripples[r_numripples++];
346+
347+
while (r->amp >= 0.02f){ // next....
348+
if (r_numripples < 0)
349+
return; // dont!!!
350+
if (r_numripples >= 96)
351+
return; // dont!!!
352+
r = &backEndData->ripples[r_numripples++]; // Go to the next ripple
353+
}
354+
355+
//ri.Printf( PRINT_DEVELOPER, "RE_AddRippleToScene: numripples is %i\n", r_numripples);
356+
357+
// Got a clean ripple, initialize it
358+
r->timeStart = backEnd.refdef.time;
359+
r->timeEnd = backEnd.refdef.time + (1000);
360+
361+
VectorCopy (org, r->origin);
362+
r->radius = intensity;
363+
r->amp = intensity * 0.12f;
364+
365+
r->ogAmp = r->amp;
366+
r->ogRadius = r->radius;
367+
368+
if (riptime > tr.refdef.time + 500) // wait a sec, is there a big drift????
369+
riptime = 0;
370+
}
371+
372+
373+
void RE_ManageRipples( void ) {
374+
ripple_t *r;
375+
int f;
376+
float pastrip;
377+
float frip;
378+
pastrip = tr.refdef.time - riptime;
379+
if ( !tr.refdef.enableRipples ) {
380+
return;
381+
}
382+
383+
if ( !r_ripples->value ) {
384+
return;
385+
}
386+
387+
for (f=0; f<MAX_RIPPLES;f++)
388+
{
389+
r = &backEndData->ripples[f];
390+
r->radius += 1-(pastrip)/160.0f; // FIXME: this is currently wrong
391+
r->amp *= 1-(pastrip)/130.0f; // as i only developed this on com_maxfps 144
392+
if (r->amp <= 0.0004f){ r->amp =0; r_numripples--; } // kill it if we don't amp much.
393+
394+
}
395+
riptime = tr.refdef.time + 4;
396+
}
397+
398+
307399
/*
308400
@@@@@@@@@@@@@@@@@@@@@
309401
RE_RenderScene
@@ -388,6 +480,10 @@ void RE_RenderScene( const refdef_t *fd ) {
388480
tr.refdef.numPolys = r_numpolys - r_firstScenePoly;
389481
tr.refdef.polys = &backEndData->polys[r_firstScenePoly];
390482

483+
tr.refdef.num_ripple = r_numripples - r_firstSceneRipple;
484+
tr.refdef.ripple = &backEndData->ripples[r_firstSceneRipple];
485+
486+
391487
// turn off dynamic lighting globally by clearing all the
392488
// dlights if it needs to be disabled or if vertex lighting is enabled
393489
if ( r_dynamiclight->integer == 0 // ||
@@ -460,13 +556,15 @@ void RE_RenderScene( const refdef_t *fd ) {
460556

461557
VectorCopy( fd->vieworg, parms.pvsOrigin );
462558

559+
RE_ManageRipples();
560+
463561
R_RenderView( &parms );
464562

465563
// the next scene rendered in this frame will tack on after this one
466564
r_firstSceneDrawSurf = tr.refdef.numDrawSurfs;
467565
r_firstSceneEntity = r_numentities;
468566
r_firstSceneDlight = r_numdlights;
469567
r_firstScenePoly = r_numpolys;
470-
568+
r_firstSceneRipple = r_numripples;
471569
tr.frontEndMsec += ri.Milliseconds() - startTime;
472570
}

0 commit comments

Comments
 (0)