mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 23:02:01 +00:00
OpenGL2: Parse radius entries from misc_cubemap entities.
This commit is contained in:
parent
b52ede0445
commit
f9c72eee69
6 changed files with 32 additions and 19 deletions
|
@ -482,8 +482,9 @@ void RB_BeginDrawingView (void) {
|
|||
// FIXME: hack for cubemap testing
|
||||
if (tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo)
|
||||
{
|
||||
cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex];
|
||||
//qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0);
|
||||
qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0);
|
||||
qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->image->texnum, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1311,9 +1312,11 @@ const void *RB_DrawSurfs( const void *data ) {
|
|||
|
||||
if (glRefConfig.framebufferObject && tr.renderCubeFbo && backEnd.viewParms.targetFbo == tr.renderCubeFbo)
|
||||
{
|
||||
cubemap_t *cubemap = &tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex];
|
||||
|
||||
FBO_Bind(NULL);
|
||||
GL_SelectTexture(TB_CUBEMAP);
|
||||
GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP);
|
||||
GL_BindToTMU(cubemap->image, TB_CUBEMAP);
|
||||
qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP);
|
||||
GL_SelectTexture(0);
|
||||
}
|
||||
|
@ -1724,7 +1727,7 @@ const void *RB_PostProcess(const void *data)
|
|||
{
|
||||
VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256);
|
||||
//FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0);
|
||||
FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1], NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0);
|
||||
FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1].image, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2996,16 +2996,17 @@ void R_LoadCubemapEntities(char *cubemapEntityName)
|
|||
return;
|
||||
|
||||
tr.numCubemaps = numCubemaps;
|
||||
tr.cubemapOrigins = ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low);
|
||||
tr.cubemaps = ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low);
|
||||
tr.cubemaps = ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low);
|
||||
memset(tr.cubemaps, 0, tr.numCubemaps * sizeof(*tr.cubemaps));
|
||||
|
||||
numCubemaps = 0;
|
||||
while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars))
|
||||
{
|
||||
int i;
|
||||
qboolean isCubemap = qfalse;
|
||||
qboolean positionSet = qfalse;
|
||||
qboolean originSet = qfalse;
|
||||
vec3_t origin;
|
||||
float parallaxRadius = 1000.0f;
|
||||
|
||||
for (i = 0; i < numSpawnVars; i++)
|
||||
{
|
||||
|
@ -3015,14 +3016,19 @@ void R_LoadCubemapEntities(char *cubemapEntityName)
|
|||
if (!Q_stricmp(spawnVars[i][0], "origin"))
|
||||
{
|
||||
sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]);
|
||||
positionSet = qtrue;
|
||||
originSet = qtrue;
|
||||
}
|
||||
else if (!Q_stricmp(spawnVars[i][0], "radius"))
|
||||
{
|
||||
sscanf(spawnVars[i][1], "%f", ¶llaxRadius);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCubemap && positionSet)
|
||||
if (isCubemap && originSet)
|
||||
{
|
||||
//ri.Printf(PRINT_ALL, "cubemap at %f %f %f\n", origin[0], origin[1], origin[2]);
|
||||
VectorCopy(origin, tr.cubemapOrigins[numCubemaps]);
|
||||
VectorCopy(origin, tr.cubemaps[numCubemaps].origin);
|
||||
tr.cubemaps[numCubemaps].parallaxRadius = parallaxRadius;
|
||||
numCubemaps++;
|
||||
}
|
||||
}
|
||||
|
@ -3068,7 +3074,7 @@ void R_RenderAllCubemaps(void)
|
|||
|
||||
for (i = 0; i < tr.numCubemaps; i++)
|
||||
{
|
||||
tr.cubemaps[i] = 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, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8);
|
||||
}
|
||||
|
||||
for (i = 0; i < tr.numCubemaps; i++)
|
||||
|
|
|
@ -471,7 +471,7 @@ int R_CubemapForPoint( vec3_t point )
|
|||
vec3_t diff;
|
||||
vec_t length;
|
||||
|
||||
VectorSubtract(point, tr.cubemapOrigins[i], diff);
|
||||
VectorSubtract(point, tr.cubemaps[i].origin, diff);
|
||||
length = DotProduct(diff, diff);
|
||||
|
||||
if (shortest > length)
|
||||
|
|
|
@ -60,6 +60,12 @@ typedef unsigned int glIndex_t;
|
|||
#define USE_VERT_TANGENT_SPACE
|
||||
#define USE_OVERBRIGHT
|
||||
|
||||
typedef struct cubemap_s {
|
||||
vec3_t origin;
|
||||
float parallaxRadius;
|
||||
image_t *image;
|
||||
} cubemap_t;
|
||||
|
||||
typedef struct dlight_s {
|
||||
vec3_t origin;
|
||||
vec3_t color; // range from 0.0 to 1.0, should be color normalized
|
||||
|
@ -1560,8 +1566,7 @@ typedef struct {
|
|||
int fatLightmapStep;
|
||||
|
||||
int numCubemaps;
|
||||
vec3_t *cubemapOrigins;
|
||||
image_t **cubemaps;
|
||||
cubemap_t *cubemaps;
|
||||
|
||||
trRefEntity_t *currentEntity;
|
||||
trRefEntity_t worldEntity; // point currentEntity at this when rendering world
|
||||
|
|
|
@ -2862,7 +2862,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene )
|
|||
|
||||
memset( &refdef, 0, sizeof( refdef ) );
|
||||
refdef.rdflags = 0;
|
||||
VectorCopy(tr.cubemapOrigins[cubemapIndex], refdef.vieworg);
|
||||
VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg);
|
||||
|
||||
switch(cubemapSide)
|
||||
{
|
||||
|
|
|
@ -1375,15 +1375,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer)
|
||||
{
|
||||
vec4_t vec;
|
||||
cubemap_t *cubemap = &tr.cubemaps[input->cubemapIndex - 1];
|
||||
|
||||
GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP);
|
||||
GL_BindToTMU( cubemap->image, TB_CUBEMAP);
|
||||
|
||||
vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.or.origin[0];
|
||||
vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.or.origin[1];
|
||||
vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.or.origin[2];
|
||||
VectorSubtract(cubemap->origin, backEnd.viewParms.or.origin, vec);
|
||||
vec[3] = 1.0f;
|
||||
|
||||
VectorScale4(vec, 1.0f / 1000.0f, vec);
|
||||
VectorScale4(vec, 1.0f / cubemap->parallaxRadius, vec);
|
||||
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue