// we invert it again during the blendfunc to make it work...
#ifndef DUMPPARTICLEFONT
- decalskinframe = R_SkinFrame_LoadExternal("particles/particlefont.tga", TEXF_ALPHA | TEXF_FORCELINEAR, false);
+ decalskinframe = R_SkinFrame_LoadExternal("particles/particlefont.tga", TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, false);
if (decalskinframe)
{
particlefonttexture = decalskinframe->base;
Image_WriteTGABGRA ("particles/particlefont.tga", PARTICLEFONTSIZE, PARTICLEFONTSIZE, particletexturedata);
#endif
- decalskinframe = R_SkinFrame_LoadInternalBGRA("particlefont", TEXF_ALPHA | TEXF_FORCELINEAR, particletexturedata, PARTICLEFONTSIZE, PARTICLEFONTSIZE);
+ decalskinframe = R_SkinFrame_LoadInternalBGRA("particlefont", TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, particletexturedata, PARTICLEFONTSIZE, PARTICLEFONTSIZE);
particlefonttexture = decalskinframe->base;
Mem_Free(particletexturedata);
}
#ifndef DUMPPARTICLEFONT
- particletexture[tex_beam].texture = loadtextureimage(particletexturepool, "particles/nexbeam.tga", false, TEXF_ALPHA | TEXF_FORCELINEAR, true, r_texture_convertsRGB_particles.integer != 0);
+ particletexture[tex_beam].texture = loadtextureimage(particletexturepool, "particles/nexbeam.tga", false, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, true, r_texture_convertsRGB_particles.integer != 0);
if (!particletexture[tex_beam].texture)
#endif
{
#ifdef DUMPPARTICLEFONT
Image_WriteTGABGRA ("particles/nexbeam.tga", 64, 64, &data2[0][0][0]);
#endif
- particletexture[tex_beam].texture = R_LoadTexture2D(particletexturepool, "nexbeam", 16, 64, &data2[0][0][0], TEXTYPE_BGRA, TEXF_ALPHA | TEXF_FORCELINEAR, -1, NULL);
+ particletexture[tex_beam].texture = R_LoadTexture2D(particletexturepool, "nexbeam", 16, 64, &data2[0][0][0], TEXTYPE_BGRA, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, -1, NULL);
}
particletexture[tex_beam].s1 = 0;
particletexture[tex_beam].t1 = 0;
Con_Printf("particles/particlefont.txt: texnum %i outside valid range (0 to %i)\n", i, MAX_PARTICLETEXTURES);
continue;
}
- particletexture[i].texture = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR, false)->base;
+ particletexture[i].texture = R_SkinFrame_LoadExternal(texturename, TEXF_ALPHA | TEXF_FORCELINEAR | TEXF_RGBMULTIPLYBYALPHA, false)->base;
particletexture[i].s1 = s1;
particletexture[i].t1 = t1;
particletexture[i].s2 = s2;
palpha = p->alpha;
if(dofade && p->orientation != PARTICLE_VBEAM && p->orientation != PARTICLE_HBEAM)
palpha *= min(1, (DotProduct(p->org, r_refdef.view.forward) - minparticledist_start) / (minparticledist_end - minparticledist_start));
+ alpha = palpha * colormultiplier[3];
+ // ensure alpha multiplier saturates properly
+ if (alpha > 1.0f)
+ alpha = 1.0f;
switch (blendmode)
{
case PBLEND_INVALID:
case PBLEND_INVMOD:
- alpha = palpha * colormultiplier[3];
- // ensure alpha multiplier saturates properly
- if (alpha > 1.0f)
- alpha = 1.0f;
// additive and modulate can just fade out in fog (this is correct)
if (r_refdef.fogenabled)
alpha *= RSurf_FogVertex(p->org);
c4f[0] = p->color[0] * alpha;
c4f[1] = p->color[1] * alpha;
c4f[2] = p->color[2] * alpha;
- c4f[3] = 1;
+ c4f[3] = 0;
break;
case PBLEND_ADD:
- alpha = palpha * colormultiplier[3];
- // ensure alpha multiplier saturates properly
- if (alpha > 1.0f)
- alpha = 1.0f;
// additive and modulate can just fade out in fog (this is correct)
if (r_refdef.fogenabled)
alpha *= RSurf_FogVertex(p->org);
c4f[0] = p->color[0] * colormultiplier[0] * alpha;
c4f[1] = p->color[1] * colormultiplier[1] * alpha;
c4f[2] = p->color[2] * colormultiplier[2] * alpha;
- c4f[3] = 1;
+ c4f[3] = 0;
break;
case PBLEND_ALPHA:
- c4f[0] = p->color[0] * colormultiplier[0];
- c4f[1] = p->color[1] * colormultiplier[1];
- c4f[2] = p->color[2] * colormultiplier[2];
- c4f[3] = palpha * colormultiplier[3];
+ c4f[0] = alpha * p->color[0] * colormultiplier[0];
+ c4f[1] = alpha * p->color[1] * colormultiplier[1];
+ c4f[2] = alpha * p->color[2] * colormultiplier[2];
+ c4f[3] = alpha;
// note: lighting is not cheap!
if (particletype[p->typeindex].lighting)
{
{
p = cl.particles + surfacelist[surfacelistindex];
- if (blendmode != p->blendmode)
- {
- blendmode = (pblend_t)p->blendmode;
- switch(blendmode)
- {
- case PBLEND_ALPHA:
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- break;
- case PBLEND_INVALID:
- case PBLEND_ADD:
- GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
- break;
- case PBLEND_INVMOD:
- GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
- break;
- }
- }
if (texture != particletexture[p->texnum].texture)
{
texture = particletexture[p->texnum].texture;
R_SetupShader_Generic(texture, NULL, GL_MODULATE, 1);
}
- // iterate until we find a change in settings
- batchstart = surfacelistindex++;
- for (;surfacelistindex < numsurfaces;surfacelistindex++)
+ if (p->blendmode == PBLEND_INVMOD)
{
- p = cl.particles + surfacelist[surfacelistindex];
- if (blendmode != p->blendmode || texture != particletexture[p->texnum].texture)
- break;
+ // inverse modulate blend - group these
+ GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
+ // iterate until we find a change in settings
+ batchstart = surfacelistindex++;
+ for (;surfacelistindex < numsurfaces;surfacelistindex++)
+ {
+ p = cl.particles + surfacelist[surfacelistindex];
+ if (p->blendmode != PBLEND_INVMOD || texture != particletexture[p->texnum].texture)
+ break;
+ }
+ }
+ else
+ {
+ // additive or alpha blend - group these
+ // (we can group these because we premultiplied the texture alpha)
+ GL_BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ // iterate until we find a change in settings
+ batchstart = surfacelistindex++;
+ for (;surfacelistindex < numsurfaces;surfacelistindex++)
+ {
+ p = cl.particles + surfacelist[surfacelistindex];
+ if (p->blendmode == PBLEND_INVMOD || texture != particletexture[p->texnum].texture)
+ break;
+ }
}
batchcount = surfacelistindex - batchstart;