mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
GL3: Bigger, fewer Lightmap textures, cleanups
if the lightmap textures are 1024x512 instead of 128x128, all original Q2 levels will only need one lightmap texture (instead of max 26 or so) and even maps that needed all 127 (the 128th was the dynamic lightmap) won't need more than 4. This should result in less glBindTexture() calls. (Note: When I wrote "1 lightmap texture" I meant 4, because where the old renderer dynamically blended the up to 4 lightmaps/surface, I put them in 4 textures that belong together and are alle passed to and blended in the fragment shader)
This commit is contained in:
parent
2e31ae0ec5
commit
4bc3a68699
7 changed files with 29 additions and 19 deletions
|
@ -176,10 +176,8 @@ typedef struct
|
|||
struct image_s * (EXPORT *DrawFindPic)(char *name);
|
||||
|
||||
void (EXPORT *DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
|
||||
//void (EXPORT *DrawPic) (int x, int y, char *name); - apparently not used anymore
|
||||
void (EXPORT *DrawPicScaled) (int x, int y, char *pic, float factor);
|
||||
void (EXPORT *DrawStretchPic) (int x, int y, int w, int h, char *name);
|
||||
void (EXPORT *DrawChar) (int x, int y, int c);
|
||||
void (EXPORT *DrawCharScaled)(int x, int y, int num, float scale);
|
||||
void (EXPORT *DrawTileClear) (int x, int y, int w, int h, char *name);
|
||||
void (EXPORT *DrawFill) (int x, int y, int w, int h, int c);
|
||||
|
|
|
@ -132,6 +132,7 @@ GL3_Bind(GLuint texnum)
|
|||
void
|
||||
GL3_BindLightmap(int lightmapnum)
|
||||
{
|
||||
int i=0;
|
||||
if(lightmapnum < 0 || lightmapnum >= MAX_LIGHTMAPS)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "WARNING: Invalid lightmapnum %i used!\n", lightmapnum);
|
||||
|
@ -144,14 +145,13 @@ GL3_BindLightmap(int lightmapnum)
|
|||
}
|
||||
|
||||
gl3state.currentlightmap = lightmapnum;
|
||||
GL3_SelectTMU(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, gl3state.lightmap_textureIDs[lightmapnum][0]);
|
||||
GL3_SelectTMU(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, gl3state.lightmap_textureIDs[lightmapnum][1]);
|
||||
GL3_SelectTMU(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, gl3state.lightmap_textureIDs[lightmapnum][2]);
|
||||
GL3_SelectTMU(GL_TEXTURE4);
|
||||
glBindTexture(GL_TEXTURE_2D, gl3state.lightmap_textureIDs[lightmapnum][3]);
|
||||
for(i=0; i<MAX_LIGHTMAPS_PER_SURFACE; ++i)
|
||||
{
|
||||
// this assumes that GL_TEXTURE<i+1> = GL_TEXTURE<i> + 1
|
||||
// at least for GL_TEXTURE0 .. GL_TEXTURE31 that's true
|
||||
GL3_SelectTMU(GL_TEXTURE1+i);
|
||||
glBindTexture(GL_TEXTURE_2D, gl3state.lightmap_textureIDs[lightmapnum][i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -241,7 +241,7 @@ GL3_LM_BeginBuildingLightmaps(gl3model_t *m)
|
|||
|
||||
gl3_newrefdef.lightstyles = lightstyles;
|
||||
|
||||
gl3_lms.current_lightmap_texture = 1;
|
||||
gl3_lms.current_lightmap_texture = 0;
|
||||
gl3_lms.internal_format = GL_LIGHTMAP_FORMAT;
|
||||
|
||||
// Note: the dynamic lightmap used to be initialized here, we don't use that anymore.
|
||||
|
|
|
@ -1503,7 +1503,10 @@ GL3_RenderFrame(refdef_t *fd)
|
|||
GL3_SetLightLevel();
|
||||
GL3_SetGL2D();
|
||||
|
||||
GL3_Draw_Flash(v_blend);
|
||||
if(v_blend[3] != 0.0f)
|
||||
{
|
||||
GL3_Draw_Flash(v_blend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -984,6 +984,8 @@ GL3_BeginRegistration(char *model)
|
|||
registration_sequence++;
|
||||
gl3_oldviewcluster = -1; /* force markleafs */
|
||||
|
||||
gl3state.currentlightmap = -1;
|
||||
|
||||
Com_sprintf(fullname, sizeof(fullname), "maps/%s.bsp", model);
|
||||
|
||||
/* explicitly free the old map if different
|
||||
|
|
|
@ -839,11 +839,16 @@ RecursiveWorldNode(mnode_t *node)
|
|||
}
|
||||
else
|
||||
{
|
||||
// calling RenderLightmappedPoly() here probably isn't optimal, rendering everything
|
||||
// through texturechains should be faster, because far less glBindTexture() is needed
|
||||
// (and it might allow batching the drawcalls of surfaces with the same texture)
|
||||
#if 0
|
||||
if(!(surf->flags & SURF_DRAWTURB))
|
||||
{
|
||||
RenderLightmappedPoly(surf);
|
||||
}
|
||||
else
|
||||
#endif // 0
|
||||
{
|
||||
/* the polygon is visible, so add it to the texture sorted chain */
|
||||
image = TextureAnimation(surf->texinfo);
|
||||
|
|
|
@ -70,7 +70,7 @@ enum {
|
|||
GL3_ATTRIB_TEXCOORD = 1, // for normal texture
|
||||
GL3_ATTRIB_LMTEXCOORD = 2, // for lightmap
|
||||
GL3_ATTRIB_COLOR = 3, // per-vertex color
|
||||
// TODO: more? maybe normal and color?
|
||||
// TODO: more? maybe normal
|
||||
};
|
||||
|
||||
// TODO: do we need the following configurable?
|
||||
|
@ -143,10 +143,12 @@ typedef struct
|
|||
} gl3Uni3D_t;
|
||||
|
||||
enum {
|
||||
BLOCK_WIDTH = 128,
|
||||
BLOCK_HEIGHT = 128,
|
||||
// width and height used to be 128, so now we should be able to get the same lightmap data
|
||||
// that used 32 lightmaps before into one, so 4 lightmaps should be enough
|
||||
BLOCK_WIDTH = 1024,
|
||||
BLOCK_HEIGHT = 512,
|
||||
LIGHTMAP_BYTES = 4,
|
||||
MAX_LIGHTMAPS = 128,
|
||||
MAX_LIGHTMAPS = 4,
|
||||
MAX_LIGHTMAPS_PER_SURFACE = MAXLIGHTMAPS // 4
|
||||
};
|
||||
|
||||
|
@ -160,9 +162,9 @@ typedef struct
|
|||
|
||||
unsigned char *d_16to8table;
|
||||
|
||||
// "So color textures start at 0, the dynamic lightmap texture is always 1024 and the static lighmap are 1025 up to 1036."
|
||||
// yes, dynamic lightmap is 1024, but I think there can be 127 dynamic lightmaps (MAX_LIGHTMAPS == 128)
|
||||
//int lightmap_textures;
|
||||
// each lightmap consists of 4 sub-lightmaps allowing changing shadows on the same surface
|
||||
// used for switching on/off light and stuff like that.
|
||||
// most surfaces only have one really and the remaining for are filled with dummy data
|
||||
GLuint lightmap_textureIDs[MAX_LIGHTMAPS][MAX_LIGHTMAPS_PER_SURFACE]; // instead of lightmap_textures+i use lightmap_textureIDs[i]
|
||||
|
||||
//int currenttextures[2];
|
||||
|
|
Loading…
Reference in a new issue