header file for renderva

master
Daniel Kolesa 2020-05-01 22:06:23 +02:00
parent 949ec16cd7
commit 26ce5f8423
16 changed files with 123 additions and 91 deletions

View File

@ -1,4 +1,5 @@
#include "blend.hh"
#include "renderva.hh"
#include "texture.hh"
#include "engine.hh"

View File

@ -25,7 +25,6 @@ extern int blendpaintmode;
void stoppaintblendmap();
void trypaintblendmap();
void renderblendbrush(GLuint tex, float x, float y, float w, float h);
void renderblendbrush();
bool loadblendmap(stream *f, int info);

View File

@ -1,3 +1,5 @@
#include "renderva.hh"
#include "engine.hh"
VARNP(dynlights, usedynlights, 0, 1, 1);

View File

@ -243,9 +243,6 @@ enum { SM_NONE = 0, SM_REFLECT, SM_CUBEMAP, SM_CASCADE, SM_SPOT };
extern int shadowmapping;
extern vec shadoworigin, shadowdir;
extern float shadowradius, shadowbias;
extern int shadowside, shadowspot;
extern matrix4 shadowmatrix;
extern void loaddeferredlightshaders();
@ -255,25 +252,14 @@ extern void clearshadowcache();
extern void rendervolumetric();
extern void cleanupvolumetric();
extern void findshadowvas();
extern void findshadowmms();
extern int calcshadowinfo(const extentity &e, vec &origin, float &radius, vec &spotloc, int &spotangle, float &bias);
extern int dynamicshadowvabounds(int mask, vec &bbmin, vec &bbmax);
extern void rendershadowmapworld();
extern void batchshadowmapmodels(bool skipmesh = false);
extern void rendershadowatlas();
extern void renderrsmgeom(bool dyntex = false);
extern bool useradiancehints();
extern void renderradiancehints();
extern void clearradiancehintscache();
extern void cleanuplights();
extern void workinoq();
extern int calcbbsidemask(const vec &bbmin, const vec &bbmax, const vec &lightpos, float lightradius, float bias);
extern int calcspheresidemask(const vec &p, float radius, float bias);
extern int calctrisidemask(const vec &p1, const vec &p2, const vec &p3, float bias);
extern int cullfrustumsides(const vec &lightpos, float lightradius, float size, float border);
extern int calcbbcsmsplits(const ivec &bbmin, const ivec &bbmax);
extern int calcspherecsmsplits(const vec &center, float radius);
extern int calcbbrsmsplits(const ivec &bbmin, const ivec &bbmax);
@ -361,50 +347,6 @@ extern void destroyva(vtxarray *va, bool reparent = true);
extern void updatevabb(vtxarray *va, bool force = false);
extern void updatevabbs(bool force = false);
// renderva
extern int oqfrags;
extern float alphafrontsx1, alphafrontsx2, alphafrontsy1, alphafrontsy2, alphabacksx1, alphabacksx2, alphabacksy1, alphabacksy2, alpharefractsx1, alpharefractsx2, alpharefractsy1, alpharefractsy2;
extern uint alphatiles[LIGHTTILE_MAXH];
extern vtxarray *visibleva;
extern void visiblecubes(bool cull = true);
extern void setvfcP(const vec &bbmin = vec(-1, -1, -1), const vec &bbmax = vec(1, 1, 1));
extern void savevfcP();
extern void restorevfcP();
extern void rendergeom();
extern int findalphavas();
extern void renderrefractmask();
extern void renderalphageom(int side);
extern void rendermapmodels();
extern void renderoutline();
extern void cleanupva();
extern bool isfoggedsphere(float rad, const vec &cv);
extern int isvisiblesphere(float rad, const vec &cv);
extern int isvisiblebb(const ivec &bo, const ivec &br);
extern bool bboccluded(const ivec &bo, const ivec &br);
extern int deferquery;
extern void flipqueries();
extern occludequery *newquery(void *owner);
extern void startquery(occludequery *query);
extern void endquery(occludequery *query);
extern bool checkquery(occludequery *query, bool nowait = false);
extern void resetqueries();
extern int getnumqueries();
extern void startbb(bool mask = true);
extern void endbb(bool mask = true);
extern void drawbb(const ivec &bo, const ivec &br);
extern void renderdecals();
struct shadowmesh;
extern void clearshadowmeshes();
extern void genshadowmeshes();
extern shadowmesh *findshadowmesh(int idx, extentity &e);
extern void rendershadowmesh(shadowmesh *m);
// dynlight
extern void updatedynlights();
@ -564,7 +506,6 @@ extern int skytexture, skyshadow, explicitsky;
extern void drawskybox(bool clear = false);
extern bool hasskybox();
extern bool limitsky();
extern bool renderexplicitsky(bool outline = false);
extern void cleanupsky();
// menus

View File

@ -1,4 +1,5 @@
#include "blend.hh"
#include "renderva.hh"
#include "texture.hh"
#include "engine.hh"

View File

@ -1,6 +1,7 @@
// main.cpp: initialisation & main loop
#include "blend.hh"
#include "renderva.hh"
#include "shader.hh"
#include "texture.hh"
#include "world.hh"

View File

@ -1,4 +1,5 @@
#include "material.hh"
#include "renderva.hh"
#include "texture.hh"
#include "water.hh"

View File

@ -1,5 +1,6 @@
#include "blend.hh"
#include "material.hh"
#include "renderva.hh"
#include "texture.hh"
#include "world.hh"

View File

@ -2,6 +2,7 @@
#include "blend.hh"
#include "material.hh"
#include "renderva.hh"
#include "texture.hh"
#include "world.hh"

View File

@ -3,6 +3,7 @@
#include "aa.hh"
#include "blend.hh"
#include "material.hh"
#include "renderva.hh"
#include "texture.hh"
#include "water.hh"

View File

@ -2,6 +2,7 @@
#include "aa.hh"
#include "material.hh"
#include "renderva.hh"
#include "texture.hh"
#include "world.hh"

View File

@ -1,4 +1,5 @@
#include "aa.hh"
#include "renderva.hh"
#include "shader.hh"
#include "texture.hh"

View File

@ -1,5 +1,6 @@
// renderparticles.cpp
#include "renderva.hh"
#include "shader.hh"
#include "texture.hh"
#include "water.hh"

View File

@ -1,3 +1,4 @@
#include "renderva.hh"
#include "texture.hh"
#include "engine.hh"

View File

@ -1,5 +1,7 @@
// renderva.cpp: handles the occlusion and rendering of vertex arrays
#include "renderva.hh"
#include "blend.hh"
#include "texture.hh"
@ -23,9 +25,9 @@ static inline void drawvaskytris(vtxarray *va)
///////// view frustrum culling ///////////////////////
plane vfcP[5]; // perpindictular vectors to view frustrum bounding planes
float vfcDfog; // far plane culling distance (fog limit).
float vfcDnear[5], vfcDfar[5];
static plane vfcP[5]; // perpindictular vectors to view frustrum bounding planes
static float vfcDfog; // far plane culling distance (fog limit).
static float vfcDnear[5], vfcDfar[5];
vtxarray *visibleva = NULL;
@ -68,7 +70,7 @@ static inline int isfoggedcube(const ivec &o, int size)
return dist < -vfcDfar[4]*size || dist > vfcDfog - vfcDnear[4]*size;
}
int isvisiblecube(const ivec &o, int size)
static int isvisiblecube(const ivec &o, int size)
{
int v = VFC_FULL_VISIBLE;
float dist;
@ -136,7 +138,7 @@ static inline void addvisibleva(vtxarray *va)
*prev = va;
}
void sortvisiblevas()
static void sortvisiblevas()
{
visibleva = NULL;
vtxarray **last = &visibleva;
@ -185,14 +187,14 @@ static inline void findvisiblevas(vector<vtxarray *> &vas)
}
}
void findvisiblevas()
static void findvisiblevas()
{
memset(vasort, 0, sizeof(vasort));
findvisiblevas<false, false>(varoot);
sortvisiblevas();
}
void calcvfcD()
static void calcvfcD()
{
loopi(5)
{
@ -203,7 +205,7 @@ void calcvfcD()
}
}
void setvfcP(const vec &bbmin, const vec &bbmax)
static void setvfcP(const vec &bbmin = vec(-1, -1, -1), const vec &bbmax = vec(1, 1, 1))
{
vec4 px = camprojmatrix.rowx(), py = camprojmatrix.rowy(), pz = camprojmatrix.rowz(), pw = camprojmatrix.roww();
vfcP[0] = plane(vec4(pw).mul(-bbmin.x).add(px)).normalize(); // left plane
@ -216,18 +218,20 @@ void setvfcP(const vec &bbmin, const vec &bbmax)
calcvfcD();
}
plane oldvfcP[5];
static plane oldvfcP[5];
void savevfcP()
#if 0
static void savevfcP()
{
memcpy(oldvfcP, vfcP, sizeof(vfcP));
}
void restorevfcP()
static void restorevfcP()
{
memcpy(vfcP, oldvfcP, sizeof(vfcP));
calcvfcD();
}
#endif
void visiblecubes(bool cull)
{
@ -337,7 +341,7 @@ void resetqueries()
loopi(MAXQUERYFRAMES) queryframes[i].reset();
}
void clearqueries()
static void clearqueries()
{
loopi(MAXQUERYFRAMES) queryframes[i].cleanup();
}
@ -460,7 +464,7 @@ extern int octaentsize;
static octaentities *visiblemms, **lastvisiblemms;
void findvisiblemms(const vector<extentity *> &ents, bool doquery)
static void findvisiblemms(const vector<extentity *> &ents, bool doquery)
{
visiblemms = NULL;
lastvisiblemms = &visiblemms;
@ -714,7 +718,7 @@ void renderblendbrush(GLuint tex, float x, float y, float w, float h)
gle::disablevertex();
}
int calcbbsidemask(const ivec &bbmin, const ivec &bbmax, const vec &lightpos, float lightradius, float bias)
static int calcbbsidemask(const ivec &bbmin, const ivec &bbmax, const vec &lightpos, float lightradius, float bias)
{
vec pmin = vec(bbmin).sub(lightpos).div(lightradius), pmax = vec(bbmax).sub(lightpos).div(lightradius);
int mask = 0x3F;
@ -772,7 +776,7 @@ int calcspheresidemask(const vec &p, float radius, float bias)
return mask;
}
int calctrisidemask(const vec &p1, const vec &p2, const vec &p3, float bias)
static int calctrisidemask(const vec &p1, const vec &p2, const vec &p3, float bias)
{
// p1, p2, p3 are in the cubemap's local coordinate system
// bias = border/(size - border)
@ -889,7 +893,7 @@ vec shadoworigin(0, 0, 0), shadowdir(0, 0, 0);
float shadowradius = 0, shadowbias = 0;
int shadowside = 0, shadowspot = 0;
vtxarray *shadowva = NULL;
static vtxarray *shadowva = NULL;
static inline void addshadowva(vtxarray *va, float dist)
{
@ -908,7 +912,7 @@ static inline void addshadowva(vtxarray *va, float dist)
*prev = va;
}
void sortshadowvas()
static void sortshadowvas()
{
shadowva = NULL;
vtxarray **last = &shadowva;
@ -921,7 +925,7 @@ void sortshadowvas()
}
}
void findshadowvas(vector<vtxarray *> &vas)
static void findshadowvas(vector<vtxarray *> &vas)
{
loopv(vas)
{
@ -938,7 +942,7 @@ void findshadowvas(vector<vtxarray *> &vas)
}
}
void findcsmshadowvas(vector<vtxarray *> &vas)
static void findcsmshadowvas(vector<vtxarray *> &vas)
{
loopv(vas)
{
@ -956,7 +960,7 @@ void findcsmshadowvas(vector<vtxarray *> &vas)
}
}
void findrsmshadowvas(vector<vtxarray *> &vas)
static void findrsmshadowvas(vector<vtxarray *> &vas)
{
loopv(vas)
{
@ -974,7 +978,7 @@ void findrsmshadowvas(vector<vtxarray *> &vas)
}
}
void findspotshadowvas(vector<vtxarray *> &vas)
static void findspotshadowvas(vector<vtxarray *> &vas)
{
loopv(vas)
{
@ -1611,7 +1615,7 @@ static void renderbatches(renderstate &cur, int pass)
resetbatches();
}
void renderzpass(renderstate &cur, vtxarray *va)
static void renderzpass(renderstate &cur, vtxarray *va)
{
if(!cur.vattribs)
{
@ -1656,7 +1660,7 @@ void renderzpass(renderstate &cur, vtxarray *va)
VAR(batchgeom, 0, 1, 1);
void renderva(renderstate &cur, vtxarray *va, int pass = RENDERPASS_GBUFFER, bool doquery = false)
static void renderva(renderstate &cur, vtxarray *va, int pass = RENDERPASS_GBUFFER, bool doquery = false)
{
switch(pass)
{
@ -1708,14 +1712,14 @@ void cleanupva()
cleanupgrass();
}
void setupgeom(renderstate &cur)
static void setupgeom(renderstate &cur)
{
glActiveTexture_(GL_TEXTURE0);
GLOBALPARAMF(colorparams, 1, 1, 1, 1);
GLOBALPARAMF(blendlayer, 1.0f);
}
void cleanupgeom(renderstate &cur)
static void cleanupgeom(renderstate &cur)
{
if(cur.vattribs) disablevattribs(cur);
if(cur.vbuf) disablevbuf(cur);
@ -2366,7 +2370,7 @@ static void renderdecalbatches(decalrenderer &cur, int pass)
resetdecalbatches();
}
void setupdecals(decalrenderer &cur)
static void setupdecals(decalrenderer &cur)
{
gle::enablevertex();
gle::enablenormal();
@ -2380,7 +2384,7 @@ void setupdecals(decalrenderer &cur)
GLOBALPARAMF(colorparams, 1, 1, 1, 1);
}
void cleanupdecals(decalrenderer &cur)
static void cleanupdecals(decalrenderer &cur)
{
disablepolygonoffset(GL_POLYGON_OFFSET_FILL);
glDisable(GL_BLEND);
@ -2496,10 +2500,10 @@ struct shadowverts
return table[h] = verts.length()-1;
}
} shadowverts;
vector<ushort> shadowtris[6];
vector<GLuint> shadowvbos;
hashtable<int, shadowmesh> shadowmeshes;
vector<shadowdraw> shadowdraws;
static vector<ushort> shadowtris[6];
static vector<GLuint> shadowvbos;
static hashtable<int, shadowmesh> shadowmeshes;
static vector<shadowdraw> shadowdraws;
struct shadowdrawinfo
{

View File

@ -0,0 +1,75 @@
#ifndef ENGINE_RENDERVA_HH
#define ENGINE_RENDERVA_HH
#include <shared/geom.hh>
#include "octa.hh"
#include "renderlights.hh" /* LIGHTTILE_MAXH */
extern vtxarray *visibleva;
bool isfoggedsphere(float rad, const vec &cv);
int isvisiblesphere(float rad, const vec &cv);
int isvisiblebb(const ivec &bo, const ivec &br);
void visiblecubes(bool cull = true);
extern int deferquery;
int getnumqueries();
void flipqueries();
void resetqueries();
occludequery *newquery(void *owner);
void startquery(occludequery *query);
void endquery(occludequery *query);
bool checkquery(occludequery *query, bool nowait = false);
void startbb(bool mask = true);
void endbb(bool mask = true);
void drawbb(const ivec &bo, const ivec &br);
bool bboccluded(const ivec &bo, const ivec &br);
void rendermapmodels();
void renderoutline();
void renderblendbrush(GLuint tex, float x, float y, float w, float h);
int calcspheresidemask(const vec &p, float radius, float bias);
int cullfrustumsides(const vec &lightpos, float lightradius, float size, float border);
extern vec shadoworigin, shadowdir;
extern float shadowradius, shadowbias;
extern int shadowside, shadowspot;
extern void findshadowvas();
extern void findshadowmms();
int dynamicshadowvabounds(int mask, vec &bbmin, vec &bbmax);
void rendershadowmapworld();
void batchshadowmapmodels(bool skipmesh = false);
void renderrsmgeom(bool dyntex = false);
struct shadowmesh;
struct extentity; /* FIXME: remove */
void clearshadowmeshes();
void genshadowmeshes();
shadowmesh *findshadowmesh(int idx, extentity &e);
void rendershadowmesh(shadowmesh *m);
extern int oqfrags;
extern float alphafrontsx1, alphafrontsx2, alphafrontsy1, alphafrontsy2, alphabacksx1, alphabacksx2, alphabacksy1, alphabacksy2, alpharefractsx1, alpharefractsx2, alpharefractsy1, alpharefractsy2;
extern uint alphatiles[LIGHTTILE_MAXH];
int findalphavas();
void renderrefractmask();
void renderalphageom(int side);
bool renderexplicitsky(bool outline = false);
void renderdecals();
void cleanupva();
void rendergeom();
#endif