mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-11 15:47:55 +00:00
ref_soft: colormap support, basic studiomodel lighting
This commit is contained in:
parent
35e42a2295
commit
b35415637b
3
r_draw.c
3
r_draw.c
@ -299,6 +299,9 @@ R_Set2DMode
|
|||||||
void R_Set2DMode( qboolean enable )
|
void R_Set2DMode( qboolean enable )
|
||||||
{
|
{
|
||||||
vid.color = COLOR_WHITE;
|
vid.color = COLOR_WHITE;
|
||||||
|
vid.is2d = enable;
|
||||||
|
vid.alpha = 7;
|
||||||
|
|
||||||
if( enable )
|
if( enable )
|
||||||
{
|
{
|
||||||
// if( glState.in2DMode )
|
// if( glState.in2DMode )
|
||||||
|
32
r_glblit.c
32
r_glblit.c
@ -133,6 +133,7 @@ void R_BuildBlendMaps()
|
|||||||
{
|
{
|
||||||
unsigned int r1, g1, b1;
|
unsigned int r1, g1, b1;
|
||||||
unsigned int r2, g2, b2;
|
unsigned int r2, g2, b2;
|
||||||
|
unsigned int i, j;
|
||||||
|
|
||||||
FOR_EACH_COLOR(1)FOR_EACH_COLOR(2)
|
FOR_EACH_COLOR(1)FOR_EACH_COLOR(2)
|
||||||
{
|
{
|
||||||
@ -169,6 +170,37 @@ void R_BuildBlendMaps()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
for( i = 0; i < 8192; i++ )
|
||||||
|
{
|
||||||
|
unsigned int r, g, b;
|
||||||
|
uint color = i << 3;
|
||||||
|
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( j = 0; j < 32; j++)
|
||||||
|
{
|
||||||
|
unsigned int index2 = j << 13;
|
||||||
|
unsigned int major, minor;
|
||||||
|
r = r1 * j / 32;
|
||||||
|
g = g1 * j / 32;
|
||||||
|
b = b1 * j / 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);
|
||||||
|
|
||||||
|
vid.colormap[index2|index1] = major << 8 | (minor & 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_AllocScreen();
|
void R_AllocScreen();
|
||||||
|
@ -472,6 +472,8 @@ colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lspot, vec3_t
|
|||||||
{
|
{
|
||||||
colorVec light = R_LightVecInternal( start, end, lspot, lvec );
|
colorVec light = R_LightVecInternal( start, end, lspot, lvec );
|
||||||
|
|
||||||
|
light.r = light.g = light.b = 255;
|
||||||
|
|
||||||
if( lspot != NULL && lvec != NULL ) // CVAR_TO_BOOL( r_lighting_extended ) &&
|
if( lspot != NULL && lvec != NULL ) // CVAR_TO_BOOL( r_lighting_extended ) &&
|
||||||
{
|
{
|
||||||
// trying to get light from ceiling (but ignore gradient analyze)
|
// trying to get light from ceiling (but ignore gradient analyze)
|
||||||
|
@ -133,7 +133,7 @@ typedef struct vrect_s
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
pixel_t *buffer; // invisible buffer
|
pixel_t *buffer; // invisible buffer
|
||||||
pixel_t *colormap; // 256 * VID_GRADES size
|
pixel_t colormap[32*8192]; // 8192 * light levels
|
||||||
//pixel_t *alphamap; // 256 * 256 translucency map
|
//pixel_t *alphamap; // 256 * 256 translucency map
|
||||||
#ifdef SEPARATE_BLIT
|
#ifdef SEPARATE_BLIT
|
||||||
pixel_t screen_minor[256];
|
pixel_t screen_minor[256];
|
||||||
@ -146,6 +146,7 @@ typedef struct
|
|||||||
byte modmap[256*256];
|
byte modmap[256*256];
|
||||||
byte alphamap[8*256*256];
|
byte alphamap[8*256*256];
|
||||||
pixel_t color;
|
pixel_t color;
|
||||||
|
qboolean is2d;
|
||||||
byte alpha;
|
byte alpha;
|
||||||
|
|
||||||
// maybe compute colormask for minor byte?
|
// maybe compute colormask for minor byte?
|
||||||
|
24
r_main.c
24
r_main.c
@ -517,6 +517,7 @@ R_SetupFrustum
|
|||||||
*/
|
*/
|
||||||
void R_SetupFrustum( void )
|
void R_SetupFrustum( void )
|
||||||
{
|
{
|
||||||
|
AngleVectors( RI.viewangles, RI.vforward, RI.vright, RI.vup );
|
||||||
#if 0
|
#if 0
|
||||||
ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
ref_overview_t *ov = gEngfuncs.GetOverviewParms();
|
||||||
|
|
||||||
@ -1034,20 +1035,27 @@ void R_DrawEntitiesOnList( void )
|
|||||||
//R_DrawAliasModel( RI.currententity );
|
//R_DrawAliasModel( RI.currententity );
|
||||||
break;
|
break;
|
||||||
case mod_studio:
|
case mod_studio:
|
||||||
//R_DrawStudioModel( RI.currententity );
|
R_DrawStudioModel( RI.currententity );
|
||||||
/*{finalvert_t fv[3];
|
#if 0
|
||||||
|
// gradient debug (for colormap testing)
|
||||||
|
{finalvert_t fv[3];
|
||||||
void R_AliasSetUpTransform (void);
|
void R_AliasSetUpTransform (void);
|
||||||
extern void (*d_pdrawspans)(void *);
|
extern void (*d_pdrawspans)(void *);
|
||||||
extern void R_PolysetFillSpans8 ( void * );
|
extern void R_PolysetFillSpans8 ( void * );
|
||||||
d_pdrawspans = R_PolysetFillSpans8;
|
d_pdrawspans = R_PolysetFillSpans8;
|
||||||
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
//RI.currententity = gEngfuncs.GetEntityByIndex(0);
|
||||||
R_AliasSetUpTransform();
|
R_AliasSetUpTransform();
|
||||||
R_SetupFinalVert( &fv[0], -10, -10, 5, 0, 0, 0);
|
image_t *image = R_GetTexture(GL_LoadTexture("gfx/env/desertbk", NULL, 0, 0));
|
||||||
R_SetupFinalVert( &fv[1], -10, 10, 10, 0, 0, 0);
|
r_affinetridesc.pskin = image->pixels[0];
|
||||||
R_SetupFinalVert( &fv[2], 10, 10, -10, 0, 0, 0);
|
r_affinetridesc.skinwidth = image->width;
|
||||||
R_RenderTriangle( &fv );
|
r_affinetridesc.skinheight = image->height;
|
||||||
}*/
|
R_SetupFinalVert( &fv[0], 0, -50, 50, 31 << 8, 0, 0);
|
||||||
R_DrawStudioModel( RI.currententity );
|
R_SetupFinalVert( &fv[1], 0, 50, 50, 0 << 8, image->width, 0);
|
||||||
|
R_SetupFinalVert( &fv[2], 0, 0, 0, 0 << 8, image->width/2, image->height);
|
||||||
|
R_RenderTriangle( &fv[0], &fv[1], &fv[2] );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
15
r_polyse.c
15
r_polyse.c
@ -1145,11 +1145,11 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
|
|||||||
#else
|
#else
|
||||||
void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
|
void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
|
||||||
{
|
{
|
||||||
int color;
|
//int color;
|
||||||
int lcount;
|
int lcount;
|
||||||
// FIXME: do z buffering
|
// FIXME: do z buffering
|
||||||
|
|
||||||
color = d_aflatcolor++ * 10;
|
//color = d_aflatcolor++ * 10;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1191,8 +1191,15 @@ void R_PolysetFillSpans8 (spanpackage_t *pspanpackage)
|
|||||||
/*if(r_newrefdef.rdflags & RDF_IRGOGGLES && RI.currententity->flags & RF_IR_VISIBLE)
|
/*if(r_newrefdef.rdflags & RDF_IRGOGGLES && RI.currententity->flags & RF_IR_VISIBLE)
|
||||||
*lpdest = ((byte *)vid.colormap)[irtable[*lptex]];
|
*lpdest = ((byte *)vid.colormap)[irtable[*lptex]];
|
||||||
else*/
|
else*/
|
||||||
*lpdest = *lptex; //((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
|
//*lpdest = *lptex; //((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
|
||||||
//PGM
|
uint src = *lptex;
|
||||||
|
//*lpdest = //vid.colormap[src & 0xff00|(llight>>8)] << 8 | (src & llight & 0xff) | ((src & 0xff) >> 3);
|
||||||
|
// very dirty, maybe need dual colormap?
|
||||||
|
//*lpdest = (vid.colormap[src >> 8 | (llight & 0xFF00)] << 8) | src & 0xff;
|
||||||
|
// 13 bit lighting, 32 light levels
|
||||||
|
*lpdest = vid.colormap[(src >> 3) | ((llight & 0x1F00) << 5)] | src & 7;
|
||||||
|
|
||||||
|
//PGM
|
||||||
*lpz = lzi >> 16;
|
*lpz = lzi >> 16;
|
||||||
}
|
}
|
||||||
lpdest++;
|
lpdest++;
|
||||||
|
@ -1770,6 +1770,7 @@ static void R_StudioSetColorBegin(short *ptricmds, vec3_t *pstudionorms )
|
|||||||
color[3] = tr.blend * 255;
|
color[3] = tr.blend * 255;
|
||||||
VectorCopy( (byte*)&RI.currententity->curstate.rendercolor, color );
|
VectorCopy( (byte*)&RI.currententity->curstate.rendercolor, color );
|
||||||
//pglColor4ubv( color );
|
//pglColor4ubv( color );
|
||||||
|
TriColor4ub(color[0], color[1], color[2], color[3]);
|
||||||
}
|
}
|
||||||
else _TriColor4f( lv[0], lv[1], lv[2], tr.blend );
|
else _TriColor4f( lv[0], lv[1], lv[2], tr.blend );
|
||||||
}
|
}
|
||||||
|
17
r_triapi.c
17
r_triapi.c
@ -27,6 +27,7 @@ finalvert_t triv[3];
|
|||||||
int vertcount, n;
|
int vertcount, n;
|
||||||
int mode;
|
int mode;
|
||||||
short s,t;
|
short s,t;
|
||||||
|
uint light;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============================================================
|
===============================================================
|
||||||
@ -145,17 +146,25 @@ void _TriColor4f( float rr, float gg, float bb, float aa )
|
|||||||
unsigned int major, minor;
|
unsigned int major, minor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//gEngfuncs.Con_Printf("%d\n", vid.alpha);
|
||||||
|
|
||||||
|
light = (rr + gg + bb) * 31 / 3;
|
||||||
|
if( light > 31 )
|
||||||
|
light = 31;
|
||||||
|
|
||||||
|
if( !vid.is2d )
|
||||||
|
return;
|
||||||
|
|
||||||
vid.alpha = aa * 7;
|
vid.alpha = aa * 7;
|
||||||
if( vid.alpha > 7 )
|
if( vid.alpha > 7 )
|
||||||
vid.alpha = 7;
|
vid.alpha = 7;
|
||||||
//gEngfuncs.Con_Printf("%d\n", vid.alpha);
|
|
||||||
|
|
||||||
if( rr == 1 && gg == 1 && bb == 1 )
|
if( rr == 1 && gg == 1 && bb == 1 )
|
||||||
{
|
{
|
||||||
vid.color = COLOR_WHITE;
|
vid.color = COLOR_WHITE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rr * 31, g = gg * 63, b = bb * 31;
|
r = rr * 31, g = gg * 63, b = bb * 31;
|
||||||
|
|
||||||
|
|
||||||
@ -235,7 +244,7 @@ void TriVertex3f( float x, float y, float z )
|
|||||||
{
|
{
|
||||||
if( mode == TRI_TRIANGLE_FAN )
|
if( mode == TRI_TRIANGLE_FAN )
|
||||||
{
|
{
|
||||||
R_SetupFinalVert( &triv[vertcount], x, y, z, 0,s,t);
|
R_SetupFinalVert( &triv[vertcount], x, y, z, light << 8,s,t);
|
||||||
vertcount++;
|
vertcount++;
|
||||||
if( vertcount >= 3 )
|
if( vertcount >= 3 )
|
||||||
{
|
{
|
||||||
@ -246,7 +255,7 @@ void TriVertex3f( float x, float y, float z )
|
|||||||
}
|
}
|
||||||
if( mode == TRI_TRIANGLE_STRIP )
|
if( mode == TRI_TRIANGLE_STRIP )
|
||||||
{
|
{
|
||||||
R_SetupFinalVert( &triv[n], x, y, z, 0,s,t);
|
R_SetupFinalVert( &triv[n], x, y, z, light << 8,s,t);
|
||||||
n++;
|
n++;
|
||||||
vertcount++;
|
vertcount++;
|
||||||
if( n == 3 )
|
if( n == 3 )
|
||||||
|
Loading…
Reference in New Issue
Block a user