#ifndef ENGINE_RENDERLIGHTS_HH #define ENGINE_RENDERLIGHTS_HH #include #include #include #include "aa.hh" #define LIGHTTILE_MAXW 16 #define LIGHTTILE_MAXH 16 enum { L_NOSHADOW = 1<<0, L_NODYNSHADOW = 1<<1, L_VOLUMETRIC = 1<<2, L_NOSPEC = 1<<3, L_SMALPHA = 1<<4 }; /* only for the inlines below */ extern int lighttilealignw, lighttilealignh, lighttilevieww, lighttileviewh, lighttilew, lighttileh; extern int vieww, viewh; /* rendergl */ template static inline void calctilebounds(float sx1, float sy1, float sx2, float sy2, T &bx1, T &by1, T &bx2, T &by2) { int tx1 = max(int(floor(((sx1 + 1)*0.5f*vieww)/lighttilealignw)), 0), ty1 = max(int(floor(((sy1 + 1)*0.5f*viewh)/lighttilealignh)), 0), tx2 = min(int(ceil(((sx2 + 1)*0.5f*vieww)/lighttilealignw)), lighttilevieww), ty2 = min(int(ceil(((sy2 + 1)*0.5f*viewh)/lighttilealignh)), lighttileviewh); bx1 = T((tx1 * lighttilew) / lighttilevieww); by1 = T((ty1 * lighttileh) / lighttileviewh); bx2 = T((tx2 * lighttilew + lighttilevieww - 1) / lighttilevieww); by2 = T((ty2 * lighttileh + lighttileviewh - 1) / lighttileviewh); } static inline void masktiles(uint *tiles, float sx1, float sy1, float sx2, float sy2) { int tx1, ty1, tx2, ty2; calctilebounds(sx1, sy1, sx2, sy2, tx1, ty1, tx2, ty2); for(int ty = ty1; ty < ty2; ty++) tiles[ty] |= ((1<<(tx2-tx1))-1)< msaapositions; int calcshadowinfo(const extentity &e, vec &origin, float &radius, vec &spotloc, int &spotangle, float &bias); void rendershadowatlas(); bool useradiancehints(); void renderradiancehints(); void clearradiancehintscache(); void cleanuplights(); void workinoq(); int calcbbcsmsplits(const ivec &bbmin, const ivec &bbmax); int calcspherecsmsplits(const vec ¢er, float radius); int calcbbrsmsplits(const ivec &bbmin, const ivec &bbmax); int calcspherersmsplits(const vec ¢er, float radius); void cleanupgbuffer(); void initgbuffer(); bool usepacknorm(); void maskgbuffer(const char *mask); void bindgdepth(); void preparegbuffer(bool depthclear = true); void rendergbuffer(bool depthclear = true); void shadesky(); void shadegbuffer(); void shademinimap(const vec &color = vec(-1, -1, -1)); void shademodelpreview(int x, int y, int w, int h, bool background = true, bool scissor = false); void rendertransparent(); void renderao(); void loadhdrshaders(int aa = AA_UNUSED); void processhdr(GLuint outfbo = 0, int aa = AA_UNUSED); void copyhdr(int sw, int sh, GLuint fbo, int dw = 0, int dh = 0, bool flipx = false, bool flipy = false, bool swapxy = false); void setuplights(); void setupgbuffer(); GLuint shouldscale(); void doscale(GLuint outfbo = 0); bool debuglights(); extern int avatarmask; bool useavatarmask(); void enableavatarmask(); void disableavatarmask(); #endif