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 when using vid_samples 2 or higher"};
+cvar_t r_transparent_alphatocoverage = {0, "r_transparent_alphatocoverage", "1", "enables GL_ALPHA_TO_COVERAGE antialiasing technique on alphablend and 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)"};
permutation |= SHADERPERMUTATION_VERTEXTEXTUREBLEND;
if (!second)
texturemode = GL_MODULATE;
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
switch (vid.renderpath)
{
case RENDERPATH_D3D9:
unsigned int permutation = 0;
if (r_trippy.integer && !notrippy)
permutation |= SHADERPERMUTATION_TRIPPY;
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
switch (vid.renderpath)
{
case RENDERPATH_D3D9:
permutation |= SHADERPERMUTATION_TRIPPY;
if (r_trippy.integer)
permutation |= SHADERPERMUTATION_TRIPPY;
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
switch (vid.renderpath)
{
case RENDERPATH_D3D9:
GL_BlendFunc(GL_ONE, GL_ZERO);
blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
}
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
}
else if (rsurfacepass == RSURFPASS_DEFERREDGEOMETRY)
{
mode = SHADERMODE_DEFERREDGEOMETRY;
GL_BlendFunc(GL_ONE, GL_ZERO);
blendfuncflags = R_BlendFuncFlags(GL_ONE, GL_ZERO);
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
}
else if (rsurfacepass == RSURFPASS_RTLIGHT)
{
permutation |= SHADERPERMUTATION_REFLECTCUBE;
GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
blendfuncflags = R_BlendFuncFlags(GL_SRC_ALPHA, GL_ONE);
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ GL_AlphaToCoverage(false);
}
else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_FULLBRIGHT)
{
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));
+ // when using alphatocoverage, we don't need alphakill
+ if (vid.allowalphatocoverage)
+ {
+ if (r_transparent_alphatocoverage.integer)
+ {
+ GL_AlphaToCoverage((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
+ permutation &= ~SHADERPERMUTATION_ALPHAKILL;
+ }
+ else
+ GL_AlphaToCoverage(false);
+ }
}
else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT_DIRECTIONAL)
{
}
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));
+ // when using alphatocoverage, we don't need alphakill
+ if (vid.allowalphatocoverage)
+ {
+ if (r_transparent_alphatocoverage.integer)
+ {
+ GL_AlphaToCoverage((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
+ permutation &= ~SHADERPERMUTATION_ALPHAKILL;
+ }
+ else
+ GL_AlphaToCoverage(false);
+ }
}
else if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT)
{
}
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));
+ // when using alphatocoverage, we don't need alphakill
+ if (vid.allowalphatocoverage)
+ {
+ if (r_transparent_alphatocoverage.integer)
+ {
+ GL_AlphaToCoverage((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
+ permutation &= ~SHADERPERMUTATION_ALPHAKILL;
+ }
+ else
+ GL_AlphaToCoverage(false);
+ }
}
else
{
}
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));
+ // when using alphatocoverage, we don't need alphakill
+ if (vid.allowalphatocoverage)
+ {
+ if (r_transparent_alphatocoverage.integer)
+ {
+ GL_AlphaToCoverage((rsurface.texture->currentmaterialflags & MATERIALFLAG_ALPHATEST) != 0);
+ permutation &= ~SHADERPERMUTATION_ALPHAKILL;
+ }
+ else
+ GL_AlphaToCoverage(false);
+ }
}
if(!(blendfuncflags & BLENDFUNC_ALLOWS_COLORMOD))
colormod = dummy_colormod;
else if (r_shadow_shadowmappcf)
permutation |= SHADERPERMUTATION_SHADOWMAPPCF;
}
- GL_AlphaToCoverage(false);
+ if (vid.allowalphatocoverage)
+ 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);
}
else
t->currentmaterialflags &= ~(MATERIALFLAG_REFRACTION | MATERIALFLAG_WATERSHADER | MATERIALFLAG_CAMERA);
+ if (vid.allowalphatocoverage && r_transparent_alphatocoverage.integer >= 2 && ((t->currentmaterialflags & (MATERIALFLAG_BLENDED | MATERIALFLAG_ALPHA | MATERIALFLAG_ADD | MATERIALFLAG_CUSTOMBLEND)) == (MATERIALFLAG_BLENDED | MATERIALFLAG_ALPHA)))
+ {
+ // promote alphablend to alphatocoverage (a type of alphatest) if antialiasing is on
+ t->currentmaterialflags = (t->currentmaterialflags & ~(MATERIALFLAG_BLENDED | MATERIALFLAG_ALPHA)) | MATERIALFLAG_ALPHATEST;
+ }
if ((t->currentmaterialflags & (MATERIALFLAG_BLENDED | MATERIALFLAG_NODEPTHTEST)) == MATERIALFLAG_BLENDED && r_transparentdepthmasking.integer && !(t->basematerialflags & MATERIALFLAG_BLENDED))
t->currentmaterialflags |= MATERIALFLAG_TRANSDEPTH;
vid.support.ext_texture_filter_anisotropic = GL_CheckExtension("GL_EXT_texture_filter_anisotropic", NULL, "-noanisotropy", false);
vid.support.ext_texture_srgb = GL_CheckExtension("GL_EXT_texture_sRGB", NULL, "-nosrgb", false);
vid.support.arb_multisample = GL_CheckExtension("GL_ARB_multisample", multisamplefuncs, "-nomultisample", false);
+ vid.allowalphatocoverage = false;
// COMMANDLINEOPTION: GL: -noshaders disables use of OpenGL 2.0 shaders (which allow pixel shader effects, can improve per pixel lighting performance and capabilities)
// COMMANDLINEOPTION: GL: -noanisotropy disables GL_EXT_texture_filter_anisotropic (allows higher quality texturing)
vid.sRGBcapable2D = false;
vid.sRGBcapable3D = true;
vid.useinterleavedarrays = false;
+ Con_Printf("vid.support.arb_multisample %i\n", vid.support.arb_multisample);
+ Con_Printf("vid.mode.samples %i\n", vid.mode.samples);
+ Con_Printf("vid.support.gl20shaders %i\n", vid.support.gl20shaders);
+ vid.allowalphatocoverage = vid.support.arb_multisample && vid_samples.integer > 1 && vid.support.gl20shaders;
}
else if (vid.support.arb_texture_env_combine && vid.texunits >= 2 && vid_gl13.integer)
{
vid.sRGBcapable3D = false;
vid.useinterleavedarrays = false;
}
+ // enable multisample antialiasing if possible
+ if (vid_samples.integer > 1 && vid.support.arb_multisample)
+ qglEnable(GL_MULTISAMPLE_ARB);
// VorteX: set other info (maybe place them in VID_InitMode?)
Cvar_SetQuick(&gl_info_vendor, gl_vendor);
Cvar_SetValueQuick(&vid_refreshrate, vid.mode.refreshrate);
Cvar_SetValueQuick(&vid_stereobuffer, vid.mode.stereobuffer);
- // 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;
}
else