Skip to content

Commit

Permalink
Added cvar "rend-sprite-alpha". 1=Enable variable translucency on spr…
Browse files Browse the repository at this point in the history
…ites.
  • Loading branch information
danij committed Sep 30, 2006
1 parent bf7eb66 commit 86ca3ba
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
19 changes: 11 additions & 8 deletions doomsday/engine/data/cphelp.txt
Expand Up @@ -725,17 +725,14 @@ desc = 1=Always render the full sky sphere.
[rend-sky-simple]
desc = Sky rendering mode: 0=normal, 1=quads.

[rend-sprite-align]
desc = 1=Always align sprites with the view plane. 2=Align to camera, unless slant > r_maxSpriteAngle.

[rend-sprite-align-angle]
desc = Maximum angle for slanted sprites (spralign 2).

[rend-sprite-noz]
desc = 1=Don't write sprites in the Z buffer.

[rend-sprite-precache]
desc = 1=Precache sprites at level setup (slow).

[rend-sprite-align]
desc = 1=Always align sprites with the view plane. 2=Align to camera, unless slant > r_maxSpriteAngle.
[rend-sprite-alpha]
desc = 1=Enable variable translucency on sprites.

[rend-sprite-blend]
desc = 1=Use additive blending for explosions.
Expand All @@ -746,6 +743,12 @@ desc = 1=Sprites lit using dynamic lights.
[rend-sprite-mode]
desc = 1=Draw sprites and masked walls with hard edges.

[rend-sprite-noz]
desc = 1=Don't write sprites in the Z buffer.

[rend-sprite-precache]
desc = 1=Precache sprites at level setup (slow).

[rend-model]
desc = Render using 3D models when possible.

Expand Down
38 changes: 24 additions & 14 deletions doomsday/engine/portable/src/rend_sprite.c
Expand Up @@ -63,18 +63,21 @@ static byte *slRGB1, *slRGB2;
static fvertex_t slViewVec;
static vissprite_t *slSpr;

static int useSpriteAlpha = 1;

// CODE --------------------------------------------------------------------

void Rend_SpriteRegister(void)
{
// Cvars
C_VAR_FLOAT("rend-sprite-align-angle", &maxSpriteAngle, 0, 0, 90);
C_VAR_INT("rend-sprite-noz", &r_nospritez, 0, 0, 1);
C_VAR_BYTE("rend-sprite-precache", &r_precache_sprites, 0, 0, 1);
C_VAR_INT("rend-sprite-align", &alwaysAlign, 0, 0, 3);
C_VAR_FLOAT("rend-sprite-align-angle", &maxSpriteAngle, 0, 0, 90);
C_VAR_INT("rend-sprite-alpha", &useSpriteAlpha, 0, 0, 1);
C_VAR_INT("rend-sprite-blend", &missileBlend, 0, 0, 1);
C_VAR_INT("rend-sprite-lit", &litSprites, 0, 0, 1);
C_VAR_BYTE("rend-sprite-mode", &noSpriteTrans, 0, 0, 1);
C_VAR_INT("rend-sprite-noz", &r_nospritez, 0, 0, 1);
C_VAR_BYTE("rend-sprite-precache", &r_precache_sprites, 0, 0, 1);
}

/**
Expand Down Expand Up @@ -599,21 +602,28 @@ void Rend_RenderSprite(vissprite_t * spr)
sprh = spritelumps[patch]->height;

// Set the lighting and alpha.
if(missileBlend && spr->data.mo.flags & DDMF_BRIGHTSHADOW)
if(useSpriteAlpha)
{
alpha = 204; // 80 %.
additiveBlending = true;
if(missileBlend && spr->data.mo.flags & DDMF_BRIGHTSHADOW)
{
alpha = 204; // 80 %.
}
else if(spr->data.mo.flags & DDMF_SHADOW)
alpha = 51; // One third.
else if(spr->data.mo.flags & DDMF_ALTSHADOW)
alpha = 160; // Two thirds.
else
alpha = 255;

// Sprite has a custom alpha multiplier?
if(spr->data.mo.alpha >= 0)
alpha *= spr->data.mo.alpha;
}
else if(spr->data.mo.flags & DDMF_SHADOW)
alpha = 51; //85; // One third.
else if(spr->data.mo.flags & DDMF_ALTSHADOW)
alpha = 160; // Two thirds.
else
alpha = 255;

// Sprite has a custom alpha multiplier?
if(spr->data.mo.alpha >= 0)
alpha *= spr->data.mo.alpha;
if(missileBlend && spr->data.mo.flags & DDMF_BRIGHTSHADOW)
additiveBlending = true;

if(spr->data.mo.lightlevel < 0)
{
Expand Down Expand Up @@ -787,7 +797,7 @@ void Rend_RenderSprite(vissprite_t * spr)
// Change the blending mode.
gl.Func(DGL_BLENDING, DGL_SRC_ALPHA, DGL_ONE);
}
else if(noSpriteTrans)
else if(noSpriteTrans && alpha >= 250)
{
// Use the "no translucency" blending mode.
GL_BlendMode(BM_ZEROALPHA);
Expand Down

0 comments on commit 86ca3ba

Please sign in to comment.