Browse Source

ref_soft: improve alpha map

pull/2/head
mittorn 6 years ago
parent
commit
29c2169012
  1. 4
      r_draw.c
  2. 48
      r_glblit.c
  3. 4
      r_local.h
  4. 10
      r_poly.c
  5. 2
      r_surf.c

4
r_draw.c

@ -166,10 +166,10 @@ void R_DrawStretchPicImplementation (int x, int y, int w, int h, int s1, int t1, @@ -166,10 +166,10 @@ void R_DrawStretchPicImplementation (int x, int y, int w, int h, int s1, int t1,
pixel_t screen = dest[u];
dest[u] = vid.addmap[src & 0xff00|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff) >> 0);
}
else if( alpha < 7) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
else if( alpha < 0) // && (vid.rendermode == kRenderTransAlpha || vid.rendermode == kRenderTransTexture ) )
{
pixel_t screen = dest[u]; // | 0xff & screen & src ;
dest[u] = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
dest[u] = BLEND_ALPHA( alpha, src, screen);//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) >> 3 | ((src & 0xff) >> 3);
}
else

48
r_glblit.c

@ -159,7 +159,7 @@ void R_BuildBlendMaps() @@ -159,7 +159,7 @@ void R_BuildBlendMaps()
b = b1 * b2 / MASK(2);
vid.modmap[index2|index1] = r << (2 + 3) | g << 2 | b;
#if 0
for( a = 0; a < 8; a++ )
{
r = r1 * (7 - a) / 7 + r2 * a / 7;
@ -168,7 +168,7 @@ void R_BuildBlendMaps() @@ -168,7 +168,7 @@ void R_BuildBlendMaps()
//if( b == 1 ) b = 0;
vid.alphamap[a << 16|index2|index1] = r << (2 + 3) | g << 2 | b;
}
#endif
}
for( i = 0; i < 8192; i++ )
{
@ -201,6 +201,50 @@ void R_BuildBlendMaps() @@ -201,6 +201,50 @@ void R_BuildBlendMaps()
vid.colormap[index2|index1] = major << 8 | (minor & 0xFF);
}
}
#if 1
for( i = 0; i < 1024; i++ )
{
unsigned int r, g, b;
uint color = i << 6;
uint m = color >> 8;
uint j = color & 0xff;
r1 = ((m >> (8 - 3) )<< 2 ) & MASK(5);
g1 = ((m >> (8 - 3 - 3)) << 3) & MASK(6);
b1 = ((m >> (8 - 3 - 3 - 2)) << 3) & MASK(5);
r1 |= MOVE_BIT(j, 5, 1) | MOVE_BIT(j, 2, 0);
g1 |= MOVE_BIT(j, 7, 2) | MOVE_BIT(j, 4, 1) | MOVE_BIT(j, 1, 0);
b1 |= MOVE_BIT(j, 6, 2) | MOVE_BIT(j, 3, 1) | MOVE_BIT(j, 0, 0);
unsigned short index1 = i;
FOR_EACH_COLOR(2)
{
unsigned int index2 = (r2 << (2 + 3) | g2 << 2 | b2) << 10;
unsigned int k;
for( k = 0; k < 3; k++ )
{
unsigned int major, minor;
unsigned int a = k + 1;
r = r1 * (7 - a) / 7 + (r2 << 2) * a / 7;
g = g1 * (7 - a) / 7 + (g2 << 3) * a / 7;
b = b1 * (7 - a) / 7 + (b2 << 3) * a / 7;
ASSERT( b < 32 );
major = (((r >> 2) & MASK(3)) << 5) |( (( (g >> 3) & MASK(3)) << 2 ) )| (((b >> 3) & MASK(2)));
// save minor GBRGBRGB
minor = MOVE_BIT(r,1,5) | MOVE_BIT(r,0,2) | MOVE_BIT(g,2,7) | MOVE_BIT(g,1,4) | MOVE_BIT(g,0,1) | MOVE_BIT(b,2,6)| MOVE_BIT(b,1,3)|MOVE_BIT(b,0,0);
minor = minor & ~0x3f;
vid.alphamap[k << 18|index2|index1] = major << 8 | (minor & 0xFF);
}
}
}
#endif
}
void R_AllocScreen();

4
r_local.h

@ -144,7 +144,7 @@ typedef struct @@ -144,7 +144,7 @@ typedef struct
#endif
byte addmap[256*256];
byte modmap[256*256];
byte alphamap[8*256*256];
pixel_t alphamap[3*1024*256];
pixel_t color;
qboolean is2d;
byte alpha;
@ -1349,6 +1349,8 @@ void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textured ); @@ -1349,6 +1349,8 @@ void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textured );
void R_SetUpWorldTransform (void);
#define BLEND_ALPHA_LOW(alpha, src, screen) (vid.alphamap[(alpha << 18) |( (src & 0xff00) << 2) | (screen >> 6)] | screen & 0x3f)
#define BLEND_ALPHA(alpha, src, dst) alpha > 3?BLEND_ALPHA_LOW(7 - 1 - alpha, dst,src):BLEND_ALPHA_LOW(alpha-1, src, dst)
//
// engine callbacks

10
r_poly.c

@ -253,7 +253,7 @@ void R_DrawSpanletTurbulentBlended66( void ) @@ -253,7 +253,7 @@ void R_DrawSpanletTurbulentBlended66( void )
pixel_t screen = *s_spanletvars.pdest;
pixel_t src = btemp;
byte alpha = 5;
*s_spanletvars.pdest = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff));
*s_spanletvars.pdest = BLEND_ALPHA( alpha, src, screen);//vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff) | ((src & 0xff));
}
s_spanletvars.izi += s_spanletvars.izistep;
@ -282,7 +282,7 @@ void R_DrawSpanletTurbulentBlended33( void ) @@ -282,7 +282,7 @@ void R_DrawSpanletTurbulentBlended33( void )
pixel_t screen = *s_spanletvars.pdest;
pixel_t src = btemp;
byte alpha = 2;
*s_spanletvars.pdest = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff)| ((src & 0xff));
*s_spanletvars.pdest = BLEND_ALPHA( alpha, src, screen);
}
s_spanletvars.izi += s_spanletvars.izistep;
@ -317,7 +317,7 @@ void R_DrawSpanlet33( void ) @@ -317,7 +317,7 @@ void R_DrawSpanlet33( void )
pixel_t screen = *s_spanletvars.pdest;
pixel_t src = btemp;
byte alpha = 2;
*s_spanletvars.pdest = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff)| ((src & 0xff));
*s_spanletvars.pdest = BLEND_ALPHA( alpha, src, screen);
}
}
@ -336,7 +336,7 @@ void R_DrawSpanletConstant33( void ) @@ -336,7 +336,7 @@ void R_DrawSpanletConstant33( void )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = vid.alphamap[r_polyblendcolor+*s_spanletvars.pdest*256];
//*s_spanletvars.pdest = BLEND_ALPHA( alpha, src, screen);
}
s_spanletvars.izi += s_spanletvars.izistep;
@ -368,7 +368,7 @@ void R_DrawSpanlet66( void ) @@ -368,7 +368,7 @@ void R_DrawSpanlet66( void )
pixel_t screen = *s_spanletvars.pdest;
pixel_t src = btemp;
byte alpha = 5;
*s_spanletvars.pdest = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0xff)| ((src & 0xff));
*s_spanletvars.pdest = BLEND_ALPHA( alpha, src, screen);
}
}

2
r_surf.c

@ -1081,7 +1081,7 @@ void R_DrawSurfaceDecals() @@ -1081,7 +1081,7 @@ void R_DrawSurfaceDecals()
pixel_t screen = dest[u]; // | 0xff & screen & src ;
if( screen == TRANSPARENT_COLOR )
continue;
dest[u] = vid.alphamap[( alpha << 16)|(src & 0xff00)|(screen>>8)] << 8 | (screen & 0x7f) >> 3 | ((src & 0xff));
dest[u] = BLEND_ALPHA( alpha, src, screen);
}
else

Loading…
Cancel
Save