forked from id-Software/Quake-III-Arena
/
tr_local.h
2493 lines (1944 loc) · 64.1 KB
/
tr_local.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef TR_LOCAL_H
#define TR_LOCAL_H
#include "../qcommon/q_shared.h"
#include "../qcommon/qfiles.h"
#include "../qcommon/qcommon.h"
#include "../renderercommon/tr_public.h"
#include "../renderercommon/tr_common.h"
#include "tr_extratypes.h"
#include "tr_extramath.h"
#include "tr_fbo.h"
#include "tr_postprocess.h"
#include "../renderercommon/iqm.h"
#include "../renderercommon/qgl.h"
#define GL_INDEX_TYPE GL_UNSIGNED_INT
typedef unsigned int glIndex_t;
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
// 14 bits
// can't be increased without changing bit packing for drawsurfs
// see QSORT_SHADERNUM_SHIFT
#define SHADERNUM_BITS 14
#define MAX_SHADERS (1<<SHADERNUM_BITS)
#define MAX_FBOS 64
#define MAX_VISCOUNTS 5
#define MAX_VAOS 4096
#define MAX_CALC_PSHADOWS 64
#define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces
#define PSHADOW_MAP_SIZE 512
#define CUBE_MAP_MIPS 7
#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS)
#define USE_VERT_TANGENT_SPACE
typedef struct dlight_s {
vec3_t origin;
vec3_t color; // range from 0.0 to 1.0, should be color normalized
float radius;
vec3_t transformed; // origin in local coordinate system
int additive; // texture detail is lost tho when the lightmap is dark
} dlight_t;
// a trRefEntity_t has all the information passed in by
// the client game, as well as some locally derived info
typedef struct {
refEntity_t e;
float axisLength; // compensate for non-normalized axis
qboolean needDlights; // true for bmodels that touch a dlight
qboolean lightingCalculated;
qboolean mirrored; // mirrored matrix, needs reversed culling
vec3_t lightDir; // normalized direction towards light, in world space
vec3_t modelLightDir; // normalized direction towards light, in model space
vec3_t ambientLight; // color normalized to 0-255
int ambientLightInt; // 32 bit rgba packed
vec3_t directedLight;
} trRefEntity_t;
typedef struct {
vec3_t origin; // in world coordinates
vec3_t axis[3]; // orientation in world
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
float modelMatrix[16];
float transformMatrix[16];
} orientationr_t;
// Ensure this is >= the ATTR_INDEX_COUNT enum below
#define VAO_MAX_ATTRIBS 16
typedef enum
{
VAO_USAGE_STATIC,
VAO_USAGE_DYNAMIC
} vaoUsage_t;
typedef struct vaoAttrib_s
{
uint32_t enabled;
uint32_t count;
uint32_t type;
uint32_t normalized;
uint32_t stride;
uint32_t offset;
}
vaoAttrib_t;
typedef struct vao_s
{
char name[MAX_QPATH];
uint32_t vao;
uint32_t vertexesVBO;
int vertexesSize; // amount of memory data allocated for all vertices in bytes
vaoAttrib_t attribs[VAO_MAX_ATTRIBS];
uint32_t frameSize; // bytes to skip per frame when doing vertex animation
uint32_t indexesIBO;
int indexesSize; // amount of memory data allocated for all triangles in bytes
} vao_t;
//===============================================================================
typedef enum {
SS_BAD,
SS_PORTAL, // mirrors, portals, viewscreens
SS_ENVIRONMENT, // sky box
SS_OPAQUE, // opaque
SS_DECAL, // scorch marks, etc.
SS_SEE_THROUGH, // ladders, grates, grills that may have small blended edges
// in addition to alpha test
SS_BANNER,
SS_FOG,
SS_UNDERWATER, // for items that should be drawn in front of the water plane
SS_BLEND0, // regular transparency and filters
SS_BLEND1, // generally only used for additive type effects
SS_BLEND2,
SS_BLEND3,
SS_BLEND6,
SS_STENCIL_SHADOW,
SS_ALMOST_NEAREST, // gun smoke puffs
SS_NEAREST // blood blobs
} shaderSort_t;
#define MAX_SHADER_STAGES 8
typedef enum {
GF_NONE,
GF_SIN,
GF_SQUARE,
GF_TRIANGLE,
GF_SAWTOOTH,
GF_INVERSE_SAWTOOTH,
GF_NOISE,
GF_RANDOM
} genFunc_t;
typedef enum {
DEFORM_NONE,
DEFORM_WAVE,
DEFORM_NORMALS,
DEFORM_BULGE,
DEFORM_MOVE,
DEFORM_PROJECTION_SHADOW,
DEFORM_AUTOSPRITE,
DEFORM_AUTOSPRITE2,
DEFORM_TEXT0,
DEFORM_TEXT1,
DEFORM_TEXT2,
DEFORM_TEXT3,
DEFORM_TEXT4,
DEFORM_TEXT5,
DEFORM_TEXT6,
DEFORM_TEXT7
} deform_t;
// deformVertexes types that can be handled by the GPU
typedef enum
{
// do not edit: same as genFunc_t
DGEN_NONE,
DGEN_WAVE_SIN,
DGEN_WAVE_SQUARE,
DGEN_WAVE_TRIANGLE,
DGEN_WAVE_SAWTOOTH,
DGEN_WAVE_INVERSE_SAWTOOTH,
DGEN_WAVE_NOISE,
// do not edit until this line
DGEN_BULGE,
DGEN_MOVE
} deformGen_t;
typedef enum {
AGEN_IDENTITY,
AGEN_SKIP,
AGEN_ENTITY,
AGEN_ONE_MINUS_ENTITY,
AGEN_VERTEX,
AGEN_ONE_MINUS_VERTEX,
AGEN_LIGHTING_SPECULAR,
AGEN_WAVEFORM,
AGEN_PORTAL,
AGEN_CONST,
} alphaGen_t;
typedef enum {
CGEN_BAD,
CGEN_IDENTITY_LIGHTING, // tr.identityLight
CGEN_IDENTITY, // always (1,1,1,1)
CGEN_ENTITY, // grabbed from entity's modulate field
CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate
CGEN_EXACT_VERTEX, // tess.vertexColors
CGEN_VERTEX, // tess.vertexColors * tr.identityLight
CGEN_EXACT_VERTEX_LIT, // like CGEN_EXACT_VERTEX but takes a light direction from the lightgrid
CGEN_VERTEX_LIT, // like CGEN_VERTEX but takes a light direction from the lightgrid
CGEN_ONE_MINUS_VERTEX,
CGEN_WAVEFORM, // programmatically generated
CGEN_LIGHTING_DIFFUSE,
CGEN_FOG, // standard fog
CGEN_CONST // fixed color
} colorGen_t;
typedef enum {
TCGEN_BAD,
TCGEN_IDENTITY, // clear to 0,0
TCGEN_LIGHTMAP,
TCGEN_TEXTURE,
TCGEN_ENVIRONMENT_MAPPED,
TCGEN_FOG,
TCGEN_VECTOR // S and T from world coordinates
} texCoordGen_t;
typedef enum {
ACFF_NONE,
ACFF_MODULATE_RGB,
ACFF_MODULATE_RGBA,
ACFF_MODULATE_ALPHA
} acff_t;
typedef struct {
genFunc_t func;
float base;
float amplitude;
float phase;
float frequency;
} waveForm_t;
#define TR_MAX_TEXMODS 4
typedef enum {
TMOD_NONE,
TMOD_TRANSFORM,
TMOD_TURBULENT,
TMOD_SCROLL,
TMOD_SCALE,
TMOD_STRETCH,
TMOD_ROTATE,
TMOD_ENTITY_TRANSLATE
} texMod_t;
#define MAX_SHADER_DEFORMS 3
typedef struct {
deform_t deformation; // vertex coordinate modification type
vec3_t moveVector;
waveForm_t deformationWave;
float deformationSpread;
float bulgeWidth;
float bulgeHeight;
float bulgeSpeed;
} deformStage_t;
typedef struct {
texMod_t type;
// used for TMOD_TURBULENT and TMOD_STRETCH
waveForm_t wave;
// used for TMOD_TRANSFORM
float matrix[2][2]; // s' = s * m[0][0] + t * m[1][0] + trans[0]
float translate[2]; // t' = s * m[0][1] + t * m[0][1] + trans[1]
// used for TMOD_SCALE
float scale[2]; // s *= scale[0]
// t *= scale[1]
// used for TMOD_SCROLL
float scroll[2]; // s' = s + scroll[0] * time
// t' = t + scroll[1] * time
// + = clockwise
// - = counterclockwise
float rotateSpeed;
} texModInfo_t;
#define MAX_IMAGE_ANIMATIONS 8
typedef struct {
image_t *image[MAX_IMAGE_ANIMATIONS];
int numImageAnimations;
float imageAnimationSpeed;
texCoordGen_t tcGen;
vec3_t tcGenVectors[2];
int numTexMods;
texModInfo_t *texMods;
int videoMapHandle;
qboolean isLightmap;
qboolean isVideoMap;
} textureBundle_t;
enum
{
TB_COLORMAP = 0,
TB_DIFFUSEMAP = 0,
TB_LIGHTMAP = 1,
TB_LEVELSMAP = 1,
TB_SHADOWMAP3 = 1,
TB_NORMALMAP = 2,
TB_DELUXEMAP = 3,
TB_SHADOWMAP2 = 3,
TB_SPECULARMAP = 4,
TB_SHADOWMAP = 5,
TB_CUBEMAP = 6,
TB_SHADOWMAP4 = 6,
NUM_TEXTURE_BUNDLES = 7
};
typedef enum
{
// material shader stage types
ST_COLORMAP = 0, // vanilla Q3A style shader treatening
ST_DIFFUSEMAP = 0, // treat color and diffusemap the same
ST_NORMALMAP,
ST_NORMALPARALLAXMAP,
ST_SPECULARMAP,
ST_GLSL
} stageType_t;
typedef struct {
qboolean active;
textureBundle_t bundle[NUM_TEXTURE_BUNDLES];
waveForm_t rgbWave;
colorGen_t rgbGen;
waveForm_t alphaWave;
alphaGen_t alphaGen;
byte constantColor[4]; // for CGEN_CONST and AGEN_CONST
unsigned stateBits; // GLS_xxxx mask
acff_t adjustColorsForFog;
qboolean isDetail;
stageType_t type;
struct shaderProgram_s *glslShaderGroup;
int glslShaderIndex;
vec4_t normalScale;
vec4_t specularScale;
} shaderStage_t;
struct shaderCommands_s;
typedef enum {
CT_FRONT_SIDED,
CT_BACK_SIDED,
CT_TWO_SIDED
} cullType_t;
typedef enum {
FP_NONE, // surface is translucent and will just be adjusted properly
FP_EQUAL, // surface is opaque but possibly alpha tested
FP_LE // surface is trnaslucent, but still needs a fog pass (fog surface)
} fogPass_t;
typedef struct {
float cloudHeight;
image_t *outerbox[6], *innerbox[6];
} skyParms_t;
typedef struct {
vec3_t color;
float depthForOpaque;
} fogParms_t;
typedef struct shader_s {
char name[MAX_QPATH]; // game path, including extension
int lightmapIndex; // for a shader to match, both name and lightmapIndex must match
int index; // this shader == tr.shaders[index]
int sortedIndex; // this shader == tr.sortedShaders[sortedIndex]
float sort; // lower numbered shaders draw before higher numbered
qboolean defaultShader; // we want to return index 0 if the shader failed to
// load for some reason, but R_FindShader should
// still keep a name allocated for it, so if
// something calls RE_RegisterShader again with
// the same name, we don't try looking for it again
qboolean explicitlyDefined; // found in a .shader file
int surfaceFlags; // if explicitlyDefined, this will have SURF_* flags
int contentFlags;
qboolean entityMergable; // merge across entites optimizable (smoke, blood)
qboolean isSky;
skyParms_t sky;
fogParms_t fogParms;
float portalRange; // distance to fog out at
qboolean isPortal;
int multitextureEnv; // 0, GL_MODULATE, GL_ADD (FIXME: put in stage)
cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED
qboolean polygonOffset; // set for decals and other items that must be offset
qboolean noMipMaps; // for console fonts, 2D elements, etc.
qboolean noPicMip; // for images that must always be full resolution
fogPass_t fogPass; // draw a blended pass, possibly with depth test equals
int vertexAttribs; // not all shaders will need all data to be gathered
int numDeforms;
deformStage_t deforms[MAX_SHADER_DEFORMS];
int numUnfoggedPasses;
shaderStage_t *stages[MAX_SHADER_STAGES];
void (*optimalStageIteratorFunc)( void );
float clampTime; // time this shader is clamped to
float timeOffset; // current time offset for this shader
struct shader_s *remappedShader; // current shader this one is remapped too
struct shader_s *next;
} shader_t;
static ID_INLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader)
{
if(shader->numDeforms)
{
const deformStage_t *ds = &shader->deforms[0];
if (shader->numDeforms > 1)
return qtrue;
switch (ds->deformation)
{
case DEFORM_WAVE:
case DEFORM_BULGE:
return qfalse;
default:
return qtrue;
}
}
return qfalse;
}
enum
{
ATTR_INDEX_POSITION = 0,
ATTR_INDEX_TEXCOORD = 1,
ATTR_INDEX_LIGHTCOORD = 2,
ATTR_INDEX_TANGENT = 3,
ATTR_INDEX_NORMAL = 4,
ATTR_INDEX_COLOR = 5,
ATTR_INDEX_PAINTCOLOR = 6,
ATTR_INDEX_LIGHTDIRECTION = 7,
ATTR_INDEX_BONE_INDEXES = 8,
ATTR_INDEX_BONE_WEIGHTS = 9,
// GPU vertex animations
ATTR_INDEX_POSITION2 = 10,
ATTR_INDEX_TANGENT2 = 11,
ATTR_INDEX_NORMAL2 = 12,
ATTR_INDEX_COUNT = 13
};
enum
{
ATTR_POSITION = 1 << ATTR_INDEX_POSITION,
ATTR_TEXCOORD = 1 << ATTR_INDEX_TEXCOORD,
ATTR_LIGHTCOORD = 1 << ATTR_INDEX_LIGHTCOORD,
ATTR_TANGENT = 1 << ATTR_INDEX_TANGENT,
ATTR_NORMAL = 1 << ATTR_INDEX_NORMAL,
ATTR_COLOR = 1 << ATTR_INDEX_COLOR,
ATTR_PAINTCOLOR = 1 << ATTR_INDEX_PAINTCOLOR,
ATTR_LIGHTDIRECTION = 1 << ATTR_INDEX_LIGHTDIRECTION,
ATTR_BONE_INDEXES = 1 << ATTR_INDEX_BONE_INDEXES,
ATTR_BONE_WEIGHTS = 1 << ATTR_INDEX_BONE_WEIGHTS,
// for .md3 interpolation
ATTR_POSITION2 = 1 << ATTR_INDEX_POSITION2,
ATTR_TANGENT2 = 1 << ATTR_INDEX_TANGENT2,
ATTR_NORMAL2 = 1 << ATTR_INDEX_NORMAL2,
ATTR_DEFAULT = ATTR_POSITION,
ATTR_BITS = ATTR_POSITION |
ATTR_TEXCOORD |
ATTR_LIGHTCOORD |
ATTR_TANGENT |
ATTR_NORMAL |
ATTR_COLOR |
ATTR_PAINTCOLOR |
ATTR_LIGHTDIRECTION |
ATTR_BONE_INDEXES |
ATTR_BONE_WEIGHTS |
ATTR_POSITION2 |
ATTR_TANGENT2 |
ATTR_NORMAL2
};
enum
{
GENERICDEF_USE_DEFORM_VERTEXES = 0x0001,
GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002,
GENERICDEF_USE_VERTEX_ANIMATION = 0x0004,
GENERICDEF_USE_FOG = 0x0008,
GENERICDEF_USE_RGBAGEN = 0x0010,
GENERICDEF_USE_LIGHTMAP = 0x0020,
GENERICDEF_ALL = 0x003F,
GENERICDEF_COUNT = 0x0040,
};
enum
{
FOGDEF_USE_DEFORM_VERTEXES = 0x0001,
FOGDEF_USE_VERTEX_ANIMATION = 0x0002,
FOGDEF_ALL = 0x0003,
FOGDEF_COUNT = 0x0004,
};
enum
{
DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001,
DLIGHTDEF_ALL = 0x0001,
DLIGHTDEF_COUNT = 0x0002,
};
enum
{
LIGHTDEF_USE_LIGHTMAP = 0x0001,
LIGHTDEF_USE_LIGHT_VECTOR = 0x0002,
LIGHTDEF_USE_LIGHT_VERTEX = 0x0003,
LIGHTDEF_LIGHTTYPE_MASK = 0x0003,
LIGHTDEF_ENTITY = 0x0004,
LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008,
LIGHTDEF_USE_PARALLAXMAP = 0x0010,
LIGHTDEF_USE_SHADOWMAP = 0x0020,
LIGHTDEF_ALL = 0x003F,
LIGHTDEF_COUNT = 0x0040
};
enum
{
GLSL_INT,
GLSL_FLOAT,
GLSL_FLOAT5,
GLSL_VEC2,
GLSL_VEC3,
GLSL_VEC4,
GLSL_MAT16
};
typedef enum
{
UNIFORM_DIFFUSEMAP = 0,
UNIFORM_LIGHTMAP,
UNIFORM_NORMALMAP,
UNIFORM_DELUXEMAP,
UNIFORM_SPECULARMAP,
UNIFORM_TEXTUREMAP,
UNIFORM_LEVELSMAP,
UNIFORM_CUBEMAP,
UNIFORM_SCREENIMAGEMAP,
UNIFORM_SCREENDEPTHMAP,
UNIFORM_SHADOWMAP,
UNIFORM_SHADOWMAP2,
UNIFORM_SHADOWMAP3,
UNIFORM_SHADOWMAP4,
UNIFORM_SHADOWMVP,
UNIFORM_SHADOWMVP2,
UNIFORM_SHADOWMVP3,
UNIFORM_SHADOWMVP4,
UNIFORM_ENABLETEXTURES,
UNIFORM_DIFFUSETEXMATRIX,
UNIFORM_DIFFUSETEXOFFTURB,
UNIFORM_TEXTURE1ENV,
UNIFORM_TCGEN0,
UNIFORM_TCGEN0VECTOR0,
UNIFORM_TCGEN0VECTOR1,
UNIFORM_DEFORMGEN,
UNIFORM_DEFORMPARAMS,
UNIFORM_COLORGEN,
UNIFORM_ALPHAGEN,
UNIFORM_COLOR,
UNIFORM_BASECOLOR,
UNIFORM_VERTCOLOR,
UNIFORM_DLIGHTINFO,
UNIFORM_LIGHTFORWARD,
UNIFORM_LIGHTUP,
UNIFORM_LIGHTRIGHT,
UNIFORM_LIGHTORIGIN,
UNIFORM_MODELLIGHTDIR,
UNIFORM_LIGHTRADIUS,
UNIFORM_AMBIENTLIGHT,
UNIFORM_DIRECTEDLIGHT,
UNIFORM_PORTALRANGE,
UNIFORM_FOGDISTANCE,
UNIFORM_FOGDEPTH,
UNIFORM_FOGEYET,
UNIFORM_FOGCOLORMASK,
UNIFORM_MODELMATRIX,
UNIFORM_MODELVIEWPROJECTIONMATRIX,
UNIFORM_TIME,
UNIFORM_VERTEXLERP,
UNIFORM_NORMALSCALE,
UNIFORM_SPECULARSCALE,
UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2
UNIFORM_VIEWORIGIN,
UNIFORM_LOCALVIEWORIGIN,
UNIFORM_VIEWFORWARD,
UNIFORM_VIEWLEFT,
UNIFORM_VIEWUP,
UNIFORM_INVTEXRES,
UNIFORM_AUTOEXPOSUREMINMAX,
UNIFORM_TONEMINAVGMAXLINEAR,
UNIFORM_PRIMARYLIGHTORIGIN,
UNIFORM_PRIMARYLIGHTCOLOR,
UNIFORM_PRIMARYLIGHTAMBIENT,
UNIFORM_PRIMARYLIGHTRADIUS,
UNIFORM_CUBEMAPINFO,
UNIFORM_COUNT
} uniform_t;
// shaderProgram_t represents a pair of one
// GLSL vertex and one GLSL fragment shader
typedef struct shaderProgram_s
{
char name[MAX_QPATH];
GLhandleARB program;
GLhandleARB vertexShader;
GLhandleARB fragmentShader;
uint32_t attribs; // vertex array attributes
// uniform parameters
GLint uniforms[UNIFORM_COUNT];
short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms
char *uniformBuffer;
} shaderProgram_t;
// trRefdef_t holds everything that comes in refdef_t,
// as well as the locally generated scene information
typedef struct {
int x, y, width, height;
float fov_x, fov_y;
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
stereoFrame_t stereoFrame;
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc
// 1 bits will prevent the associated area from rendering at all
byte areamask[MAX_MAP_AREA_BYTES];
qboolean areamaskModified; // qtrue if areamask changed since last scene
float floatTime; // tr.refdef.time / 1000.0
float blurFactor;
// text messages for deform text shaders
char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH];
int num_entities;
trRefEntity_t *entities;
int num_dlights;
struct dlight_s *dlights;
int numPolys;
struct srfPoly_s *polys;
int numDrawSurfs;
struct drawSurf_s *drawSurfs;
unsigned int dlightMask;
int num_pshadows;
struct pshadow_s *pshadows;
float sunShadowMvp[4][16];
float sunDir[4];
float sunCol[4];
float sunAmbCol[4];
float colorScale;
float autoExposureMinMax[2];
float toneMinAvgMaxLinear[3];
} trRefdef_t;
//=================================================================================
// skins allow models to be retextured without modifying the model file
typedef struct {
char name[MAX_QPATH];
shader_t *shader;
} skinSurface_t;
typedef struct skin_s {
char name[MAX_QPATH]; // game path, including extension
int numSurfaces;
skinSurface_t *surfaces[MD3_MAX_SURFACES];
} skin_t;
typedef struct {
int originalBrushNumber;
vec3_t bounds[2];
unsigned colorInt; // in packed byte format
float tcScale; // texture coordinate vector scales
fogParms_t parms;
// for clipping distance in fog when outside
qboolean hasSurface;
float surface[4];
} fog_t;
typedef enum {
VPF_NONE = 0x00,
VPF_NOVIEWMODEL = 0x01,
VPF_SHADOWMAP = 0x02,
VPF_DEPTHSHADOW = 0x04,
VPF_DEPTHCLAMP = 0x08,
VPF_ORTHOGRAPHIC = 0x10,
VPF_USESUNLIGHT = 0x20,
VPF_FARPLANEFRUSTUM = 0x40,
VPF_NOCUBEMAPS = 0x80
} viewParmFlags_t;
typedef struct {
orientationr_t or;
orientationr_t world;
vec3_t pvsOrigin; // may be different than or.origin for portals
qboolean isPortal; // true if this view is through a portal
qboolean isMirror; // the portal is a mirror, invert the face culling
viewParmFlags_t flags;
int frameSceneNum; // copied from tr.frameSceneNum
int frameCount; // copied from tr.frameCount
cplane_t portalPlane; // clip anything behind this if mirroring
int viewportX, viewportY, viewportWidth, viewportHeight;
FBO_t *targetFbo;
int targetFboLayer;
int targetFboCubemapIndex;
float fovX, fovY;
float projectionMatrix[16];
cplane_t frustum[5];
vec3_t visBounds[2];
float zFar;
float zNear;
stereoFrame_t stereoFrame;
} viewParms_t;
/*
==============================================================================
SURFACES
==============================================================================
*/
typedef byte color4ub_t[4];
// any changes in surfaceType must be mirrored in rb_surfaceTable[]
typedef enum {
SF_BAD,
SF_SKIP, // ignore
SF_FACE,
SF_GRID,
SF_TRIANGLES,
SF_POLY,
SF_MDV,
SF_MDR,
SF_IQM,
SF_FLARE,
SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity
SF_DISPLAY_LIST,
SF_VAO_MESH,
SF_VAO_MDVMESH,
SF_NUM_SURFACE_TYPES,
SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int )
} surfaceType_t;
typedef struct drawSurf_s {
unsigned int sort; // bit combination for fast compares
int cubemapIndex;
surfaceType_t *surface; // any of surface*_t
} drawSurf_t;
#define MAX_FACE_POINTS 64
#define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file
#define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory
// when cgame directly specifies a polygon, it becomes a srfPoly_t
// as soon as it is called
typedef struct srfPoly_s {
surfaceType_t surfaceType;
qhandle_t hShader;
int fogIndex;
int numVerts;
polyVert_t *verts;
} srfPoly_t;
typedef struct srfDisplayList_s {
surfaceType_t surfaceType;
int listNum;
} srfDisplayList_t;
typedef struct srfFlare_s {
surfaceType_t surfaceType;
vec3_t origin;
vec3_t normal;
vec3_t color;
} srfFlare_t;
typedef struct
{
vec3_t xyz;
vec2_t st;
vec2_t lightmap;
vec3_t normal;
#ifdef USE_VERT_TANGENT_SPACE
vec4_t tangent;
#endif
vec3_t lightdir;
vec4_t vertexColors;
#if DEBUG_OPTIMIZEVERTICES
unsigned int id;
#endif
} srfVert_t;
#ifdef USE_VERT_TANGENT_SPACE
#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}}
#else
#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}}
#endif
// srfBspSurface_t covers SF_GRID, SF_TRIANGLES, SF_POLY, and SF_VAO_MESH
typedef struct srfBspSurface_s
{
surfaceType_t surfaceType;
// dynamic lighting information
int dlightBits;
int pshadowBits;
// culling information
vec3_t cullBounds[2];
vec3_t cullOrigin;
float cullRadius;
cplane_t cullPlane;
// indexes
int numIndexes;
glIndex_t *indexes;
// vertexes
int numVerts;
srfVert_t *verts;
// BSP VBO offsets
int firstVert;
int firstIndex;
glIndex_t minIndex;
glIndex_t maxIndex;
// static render data
vao_t *vao;
// SF_GRID specific variables after here
// lod information, which may be different
// than the culling information to allow for
// groups of curves that LOD as a unit
vec3_t lodOrigin;
float lodRadius;
int lodFixed;
int lodStitched;
// vertexes
int width, height;
float *widthLodError;
float *heightLodError;
} srfBspSurface_t;
// inter-quake-model
typedef struct {
int num_vertexes;
int num_triangles;
int num_frames;
int num_surfaces;
int num_joints;
int num_poses;
struct srfIQModel_s *surfaces;
float *positions;
float *texcoords;
float *normals;
float *tangents;
byte *blendIndexes;
union {
float *f;
byte *b;
} blendWeights;
byte *colors;
int *triangles;
// depending upon the exporter, blend indices and weights might be int/float
// as opposed to the recommended byte/byte, for example Noesis exports
// int/float whereas the official IQM tool exports byte/byte
byte blendWeightsType; // IQM_UBYTE or IQM_FLOAT
int *jointParents;
float *jointMats;
float *poseMats;
float *bounds;
char *names;