]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
Fix UI rendering to not use the bouncegrid texture; it looked interesting on the...
[xonotic/darkplaces.git] / gl_rmain.c
index d6ea4baf56561ff29fee0d6fb6142aae31d9cd09..d5412af87045d67763d24566f0acf04bab19118a 100644 (file)
@@ -69,12 +69,6 @@ cvar_t r_motionblur_mousefactor = {CVAR_SAVE, "r_motionblur_mousefactor", "2", "
 cvar_t r_motionblur_mousefactor_minspeed = {CVAR_SAVE, "r_motionblur_mousefactor_minspeed", "0", "lower value of mouse acceleration when it starts to factor into blur equation"};
 cvar_t r_motionblur_mousefactor_maxspeed = {CVAR_SAVE, "r_motionblur_mousefactor_maxspeed", "50", "upper value of mouse acceleration when it reaches the peak factor into blur equation"};
 
-// TODO do we want a r_equalize_entities cvar that works on all ents, or would that be a cheat?
-cvar_t r_equalize_entities_fullbright = {CVAR_SAVE, "r_equalize_entities_fullbright", "0", "render fullbright entities by equalizing their lightness, not by not rendering light (DEPRECATED)"};
-cvar_t r_equalize_entities_minambient = {CVAR_SAVE, "r_equalize_entities_minambient", "0.5", "light equalizing: ensure at least this ambient/diffuse ratio (DEPRECATED)"};
-cvar_t r_equalize_entities_by = {CVAR_SAVE, "r_equalize_entities_by", "0.7", "light equalizing: exponent of dynamics compression (0 = no compression, 1 = full compression) (DEPRECATED)"};
-cvar_t r_equalize_entities_to = {CVAR_SAVE, "r_equalize_entities_to", "0.8", "light equalizing: target light level (DEPRECATED)"};
-
 cvar_t r_depthfirst = {CVAR_SAVE, "r_depthfirst", "0", "renders a depth-only version of the scene before normal rendering begins to eliminate overdraw, values: 0 = off, 1 = world depth, 2 = world and model depth"};
 cvar_t r_useinfinitefarclip = {CVAR_SAVE, "r_useinfinitefarclip", "1", "enables use of a special kind of projection matrix that has an extremely large farclip"};
 cvar_t r_farclip_base = {0, "r_farclip_base", "65536", "farclip (furthest visible distance) for rendering when r_useinfinitefarclip is 0"};
@@ -581,7 +575,7 @@ static void R_BuildFogHeightTexture(void)
        r_refdef.fog_height_table2d = (unsigned char *)Mem_Alloc(r_main_mempool, size * size * 4);
        memcpy(r_refdef.fog_height_table1d, inpixels, size * 4);
        Mem_Free(inpixels);
-       // LordHavoc: now the magic - what is that table2d for?  it is a cooked
+       // LadyHavoc: now the magic - what is that table2d for?  it is a cooked
        // average fog color table accounting for every fog layer between a point
        // and the camera.  (Note: attenuation is handled separately!)
        for (y = 0;y < size;y++)
@@ -1735,7 +1729,7 @@ void R_SetupShader_Surface(const float rtlightambient[3], const float rtlightdif
                        permutation |= SHADERPERMUTATION_DEFERREDLIGHTMAP;
                if (t->reflectmasktexture)
                        permutation |= SHADERPERMUTATION_REFLECTCUBE;
-               if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld)
+               if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld && !notrippy)
                {
                        permutation |= SHADERPERMUTATION_BOUNCEGRID;
                        if (r_shadow_bouncegrid_state.directional)
@@ -1824,7 +1818,7 @@ void R_SetupShader_Surface(const float rtlightambient[3], const float rtlightdif
                        // ordinary vertex coloring (q3bsp)
                        mode = SHADERMODE_VERTEXCOLOR;
                }
-               if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld)
+               if (r_shadow_bouncegrid_state.texture && cl.csqc_vidvars.drawworld && !notrippy)
                {
                        permutation |= SHADERPERMUTATION_BOUNCEGRID;
                        if (r_shadow_bouncegrid_state.directional)
@@ -3202,10 +3196,6 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&r_motionblur_mousefactor);
        Cvar_RegisterVariable(&r_motionblur_mousefactor_minspeed);
        Cvar_RegisterVariable(&r_motionblur_mousefactor_maxspeed);
-       Cvar_RegisterVariable(&r_equalize_entities_fullbright);
-       Cvar_RegisterVariable(&r_equalize_entities_minambient);
-       Cvar_RegisterVariable(&r_equalize_entities_by);
-       Cvar_RegisterVariable(&r_equalize_entities_to);
        Cvar_RegisterVariable(&r_depthfirst);
        Cvar_RegisterVariable(&r_useinfinitefarclip);
        Cvar_RegisterVariable(&r_farclip_base);
@@ -3488,7 +3478,7 @@ int R_CullBoxCustomPlanes(const vec3_t mins, const vec3_t maxs, int numplanes, c
 
 //==================================================================================
 
-// LordHavoc: this stores temporary data used within the same frame
+// LadyHavoc: this stores temporary data used within the same frame
 
 typedef struct r_framedata_mem_s
 {
@@ -3761,7 +3751,7 @@ r_meshbuffer_t *R_BufferData_Store(size_t datasize, const void *data, r_bufferda
 
 //==================================================================================
 
-// LordHavoc: animcache originally written by Echon, rewritten since then
+// LadyHavoc: animcache originally written by Echon, rewritten since then
 
 /**
  * Animation cache prevents re-generating mesh data for an animated model
@@ -4348,7 +4338,7 @@ static void R_View_SetFrustum(const int *scissor)
        for (i = 0;i < r_refdef.view.numfrustumplanes;i++)
                PlaneClassify(r_refdef.view.frustum + i);
 
-       // LordHavoc: note to all quake engine coders, Quake had a special case
+       // LadyHavoc: note to all quake engine coders, Quake had a special case
        // for 90 degrees which assumed a square view (wrong), so I removed it,
        // Quake2 has it disabled as well.
 
@@ -4540,8 +4530,8 @@ void R_RenderView_UpdateViewVectors(void)
 
 void R_RenderTarget_FreeUnused(qboolean force)
 {
-       int i, j, end;
-       end = Mem_ExpandableArray_IndexRange(&r_fb.rendertargets);
+       unsigned int i, j, end;
+       end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
        for (i = 0; i < end; i++)
        {
                r_rendertarget_t *r = (r_rendertarget_t *)Mem_ExpandableArray_RecordAtIndex(&r_fb.rendertargets, i);
@@ -4581,11 +4571,11 @@ static void R_CalcTexCoordsForView(float x, float y, float w, float h, float tw,
 
 r_rendertarget_t *R_RenderTarget_Get(int texturewidth, int textureheight, textype_t depthtextype, qboolean depthisrenderbuffer, textype_t colortextype0, textype_t colortextype1, textype_t colortextype2, textype_t colortextype3)
 {
-       int i, j, end;
+       unsigned int i, j, end;
        r_rendertarget_t *r = NULL;
        char vabuf[256];
        // first try to reuse an existing slot if possible
-       end = Mem_ExpandableArray_IndexRange(&r_fb.rendertargets);
+       end = (unsigned int)Mem_ExpandableArray_IndexRange(&r_fb.rendertargets); // checked
        for (i = 0; i < end; i++)
        {
                r = (r_rendertarget_t *)Mem_ExpandableArray_RecordAtIndex(&r_fb.rendertargets, i);
@@ -5745,8 +5735,7 @@ void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, i
                R_TimeReport("animcache");
 
        R_Shadow_UpdateBounceGridTexture();
-       if (r_timereport_active && r_shadow_bouncegrid.integer)
-               R_TimeReport("bouncegrid");
+       // R_Shadow_UpdateBounceGridTexture called R_TimeReport a few times internally, so we don't need to do that here.
 
        r_fb.water.numwaterplanes = 0;
        if (r_fb.water.enabled)
@@ -6764,7 +6753,7 @@ texture_t *R_GetCurrentTexture(texture_t *t)
                t->currentmaterialflags |= MATERIALFLAG_ADD | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
        else if (t->currentalpha < 1)
                t->currentmaterialflags |= MATERIALFLAG_ALPHA | MATERIALFLAG_BLENDED | MATERIALFLAG_NOSHADOW;
-       // LordHavoc: prevent bugs where code checks add or alpha at higher priority than customblend by clearing these flags
+       // LadyHavoc: prevent bugs where code checks add or alpha at higher priority than customblend by clearing these flags
        if (t->currentmaterialflags & MATERIALFLAG_CUSTOMBLEND)
                t->currentmaterialflags &= ~(MATERIALFLAG_ADD | MATERIALFLAG_ALPHA);
        if (rsurface.ent_flags & RENDER_DOUBLESIDED)
@@ -8730,7 +8719,7 @@ static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_
 
 extern rtexture_t *r_shadow_prepasslightingdiffusetexture;
 extern rtexture_t *r_shadow_prepasslightingspeculartexture;
-static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean prepass)
+static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean prepass, qboolean ui)
 {
        if (r_fb.water.renderingscene && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA)))
                return;
@@ -8786,7 +8775,7 @@ static void R_DrawTextureSurfaceList_GL20(int texturenumsurfaces, const msurface
 
        // render surface batch normally
        GL_DepthMask(writedepth && !(rsurface.texture->currentmaterialflags & MATERIALFLAG_BLENDED));
-       R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BASE, texturenumsurfaces, texturesurfacelist, NULL, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY) != 0);
+       R_SetupShader_Surface(vec3_origin, vec3_origin, vec3_origin, RSURFPASS_BASE, texturenumsurfaces, texturesurfacelist, NULL, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY) != 0 || ui);
        RSurf_DrawBatch();
 }
 
@@ -8822,7 +8811,7 @@ static void R_DrawTextureSurfaceList_ShowSurfaces(int texturenumsurfaces, const
        RSurf_DrawBatch();
 }
 
-static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean prepass)
+static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth, qboolean prepass, qboolean ui)
 {
        CHECKGLERROR
        RSurf_SetupDepthAndCulling();
@@ -8835,7 +8824,7 @@ static void R_DrawModelTextureSurfaceList(int texturenumsurfaces, const msurface
        {
        case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
-               R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
+               R_DrawTextureSurfaceList_GL20(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
                break;
        }
        CHECKGLERROR
@@ -8918,7 +8907,7 @@ static void R_DrawSurface_TransparentCallback(const entity_render_t *ent, const
                                texturesurfacelist[texturenumsurfaces++] = surface;
                        }
                // render the range of surfaces
-               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, false, false);
+               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, false, false, false);
        }
        rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
 }
@@ -8972,7 +8961,7 @@ static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurf
 {
        CHECKGLERROR
        if (ui)
-               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
+               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
        else if (depthonly)
                R_DrawTextureSurfaceList_DepthOnly(texturenumsurfaces, texturesurfacelist);
        else if (prepass)
@@ -8982,7 +8971,7 @@ static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurf
                if (rsurface.texture->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED)
                        R_ProcessTransparentTextureSurfaceList(texturenumsurfaces, texturesurfacelist);
                else
-                       R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass);
+                       R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth, prepass, ui);
        }
        else if ((rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY) && (!r_showsurfaces.integer || r_showsurfaces.integer == 3))
                R_DrawTextureSurfaceList_Sky(texturenumsurfaces, texturesurfacelist);
@@ -8997,7 +8986,7 @@ static void R_ProcessModelTextureSurfaceList(int texturenumsurfaces, const msurf
        else
        {
                // the alphatest check is to make sure we write depth for anything we skipped on the depth-only pass earlier
-               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST), prepass);
+               R_DrawModelTextureSurfaceList(texturenumsurfaces, texturesurfacelist, writedepth || (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST), prepass, ui);
        }
        CHECKGLERROR
 }
@@ -10153,7 +10142,7 @@ void R_DebugLine(vec3_t start, vec3_t end)
 }
 
 
-void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass)
+void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass, qboolean ui)
 {
        int q;
        static texture_t texture;
@@ -10201,10 +10190,10 @@ void R_DrawCustomSurface(skinframe_t *skinframe, const matrix4x4_t *texmatrix, i
        rsurface.lightmaptexture = NULL;
        rsurface.deluxemaptexture = NULL;
        rsurface.uselightmaptexture = false;
-       R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass);
+       R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass, ui);
 }
 
-void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass)
+void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatrix, int materialflags, int firstvertex, int numvertices, int firsttriangle, int numtriangles, qboolean writedepth, qboolean prepass, qboolean ui)
 {
        static msurface_t surface;
        const msurface_t *surfacelist = &surface;
@@ -10221,5 +10210,5 @@ void R_DrawCustomSurface_Texture(texture_t *texture, const matrix4x4_t *texmatri
        rsurface.lightmaptexture = NULL;
        rsurface.deluxemaptexture = NULL;
        rsurface.uselightmaptexture = false;
-       R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass);
+       R_DrawModelTextureSurfaceList(1, &surfacelist, writedepth, prepass, ui);
 }