OpenGL2: Add r_cubemapSize.

This commit is contained in:
SmileTheory 2015-12-24 16:34:58 -08:00
parent c3216f54d2
commit e2b2437966
5 changed files with 8 additions and 7 deletions

View file

@ -1764,7 +1764,7 @@ const void *RB_ExportCubemaps(const void *data)
if (cmd) if (cmd)
{ {
FBO_t *oldFbo = glState.currentFBO; FBO_t *oldFbo = glState.currentFBO;
int sideSize = CUBE_MAP_SIZE * CUBE_MAP_SIZE * 4; int sideSize = r_cubemapSize->integer * r_cubemapSize->integer * 4;
byte *cubemapPixels = ri.Malloc(sideSize * 6); byte *cubemapPixels = ri.Malloc(sideSize * 6);
int i, j; int i, j;
@ -1779,12 +1779,12 @@ const void *RB_ExportCubemaps(const void *data)
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
{ {
qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, cubemap->image->texnum, 0); qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + j, cubemap->image->texnum, 0);
qglReadPixels(0, 0, CUBE_MAP_SIZE, CUBE_MAP_SIZE, GL_RGBA, GL_UNSIGNED_BYTE, p); qglReadPixels(0, 0, r_cubemapSize->integer, r_cubemapSize->integer, GL_RGBA, GL_UNSIGNED_BYTE, p);
p += sideSize; p += sideSize;
} }
Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/%03d.dds", tr.world->baseName, i); Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/%03d.dds", tr.world->baseName, i);
R_SaveDDS(filename, cubemapPixels, CUBE_MAP_SIZE, CUBE_MAP_SIZE, 6); R_SaveDDS(filename, cubemapPixels, r_cubemapSize->integer, r_cubemapSize->integer, 6);
ri.Printf(PRINT_ALL, "Saved cubemap %d as %s\n", i, filename); ri.Printf(PRINT_ALL, "Saved cubemap %d as %s\n", i, filename);
} }

View file

@ -3074,7 +3074,7 @@ void R_RenderAllCubemaps(void)
for (i = 0; i < tr.numCubemaps; i++) for (i = 0; i < tr.numCubemaps; i++)
{ {
tr.cubemaps[i].image = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8); tr.cubemaps[i].image = R_CreateImage(va("*cubeMap%d", i), NULL, r_cubemapSize->integer, r_cubemapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8);
} }
for (i = 0; i < tr.numCubemaps; i++) for (i = 0; i < tr.numCubemaps; i++)

View file

@ -2841,7 +2841,7 @@ void R_CreateBuiltinImages( void ) {
if (r_cubeMapping->integer) if (r_cubeMapping->integer)
{ {
tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); tr.renderCubeImage = R_CreateImage("*renderCube", NULL, r_cubemapSize->integer, r_cubemapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat);
} }
} }
} }

View file

@ -142,6 +142,7 @@ cvar_t *r_specularMapping;
cvar_t *r_deluxeMapping; cvar_t *r_deluxeMapping;
cvar_t *r_parallaxMapping; cvar_t *r_parallaxMapping;
cvar_t *r_cubeMapping; cvar_t *r_cubeMapping;
cvar_t *r_cubemapSize;
cvar_t *r_specularIsMetallic; cvar_t *r_specularIsMetallic;
cvar_t *r_glossIsRoughness; cvar_t *r_glossIsRoughness;
cvar_t *r_baseNormalX; cvar_t *r_baseNormalX;
@ -1243,6 +1244,7 @@ void R_Register( void )
r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH );
r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubemapSize = ri.Cvar_Get( "r_cubemapSize", "128", CVAR_ARCHIVE | CVAR_LATCH );
r_specularIsMetallic = ri.Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_specularIsMetallic = ri.Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_glossIsRoughness = ri.Cvar_Get("r_glossIsRoughness", "0", CVAR_ARCHIVE | CVAR_LATCH); r_glossIsRoughness = ri.Cvar_Get("r_glossIsRoughness", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH );

View file

@ -54,8 +54,6 @@ typedef unsigned int glIndex_t;
#define MAX_CALC_PSHADOWS 64 #define MAX_CALC_PSHADOWS 64
#define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces #define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces
#define PSHADOW_MAP_SIZE 512 #define PSHADOW_MAP_SIZE 512
#define CUBE_MAP_MIPS 7
#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS)
#define USE_VERT_TANGENT_SPACE #define USE_VERT_TANGENT_SPACE
#define USE_OVERBRIGHT #define USE_OVERBRIGHT
@ -1792,6 +1790,7 @@ extern cvar_t *r_specularMapping;
extern cvar_t *r_deluxeMapping; extern cvar_t *r_deluxeMapping;
extern cvar_t *r_parallaxMapping; extern cvar_t *r_parallaxMapping;
extern cvar_t *r_cubeMapping; extern cvar_t *r_cubeMapping;
extern cvar_t *r_cubemapSize;
extern cvar_t *r_specularIsMetallic; extern cvar_t *r_specularIsMetallic;
extern cvar_t *r_glossIsRoughness; extern cvar_t *r_glossIsRoughness;
extern cvar_t *r_baseNormalX; extern cvar_t *r_baseNormalX;