Bugfixed and flipped environment probe glReadPixels output

This commit is contained in:
Robert Beckebans 2021-03-23 09:36:39 +01:00
parent 2391ba1b43
commit 8c397e9463
3 changed files with 27 additions and 17 deletions

View file

@ -642,6 +642,7 @@ byte* R_MipMap( const byte* in, int width, int height );
void R_BlendOverTexture( byte* data, int pixelCount, const byte blend[4] );
void R_HorizontalFlip( byte* data, int width, int height );
void R_VerticalFlip( byte* data, int width, int height );
void R_VerticalFlipRGB16F( byte* data, int width, int height );
void R_RotatePic( byte* data, int width );
void R_ApplyCubeMapTransforms( int i, byte* data, int size );

View file

@ -528,6 +528,31 @@ void R_VerticalFlip( byte* data, int width, int height )
}
}
// RB: halfFloat_t helper
struct ColorRGB16F
{
uint16 red;
uint16 green;
uint16 blue;
};
void R_VerticalFlipRGB16F( byte* data, int width, int height )
{
int i, j;
ColorRGB16F temp;
for( i = 0; i < width; i++ )
{
for( j = 0; j < height / 2; j++ )
{
temp = *( ( ColorRGB16F* )data + j * width + i );
*( ( ColorRGB16F* )data + j * width + i ) = *( ( ColorRGB16F* )data + ( height - 1 - j ) * width + i );
*( ( ColorRGB16F* )data + ( height - 1 - j ) * width + i ) = temp;
}
}
}
void R_RotatePic( byte* data, int width )
{
int i, j;

View file

@ -838,23 +838,7 @@ void R_ReadTiledPixels( int width, int height, byte* buffer, renderView_t* ref =
glPixelStorei( GL_PACK_ROW_LENGTH, RADIANCE_CUBEMAP_SIZE );
glReadPixels( 0, 0, w, h, GL_RGB, GL_HALF_FLOAT, buffer );
#if 0
// TODO vertical flip with half floats
{
int i, j;
uint64 temp;
for( i = 0 ; i < width ; i++ )
{
for( j = 0 ; j < height / 2 ; j++ )
{
temp = *( ( uint64* )buffer + j * width + i );
*( ( uint64* )buffer + j * width + i ) = *( ( uint64* )buffer + ( height - 1 - j ) * width + i );
*( ( uint64* )buffer + ( height - 1 - j ) * width + i ) = temp;
}
}
}
#endif
R_VerticalFlipRGB16F( buffer, w, h );
Framebuffer::Unbind();
}