reworked use of alphatest - now only GL11/GL13/GLES1 paths use it, other
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Jun 2011 13:33:46 +0000 (13:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 8 Jun 2011 13:33:46 +0000 (13:33 +0000)
paths use SHADERPERMUTATION_ALPHAKILL (including the SOFT path)
reworked r_transparent_alphatocoverage, it no longer needs
vid_multisampling

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11186 d7cf8633-e32d-0410-b094-e92efae38249

dpsoftrast.c
dpsoftrast.h
gl_backend.c
gl_backend.h
gl_rmain.c
r_shadow.c
vid.h
vid_shared.c

index 86d4f7b..abefc1b 100644 (file)
@@ -249,9 +249,6 @@ typedef ATOMIC(struct DPSOFTRAST_State_Thread_s
        int depthtest;
        int depthfunc;
        int scissortest;
-       int alphatest;
-       int alphafunc;
-       float alphavalue;
        int viewport[4];
        int scissor[4];
        float depthrange[2];
@@ -1168,30 +1165,6 @@ void DPSOFTRAST_CullFace(int mode)
        command->mode = mode;
 }
 
-DEFCOMMAND(15, AlphaTest, int enable;)
-static void DPSOFTRAST_Interpret_AlphaTest(DPSOFTRAST_State_Thread *thread, DPSOFTRAST_Command_AlphaTest *command)
-{
-       thread->alphatest = command->enable;
-}
-void DPSOFTRAST_AlphaTest(int enable)
-{
-       DPSOFTRAST_Command_AlphaTest *command = DPSOFTRAST_ALLOCATECOMMAND(AlphaTest);
-       command->enable = enable;
-}
-
-DEFCOMMAND(16, AlphaFunc, int func; float ref;)
-static void DPSOFTRAST_Interpret_AlphaFunc(DPSOFTRAST_State_Thread *thread, DPSOFTRAST_Command_AlphaFunc *command)
-{
-       thread->alphafunc = command->func;
-       thread->alphavalue = command->ref;
-}
-void DPSOFTRAST_AlphaFunc(int func, float ref)
-{
-       DPSOFTRAST_Command_AlphaFunc *command = DPSOFTRAST_ALLOCATECOMMAND(AlphaFunc);
-       command->func = func;
-       command->ref = ref;
-}
-
 void DPSOFTRAST_Color4f(float r, float g, float b, float a)
 {
        dpsoftrast.color[0] = r;
@@ -2076,7 +2049,7 @@ void DPSOFTRAST_Draw_Span_FinishBGRA8(DPSOFTRAST_State_Thread *thread, const DPS
        pixel += (span->y * dpsoftrast.fb_width + span->x) * 4;
        pixeli += span->y * dpsoftrast.fb_width + span->x;
        // handle alphatest now (this affects depth writes too)
-       if (thread->alphatest)
+       if (thread->shader_permutation & SHADERPERMUTATION_ALPHAKILL)
                for (x = startx;x < endx;x++)
                        if (in4ub[x*4+3] < 128)
                                pixelmask[x] = false;
@@ -3333,7 +3306,7 @@ void DPSOFTRAST_PixelShader_FlatColor(DPSOFTRAST_State_Thread *thread, const DPS
        unsigned char buffer_FragColorbgra8[DPSOFTRAST_DRAW_MAXSPANLENGTH*4];
        DPSOFTRAST_Draw_Span_Begin(thread, triangle, span, buffer_z);
        DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(thread, triangle, span, buffer_texture_colorbgra8, GL20TU_COLOR, 2, buffer_z);
-       if (thread->alphatest || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
+       if ((thread->shader_permutation & SHADERPERMUTATION_ALPHAKILL) || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
                pixel = buffer_FragColorbgra8;
        Color_Ambientm = _mm_shuffle_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_load_ps(&thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4]), _mm_set1_ps(256.0f))), _MM_SHUFFLE(3, 0, 1, 2));
        Color_Ambientm = _mm_and_si128(Color_Ambientm, _mm_setr_epi32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
@@ -3386,7 +3359,7 @@ void DPSOFTRAST_PixelShader_VertexColor(DPSOFTRAST_State_Thread *thread, const D
        int arrayindex = DPSOFTRAST_ARRAY_COLOR;
        DPSOFTRAST_Draw_Span_Begin(thread, triangle, span, buffer_z);
        DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(thread, triangle, span, buffer_texture_colorbgra8, GL20TU_COLOR, 2, buffer_z);
-       if (thread->alphatest || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
+       if ((thread->shader_permutation & SHADERPERMUTATION_ALPHAKILL) || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
                pixel = buffer_FragColorbgra8;
        Color_Ambientm = _mm_shuffle_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_load_ps(&thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4]), _mm_set1_ps(256.0f))), _MM_SHUFFLE(3, 0, 1, 2));
        Color_Ambientm = _mm_and_si128(Color_Ambientm, _mm_setr_epi32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
@@ -3461,7 +3434,7 @@ void DPSOFTRAST_PixelShader_Lightmap(DPSOFTRAST_State_Thread *thread, const DPSO
        DPSOFTRAST_Draw_Span_Begin(thread, triangle, span, buffer_z);
        DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(thread, triangle, span, buffer_texture_colorbgra8, GL20TU_COLOR, DPSOFTRAST_ARRAY_TEXCOORD0, buffer_z);
        DPSOFTRAST_Draw_Span_Texture2DVaryingBGRA8(thread, triangle, span, buffer_texture_lightmapbgra8, GL20TU_LIGHTMAP, DPSOFTRAST_ARRAY_TEXCOORD4, buffer_z);
-       if (thread->alphatest || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
+       if ((thread->shader_permutation & SHADERPERMUTATION_ALPHAKILL) || thread->fb_blendmode != DPSOFTRAST_BLENDMODE_OPAQUE)
                pixel = buffer_FragColorbgra8;
        Color_Ambientm = _mm_shuffle_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_load_ps(&thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4]), _mm_set1_ps(256.0f))), _MM_SHUFFLE(3, 0, 1, 2));
        Color_Ambientm = _mm_and_si128(Color_Ambientm, _mm_setr_epi32(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0));
@@ -5486,8 +5459,6 @@ static void DPSOFTRAST_Draw_InterpretCommands(DPSOFTRAST_State_Thread *thread, i
                INTERPCOMMAND(DepthRange)
                INTERPCOMMAND(PolygonOffset)
                INTERPCOMMAND(CullFace)
-               INTERPCOMMAND(AlphaTest)
-               INTERPCOMMAND(AlphaFunc)
                INTERPCOMMAND(SetTexture)
                INTERPCOMMAND(SetShader)
                INTERPCOMMAND(Uniform4f)
@@ -5643,9 +5614,6 @@ int DPSOFTRAST_Init(int width, int height, int numthreads, int interlace, unsign
                thread->depthtest = true;
                thread->depthfunc = GL_LEQUAL;
                thread->scissortest = false;
-               thread->alphatest = false;
-               thread->alphafunc = GL_GREATER;
-               thread->alphavalue = 0.5f;
                thread->viewport[0] = 0;
                thread->viewport[1] = 0;
                thread->viewport[2] = dpsoftrast.fb_width;
index ef77508..3f267a2 100644 (file)
@@ -65,8 +65,6 @@ void DPSOFTRAST_DepthFunc(int comparemode);
 void DPSOFTRAST_DepthRange(float range0, float range1);
 void DPSOFTRAST_PolygonOffset(float alongnormal, float intoview);
 void DPSOFTRAST_CullFace(int mode);
-void DPSOFTRAST_AlphaTest(int enable);
-void DPSOFTRAST_AlphaFunc(int alphafunc, float alphavalue);
 void DPSOFTRAST_Color4f(float r, float g, float b, float a);
 void DPSOFTRAST_GetPixelsBGRA(int blockx, int blocky, int blockwidth, int blockheight, unsigned char *outpixels);
 void DPSOFTRAST_CopyRectangleToTexture(int index, int mip, int tx, int ty, int sx, int sy, int width, int height);
index d2dae38..cdc4df6 100644 (file)
@@ -137,6 +137,7 @@ typedef struct gl_state_s
        int alphatest;
        int alphafunc;
        float alphafuncvalue;
+       qboolean alphatocoverage;
        int scissortest;
        unsigned int unit;
        unsigned int clientunit;
@@ -1391,6 +1392,7 @@ static void GL_Backend_ResetState(void)
        gl_state.alphatest = false;
        gl_state.alphafunc = GL_GEQUAL;
        gl_state.alphafuncvalue = 0.5f;
+       gl_state.alphatocoverage = false;
        gl_state.blendfunc1 = GL_ONE;
        gl_state.blendfunc2 = GL_ZERO;
        gl_state.blend = false;
@@ -1412,9 +1414,6 @@ static void GL_Backend_ResetState(void)
 #ifdef SUPPORTD3D
                {
                        IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_COLORWRITEENABLE, gl_state.colormask);
-                       IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ALPHATESTENABLE, gl_state.alphatest);
-                       IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ALPHAFUNC, d3dcmpforglfunc(gl_state.alphafunc));
-                       IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ALPHAREF, (int)bound(0, gl_state.alphafuncvalue * 256.0f, 255));
                        IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_CULLMODE, D3DCULL_NONE);
                        IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ZFUNC, d3dcmpforglfunc(gl_state.depthfunc));
                        IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ZENABLE, gl_state.depthtest);
@@ -1437,7 +1436,7 @@ static void GL_Backend_ResetState(void)
 
                qglColorMask(1, 1, 1, 1);CHECKGLERROR
                qglAlphaFunc(gl_state.alphafunc, gl_state.alphafuncvalue);CHECKGLERROR
-               qglDisable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+               qglDisable(GL_ALPHA_TEST);CHECKGLERROR
                qglBlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);CHECKGLERROR
                qglDisable(GL_BLEND);CHECKGLERROR
                qglCullFace(gl_state.cullface);CHECKGLERROR
@@ -1499,7 +1498,6 @@ static void GL_Backend_ResetState(void)
                break;
        case RENDERPATH_SOFT:
                DPSOFTRAST_ColorMask(1,1,1,1);
-               DPSOFTRAST_AlphaTest(gl_state.alphatest);
                DPSOFTRAST_BlendFunc(gl_state.blendfunc1, gl_state.blendfunc2);
                DPSOFTRAST_CullFace(gl_state.cullface);
                DPSOFTRAST_DepthFunc(gl_state.depthfunc);
@@ -1520,11 +1518,6 @@ static void GL_Backend_ResetState(void)
                qglEnable(GL_DEPTH_TEST);CHECKGLERROR
                qglDepthMask(gl_state.depthmask);CHECKGLERROR
                qglPolygonOffset(gl_state.polygonoffset[0], gl_state.polygonoffset[1]);
-       //      if (vid.renderpath == RENDERPATH_GL20)
-       //      {
-       //              qglAlphaFunc(gl_state.alphafunc, gl_state.alphafuncvalue);CHECKGLERROR
-       //              qglDisable(GL_ALPHA_TEST);CHECKGLERROR
-       //      }
                if (vid.support.arb_vertex_buffer_object)
                {
                        qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
@@ -2129,7 +2122,7 @@ void GL_MultiSampling(qboolean state)
                case RENDERPATH_GLES1:
                case RENDERPATH_GL20:
                case RENDERPATH_GLES2:
-                       if (vid.support.arb_multisample)
+                       if (vid.support.arb_multisample && vid.mode.samples > 1)
                        {
                                if (state)
                                        qglEnable(GL_MULTISAMPLE_ARB);
@@ -2163,34 +2156,55 @@ void GL_AlphaTest(int state)
                        CHECKGLERROR
                        if (gl_state.alphatest)
                        {
-                               qglEnable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+                               qglEnable(GL_ALPHA_TEST);CHECKGLERROR
                        }
                        else
                        {
-                               qglDisable((r_transparent_alphatocoverage.integer) ? GL_SAMPLE_ALPHA_TO_COVERAGE_ARB : GL_ALPHA_TEST);CHECKGLERROR
+                               qglDisable(GL_ALPHA_TEST);CHECKGLERROR
                        }
                        break;
                case RENDERPATH_D3D9:
-#ifdef SUPPORTD3D
-//                     IDirect3DDevice9_SetRenderState(vid_d3d9dev, D3DRS_ALPHATESTENABLE, gl_state.alphatest);
-#endif
-                       break;
                case RENDERPATH_D3D10:
-                       break;
                case RENDERPATH_D3D11:
+               case RENDERPATH_SOFT:
+               case RENDERPATH_GL20:
+               case RENDERPATH_GLES2:
                        break;
+               }
+       }
+}
+
+void GL_AlphaToCoverage(qboolean state)
+{
+       if (gl_state.alphatocoverage != state)
+       {
+               gl_state.alphatocoverage = state;
+               switch(vid.renderpath)
+               {
+               case RENDERPATH_GL11:
+               case RENDERPATH_GL13:
+               case RENDERPATH_GLES1:
+               case RENDERPATH_GLES2:
+               case RENDERPATH_D3D9:
+               case RENDERPATH_D3D10:
+               case RENDERPATH_D3D11:
                case RENDERPATH_SOFT:
-                       DPSOFTRAST_AlphaTest(gl_state.alphatest);
                        break;
                case RENDERPATH_GL20:
-               case RENDERPATH_GLES2:
-                       if (vid_multisampling.integer)
+                       // alpha to coverage turns the alpha value of the pixel into 0%, 25%, 50%, 75% or 100% by masking the multisample fragments accordingly
+                       if (vid.support.arb_multisample && vid.mode.samples > 1)
                        {
-                               if (gl_state.alphatest && r_transparent_alphatocoverage.integer)
-                                       qglEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
-                               else
-                                       qglDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
                                CHECKGLERROR
+                               if (gl_state.alphatocoverage)
+                               {
+                                       qglEnable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);CHECKGLERROR
+                                       qglEnable(GL_MULTISAMPLE_ARB);CHECKGLERROR
+                               }
+                               else
+                               {
+                                       qglDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);CHECKGLERROR
+                                       qglDisable(GL_MULTISAMPLE_ARB);CHECKGLERROR
+                               }
                        }
                        break;
                }
index 8f6e5ab..1f41660 100644 (file)
@@ -40,6 +40,7 @@ void R_SetStencil(qboolean enable, int writemask, int fail, int zfail, int zpass
 void GL_PolygonOffset(float planeoffset, float depthoffset);
 void GL_CullFace(int state);
 void GL_AlphaTest(int state);
+void GL_AlphaToCoverage(qboolean state);
 void GL_MultiSampling(qboolean state);
 void GL_ColorMask(int r, int g, int b, int a);
 void GL_Color(float cr, float cg, float cb, float ca);
index 627f1b4..9158696 100644 (file)
@@ -72,7 +72,7 @@ cvar_t r_farclip_world = {0, "r_farclip_world", "2", "adds map size to farclip m
 cvar_t r_nearclip = {0, "r_nearclip", "1", "distance from camera of nearclip plane" };
 cvar_t r_deformvertexes = {0, "r_deformvertexes", "1", "allows use of deformvertexes in shader files (can be turned off to check performance impact)"};
 cvar_t r_transparent = {0, "r_transparent", "1", "allows use of transparent surfaces (can be turned off to check performance impact)"};
-cvar_t r_transparent_alphatocoverage = {0, "r_transparent_alphatocoverage", "0", "enables alpha-to-coverage antialiasing technique on alphatest surfaces, this is not yet finished as multisampling is not used"};
+cvar_t r_transparent_alphatocoverage = {0, "r_transparent_alphatocoverage", "0", "enables alpha-to-coverage antialiasing technique on alphatest surfaces when using vid_samples 2 or higher"};
 cvar_t r_showoverdraw = {0, "r_showoverdraw", "0", "shows overlapping geometry"};
 cvar_t r_showbboxes = {0, "r_showbboxes", "0", "shows bounding boxes of server entities, value controls opacity scaling (1 = 10%,  10 = 100%)"};
 cvar_t r_showsurfaces = {0, "r_showsurfaces", "0", "1 shows surfaces as different colors, or a value of 2 shows triangle draw order (for analyzing whether meshes are optimized for vertex cache)"};
@@ -1911,6 +1911,7 @@ void R_SetupShader_Generic(rtexture_t *first, rtexture_t *second, int texturemod
                permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
        if (!second)
                texturemode = GL_MODULATE;
+       GL_AlphaToCoverage(false);
        switch (vid.renderpath)
        {
        case RENDERPATH_D3D9:
@@ -1956,6 +1957,7 @@ void R_SetupShader_DepthOrShadow(qboolean notrippy)
        unsigned int permutation = 0;
        if (r_trippy.integer && !notrippy)
                permutation |= SHADERPERMUTATION_TRIPPY;
+       GL_AlphaToCoverage(false);
        switch (vid.renderpath)
        {
        case RENDERPATH_D3D9:
@@ -1994,6 +1996,7 @@ void R_SetupShader_ShowDepth(qboolean notrippy)
                permutation |= SHADERPERMUTATION_TRIPPY;
        if (r_trippy.integer)
                permutation |= SHADERPERMUTATION_TRIPPY;
+       GL_AlphaToCoverage(false);
        switch (vid.renderpath)
        {
        case RENDERPATH_D3D9:
@@ -2145,6 +2148,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                        GL_BlendFunc(GL_ONE, GL_ZERO);
                        blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
                }
+               GL_AlphaToCoverage(false);
        }
        else if (rsurfacepass == RSURFPASS_DEFERREDGEOMETRY)
        {
@@ -2164,6 +2168,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                mode = SHADERMODE_DEFERREDGEOMETRY;
                GL_BlendFunc(GL_ONE, GL_ZERO);
                blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
+               GL_AlphaToCoverage(false);
        }
        else if (rsurfacepass == RSURFPASS_RTLIGHT)
        {
@@ -2208,6 +2213,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                        permutation |= SHADERPERMUTATION_REFLECTCUBE;
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
                blendfuncflags = R_BlendFuncFlags(GL_SRC_ALPHA, GL_ONE);
+               GL_AlphaToCoverage(false);
        }
        else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)
        {
@@ -2250,6 +2256,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                        permutation |= SHADERPERMUTATION_REFLECTCUBE;
                GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
                blendfuncflags = R_BlendFuncFlags(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
+               GL_AlphaToCoverage(r_transparent_alphatocoverage.integer && (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST));
        }
        else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT_DIRECTIONAL)
        {
@@ -2302,6 +2309,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
                blendfuncflags = R_BlendFuncFlags(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
+               GL_AlphaToCoverage(r_transparent_alphatocoverage.integer && (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST));
        }
        else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT)
        {
@@ -2351,6 +2359,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
                blendfuncflags = R_BlendFuncFlags(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
+               GL_AlphaToCoverage(r_transparent_alphatocoverage.integer && (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST));
        }
        else
        {
@@ -2436,6 +2445,7 @@ void R_SetupShader_Surface(const vec3_t lightcolorbase, qboolean modellighting,
                }
                GL_BlendFunc(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
                blendfuncflags = R_BlendFuncFlags(rsurface.texture->currentlayers[0].blendfunc1, rsurface.texture->currentlayers[0].blendfunc2);
+               GL_AlphaToCoverage(r_transparent_alphatocoverage.integer && (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST));
        }
        if(!(blendfuncflags & BLENDFUNC_ALLOWS_COLORMOD))
                colormod = dummy_colormod;
@@ -2936,6 +2946,7 @@ void R_SetupShader_DeferredLight(const rtlight_t *rtlight)
                else if (r_shadow_shadowmappcf)
                        permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
        }
+       GL_AlphaToCoverage(false);
        Matrix4x4_Transform(&r_refdef.view.viewport.viewmatrix, rtlight->shadoworigin, viewlightorigin);
        Matrix4x4_Concat(&lighttoview, &r_refdef.view.viewport.viewmatrix, &rtlight->matrix_lighttoworld);
        Matrix4x4_Invert_Simple(&viewtolight, &lighttoview);
@@ -9632,11 +9643,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, (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT) != 0, 1, 1, rsurface.texture->specularscale, RSURFPASS_BASE, texturenumsurfaces, texturesurfacelist, NULL, (rsurface.texture->currentmaterialflags & MATERIALFLAG_SKY) != 0);
-       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-               GL_AlphaTest(true);
        RSurf_DrawBatch();
-       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-               GL_AlphaTest(false);
 }
 
 static void R_DrawTextureSurfaceList_GL13(int texturenumsurfaces, const msurface_t **texturesurfacelist, qboolean writedepth)
index ce56b64..7de402e 100644 (file)
@@ -3168,17 +3168,7 @@ static void R_Shadow_RenderLighting_Light_GLSL(int texturenumsurfaces, const msu
 {
        // ARB2 GLSL shader path (GFFX5200, Radeon 9500)
        R_SetupShader_Surface(lightcolor, false, ambientscale, diffusescale, specularscale, RSURFPASS_RTLIGHT, texturenumsurfaces, texturesurfacelist, NULL, false);
-       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-       {
-               GL_DepthFunc(GL_EQUAL);
-               GL_AlphaTest(true);
-       }
        RSurf_DrawBatch();
-       if (rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST)
-       {
-               GL_DepthFunc(GL_LEQUAL);
-               GL_AlphaTest(false);
-       }
 }
 
 static void R_Shadow_RenderLighting_Light_Vertex_Pass(int firstvertex, int numvertices, int numtriangles, const int *element3i, vec3_t diffusecolor2, vec3_t ambientcolor2)
diff --git a/vid.h b/vid.h
index 6ff6a65..1bc6e0c 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -180,7 +180,6 @@ extern cvar_t vid_width;
 extern cvar_t vid_height;
 extern cvar_t vid_bitsperpixel;
 extern cvar_t vid_samples;
-extern cvar_t vid_multisampling;
 extern cvar_t vid_refreshrate;
 extern cvar_t vid_userefreshrate;
 extern cvar_t vid_vsync;
index f59a759..05f17f5 100644 (file)
@@ -164,7 +164,6 @@ cvar_t vid_width = {CVAR_SAVE, "vid_width", "640", "resolution"};
 cvar_t vid_height = {CVAR_SAVE, "vid_height", "480", "resolution"};
 cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32", "how many bits per pixel to render at (32 or 16, 32 is recommended)"};
 cvar_t vid_samples = {CVAR_SAVE, "vid_samples", "1", "how many anti-aliasing samples per pixel to request from the graphics driver (4 is recommended, 1 is faster)"};
-cvar_t vid_multisampling = {CVAR_SAVE, "vid_multisampling", "0", "Make use of GL_AGB_MULTISAMPLING for advaced anti-aliasing techniques such as Alpha-To-Coverage, not yet finished"};
 cvar_t vid_refreshrate = {CVAR_SAVE, "vid_refreshrate", "60", "refresh rate to use, in hz (higher values flicker less, if supported by your monitor)"};
 cvar_t vid_userefreshrate = {CVAR_SAVE, "vid_userefreshrate", "0", "set this to 1 to make vid_refreshrate used, or to 0 to let the engine choose a sane default"};
 cvar_t vid_stereobuffer = {CVAR_SAVE, "vid_stereobuffer", "0", "enables 'quad-buffered' stereo rendering for stereo shutterglasses, HMD (head mounted display) devices, or polarized stereo LCDs, if supported by your drivers"};
@@ -1640,7 +1639,6 @@ void VID_Shared_Init(void)
        Cvar_RegisterVariable(&vid_height);
        Cvar_RegisterVariable(&vid_bitsperpixel);
        Cvar_RegisterVariable(&vid_samples);
-       Cvar_RegisterVariable(&vid_multisampling);
        Cvar_RegisterVariable(&vid_refreshrate);
        Cvar_RegisterVariable(&vid_userefreshrate);
        Cvar_RegisterVariable(&vid_stereobuffer);
@@ -1715,17 +1713,6 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate,
 {
        viddef_mode_t mode;
 
-#if 0
-       // LordHavoc: FIXME: VorteX broke vid_restart with this, it is a mystery why it would ever work, commented out
-       // multisampling should set at least 2 samples
-       if (vid.support.arb_multisample)
-       {
-               GL_MultiSampling(false);
-               if (vid_multisampling.integer)
-                       samples = max(2, samples);
-       }
-#endif
-
        memset(&mode, 0, sizeof(mode));
        mode.fullscreen = fullscreen != 0;
        mode.width = width;
@@ -1764,9 +1751,10 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate,
                        Cvar_SetValueQuick(&vid_refreshrate, vid.mode.refreshrate);
                Cvar_SetValueQuick(&vid_stereobuffer, vid.mode.stereobuffer);
 
-               // activate multisampling
-               if (vid_multisampling.integer)
-                       GL_MultiSampling(true);
+               // LordHavoc: disabled this code because multisampling is on by default if the framebuffer is multisampled
+//             // activate multisampling
+//             if (vid.mode.samples > 1)
+//                     GL_MultiSampling(true);
 
                return true;
        }