]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_shared.h
Don't set MATERIALFLAG_NOSHADOW on SKY materials. They need to cast shadows to preve...
[xonotic/darkplaces.git] / model_shared.h
index 1de925742ed811894eaabdf5d5b62da6be50c0b6..6184dc292e80fc2c626a2ed90b48989eae83dc3f 100644 (file)
@@ -68,7 +68,7 @@ typedef struct skinframe_s
        // mark and sweep garbage collection, this value is updated to a new value
        // on each level change for the used skinframes, if some are not used they
        // are freed
-       int loadsequence;
+       unsigned int loadsequence;
        // indicates whether this texture has transparent pixels
        qboolean hasalpha;
        // average texture color, if applicable
@@ -82,11 +82,6 @@ typedef struct skinframe_s
        qboolean qgeneratemerged;
        qboolean qgeneratenmap;
        qboolean qgenerateglow;
-       // for q2 wal files we have some extra info
-       int q2flags;
-       int q2value;
-       int q2contents;
-       // we could also store the q2animname from the wal but we have no current need of it
 }
 skinframe_t;
 
@@ -268,7 +263,7 @@ shadowmesh_t;
 #define TEXTURE_MAXFRAMES 64
 #define Q3WAVEPARMS 4
 #define Q3DEFORM_MAXPARMS 3
-#define Q3SHADER_MAXLAYERS 2 // FIXME support more than that (currently only two are used, so why keep more in RAM?)
+#define Q3SHADER_MAXLAYERS 8
 #define Q3RGBGEN_MAXPARMS 3
 #define Q3ALPHAGEN_MAXPARMS 1
 #define Q3TCGEN_MAXPARMS 6
@@ -456,7 +451,6 @@ typedef struct q3shaderinfo_s
        qboolean lighting;
        qboolean vertexalpha;
        qboolean textureblendalpha;
-       int primarylayer, backgroundlayer;
        q3shaderinfo_layer_t layers[Q3SHADER_MAXLAYERS];
        char skyboxname[Q3PATHLENGTH];
        q3shaderinfo_deform_t deforms[Q3MAXDEFORMS];
@@ -508,6 +502,20 @@ typedef struct q3shaderinfo_s
 }
 q3shaderinfo_t;
 
+typedef struct texture_shaderpass_s
+{
+       qboolean alphatest; // FIXME: handle alphafunc properly
+       float framerate;
+       int numframes;
+       skinframe_t *skinframes[TEXTURE_MAXFRAMES];
+       int blendfunc[2];
+       q3shaderinfo_layer_rgbgen_t rgbgen;
+       q3shaderinfo_layer_alphagen_t alphagen;
+       q3shaderinfo_layer_tcgen_t tcgen;
+       q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS];
+}
+texture_shaderpass_t;
+
 typedef enum texturelayertype_e
 {
        TEXTURELAYERTYPE_INVALID,
@@ -551,16 +559,10 @@ typedef struct texture_s
        float biaspolygonfactor;
        float biaspolygonoffset;
 
-       // textures to use when rendering this material
+       // textures to use when rendering this material (derived from materialshaderpass)
        skinframe_t *currentskinframe;
-       int numskinframes;
-       float skinframerate;
-       skinframe_t *skinframes[TEXTURE_MAXFRAMES];
-       // background layer (for terrain texture blending)
+       // textures to use for terrain texture blending (derived from backgroundshaderpass)
        skinframe_t *backgroundcurrentskinframe;
-       int backgroundnumskinframes;
-       float backgroundskinframerate;
-       skinframe_t *backgroundskinframes[TEXTURE_MAXFRAMES];
 
        // total frames in sequence and alternate sequence
        int anim_total[2];
@@ -583,12 +585,14 @@ typedef struct texture_s
        matrix4x4_t currentbackgroundtexmatrix;
 
        // various q3 shader features
-       q3shaderinfo_layer_rgbgen_t rgbgen;
-       q3shaderinfo_layer_alphagen_t alphagen;
-       q3shaderinfo_layer_tcgen_t tcgen;
-       q3shaderinfo_layer_tcmod_t tcmods[Q3MAXTCMODS];
-       q3shaderinfo_layer_tcmod_t backgroundtcmods[Q3MAXTCMODS];
        q3shaderinfo_deform_t deforms[Q3MAXDEFORMS];
+       texture_shaderpass_t *shaderpasses[Q3SHADER_MAXLAYERS]; // all shader passes in one array
+       texture_shaderpass_t *materialshaderpass; // equal to one of shaderpasses[] or NULL
+       texture_shaderpass_t *backgroundshaderpass; // equal to one of shaderpasses[] or NULL
+       unsigned char startpreshaderpass; // range within shaderpasses[]
+       unsigned char endpreshaderpass; // number of preshaderpasses
+       unsigned char startpostshaderpass; // range within shaderpasses[]
+       unsigned char endpostshaderpass; // number of postshaderpasses
 
        qboolean colormapping;
        rtexture_t *basetexture; // original texture without pants/shirt/glow
@@ -632,6 +636,10 @@ typedef struct texture_s
        int q2value;
        int q2contents;
 
+       // q1qsp
+       /// this points to a variant of the sky texture that has MATERIALFLAG_NOSHADOW, for the e1m5 logo shadow trick.
+       struct texture_s *skynoshadowtexture;
+
        // reflection
        float reflectmin; // when refraction is used, minimum amount of reflection (when looking straight down)
        float reflectmax; // when refraction is used, maximum amount of reflection (when looking parallel to water)
@@ -767,6 +775,10 @@ typedef struct model_brush_s
        qboolean isbsp2;
        // true if this model is a Quake2 .bsp file (IBSP38)
        qboolean isq2bsp;
+       // true if this model is a Quake3 .bsp file (IBSP46)
+       qboolean isq3bsp;
+       // true if this model is a Quake1/Quake2 .bsp file where skymasking capability exists
+       qboolean skymasking;
        // string of entity definitions (.map format)
        char *entities;
 
@@ -1068,16 +1080,16 @@ typedef struct model_s
        // draw the lighting on a model (through stencil)
        void(*DrawLight)(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
        // trace a box against this model
-       void (*TraceBox)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask);
-       void (*TraceBrush)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask);
+       void (*TraceBox)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask);
+       void (*TraceBrush)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask, int skipsupercontentsmask);
        // trace a box against this model
-       void (*TraceLine)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
+       void (*TraceLine)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask);
        // trace a point against this model (like PointSuperContents)
-       void (*TracePoint)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
+       void (*TracePoint)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask);
        // find the supercontents value at a point in this model
        int (*PointSuperContents)(struct model_s *model, int frame, const vec3_t point);
        // trace a line against geometry in this model and report correct texture (used by r_shadow_bouncegrid)
-       void (*TraceLineAgainstSurfaces)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
+       void (*TraceLineAgainstSurfaces)(struct model_s *model, const struct frameblend_s *frameblend, const struct skeleton_s *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask);
        // fields belonging to some types of model
        model_sprite_t  sprite;
        model_brush_t   brush;
@@ -1147,6 +1159,8 @@ void Mod_FreeQ3Shaders(void);
 void Mod_LoadQ3Shaders(void);
 q3shaderinfo_t *Mod_LookupQ3Shader(const char *name);
 qboolean Mod_LoadTextureFromQ3Shader(texture_t *texture, const char *name, qboolean warnmissing, qboolean fallback, int defaulttexflags);
+texture_shaderpass_t *Mod_CreateShaderPass(skinframe_t *skinframe);
+texture_shaderpass_t *Mod_CreateShaderPassFromQ3ShaderLayer(q3shaderinfo_layer_t *layer, int layerindex, int texflags, const char *texturename);
 
 extern cvar_t r_mipskins;
 extern cvar_t r_mipnormalmaps;
@@ -1191,7 +1205,7 @@ typedef struct mod_alloclightmap_state_s
 }
 mod_alloclightmap_state_t;
 
-void Mod_AllocLightmap_Init(mod_alloclightmap_state_t *state, int width, int height);
+void Mod_AllocLightmap_Init(mod_alloclightmap_state_t *state, mempool_t *mempool, int width, int height);
 void Mod_AllocLightmap_Free(mod_alloclightmap_state_t *state);
 void Mod_AllocLightmap_Reset(mod_alloclightmap_state_t *state);
 qboolean Mod_AllocLightmap_Block(mod_alloclightmap_state_t *state, int blockwidth, int blockheight, int *outx, int *outy);
@@ -1221,11 +1235,11 @@ void R_Q1BSP_DrawShadowVolume(struct entity_render_s *ent, const vec3_t relative
 void R_Q1BSP_DrawLight(struct entity_render_s *ent, int numsurfaces, const int *surfacelist, const unsigned char *trispvs);
 
 // Collision optimization using Bounding Interval Hierarchy
-void Mod_CollisionBIH_TracePoint(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
-void Mod_CollisionBIH_TraceLine(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask);
-void Mod_CollisionBIH_TraceBox(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask);
-void Mod_CollisionBIH_TraceBrush(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask);
-void Mod_CollisionBIH_TracePoint_Mesh(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask);
+void Mod_CollisionBIH_TracePoint(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask);
+void Mod_CollisionBIH_TraceLine(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask);
+void Mod_CollisionBIH_TraceBox(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, const vec3_t boxmins, const vec3_t boxmaxs, const vec3_t end, int hitsupercontentsmask, int skipsupercontentsmask);
+void Mod_CollisionBIH_TraceBrush(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, struct colbrushf_s *start, struct colbrushf_s *end, int hitsupercontentsmask, int skipsupercontentsmask);
+void Mod_CollisionBIH_TracePoint_Mesh(dp_model_t *model, const struct frameblend_s *frameblend, const skeleton_t *skeleton, struct trace_s *trace, const vec3_t start, int hitsupercontentsmask, int skipsupercontentsmask);
 qboolean Mod_CollisionBIH_TraceLineOfSight(struct model_s *model, const vec3_t start, const vec3_t end);
 int Mod_CollisionBIH_PointSuperContents(struct model_s *model, int frame, const vec3_t point);
 int Mod_CollisionBIH_PointSuperContents_Mesh(struct model_s *model, int frame, const vec3_t point);