Add true color support to voxel renderer
This commit is contained in:
parent
0cea344dce
commit
5a85fabfa6
5 changed files with 83 additions and 3 deletions
|
|
@ -187,6 +187,7 @@ void FSoftwareRenderer::RemapVoxels()
|
|||
{
|
||||
for (unsigned i=0; i<Voxels.Size(); i++)
|
||||
{
|
||||
Voxels[i]->CreateBgraSlabData();
|
||||
Voxels[i]->Remap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -538,6 +538,18 @@ namespace swrenderer
|
|||
}
|
||||
z2a[xxx] = MIN<int>(z2, dadmost[lxt + xxx]);
|
||||
}
|
||||
|
||||
const uint8_t *columnColors = col;
|
||||
bool bgra = viewport->RenderTarget->IsBgra();
|
||||
if (bgra)
|
||||
{
|
||||
// The true color slab data array is identical, except its using uint32 instead of uint8.
|
||||
//
|
||||
// We can find the same slab column by calculating the offset from the start of SlabData
|
||||
// and use that to offset into the BGRA version of the same data.
|
||||
columnColors = (const uint8_t *)(&mip->SlabDataBgra[0] + (ptrdiff_t)(col - mip->SlabData));
|
||||
}
|
||||
|
||||
// Find top and bottom pixels that match and draw them as one strip
|
||||
for (int xxl = 0, xxr; xxl < stripwidth; )
|
||||
{
|
||||
|
|
@ -559,7 +571,7 @@ namespace swrenderer
|
|||
{
|
||||
drawerargs.SetDest(lxt + x, z1);
|
||||
drawerargs.SetCount(z2 - z1);
|
||||
drawerargs.DrawVoxelColumn(thread, yplc[xxl], yinc, col, zleng);
|
||||
drawerargs.DrawVoxelColumn(thread, yplc[xxl], yinc, columnColors, zleng);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -499,8 +499,19 @@ namespace swrenderer
|
|||
|
||||
void SpriteDrawerArgs::DrawVoxelColumn(RenderThread *thread, fixed_t vPos, fixed_t vStep, const uint8_t *voxels, int voxelsCount)
|
||||
{
|
||||
dc_iscale = vStep;
|
||||
dc_texturefrac = vPos;
|
||||
if (RenderViewport::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
double v = vPos / (double)voxelsCount / FRACUNIT;
|
||||
double vstep = vStep / (double)voxelsCount / FRACUNIT;
|
||||
dc_texturefrac = (int)(v * (1 << 30));
|
||||
dc_iscale = (int)(vstep * (1 << 30));
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_texturefrac = vPos;
|
||||
dc_iscale = vStep;
|
||||
}
|
||||
|
||||
dc_texturefracx = 0;
|
||||
dc_source = voxels;
|
||||
dc_source2 = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue