int r_view_width;
int r_view_height;
int r_view_depth;
-float r_view_fov_x;
-float r_view_fov_y;
matrix4x4_t r_view_matrix;
//
refdef_t r_refdef;
cvar_t r_showtris = {0, "r_showtris", "0"};
+cvar_t r_shownormals = {0, "r_shownormals", "0"};
cvar_t r_drawentities = {0, "r_drawentities","1"};
cvar_t r_drawviewmodel = {0, "r_drawviewmodel","1"};
cvar_t r_speeds = {0, "r_speeds","0"};
cvar_t r_waterscroll = {CVAR_SAVE, "r_waterscroll", "1"};
cvar_t r_bloom = {CVAR_SAVE, "r_bloom", "0"};
-cvar_t r_bloom_intensity = {CVAR_SAVE, "r_bloom_intensity", "2"};
-cvar_t r_bloom_blur = {CVAR_SAVE, "r_bloom_blur", "8"};
+cvar_t r_bloom_intensity = {CVAR_SAVE, "r_bloom_intensity", "1.5"};
+cvar_t r_bloom_blur = {CVAR_SAVE, "r_bloom_blur", "4"};
cvar_t r_bloom_resolution = {CVAR_SAVE, "r_bloom_resolution", "320"};
-cvar_t r_bloom_power = {CVAR_SAVE, "r_bloom_power", "4"};
+cvar_t r_bloom_power = {CVAR_SAVE, "r_bloom_power", "2"};
cvar_t r_smoothnormals_areaweighting = {0, "r_smoothnormals_areaweighting", "1"};
if (l >= 0 && !strcmp(entname + l, ".bsp"))
{
strcpy(entname + l, ".ent");
- if ((entities = (char *)FS_LoadFile(entname, tempmempool, true)))
+ if ((entities = (char *)FS_LoadFile(entname, tempmempool, true, NULL)))
{
CL_ParseEntityLump(entities);
Mem_Free(entities);
// FIXME: move this to client?
FOG_registercvars();
Cvar_RegisterVariable(&r_showtris);
+ Cvar_RegisterVariable(&r_shownormals);
Cvar_RegisterVariable(&r_drawentities);
Cvar_RegisterVariable(&r_drawviewmodel);
Cvar_RegisterVariable(&r_speeds);
Matrix4x4_ToVectors(&r_view_matrix, r_viewforward, r_viewleft, r_viewup, r_vieworigin);
VectorNegate(r_viewleft, r_viewright);
- // LordHavoc: note to all quake engine coders, the special case for 90
- // degrees assumed a square view (wrong), so I removed it, Quake2 has it
- // disabled as well.
+#if 0
+ frustum[0].normal[0] = 0 - 1.0 / r_refdef.frustum_x;
+ frustum[0].normal[1] = 0 - 0;
+ frustum[0].normal[2] = -1 - 0;
+ frustum[1].normal[0] = 0 + 1.0 / r_refdef.frustum_x;
+ frustum[1].normal[1] = 0 + 0;
+ frustum[1].normal[2] = -1 + 0;
+ frustum[2].normal[0] = 0 - 0;
+ frustum[2].normal[1] = 0 - 1.0 / r_refdef.frustum_y;
+ frustum[2].normal[2] = -1 - 0;
+ frustum[3].normal[0] = 0 + 0;
+ frustum[3].normal[1] = 0 + 1.0 / r_refdef.frustum_y;
+ frustum[3].normal[2] = -1 + 0;
+#endif
- // rotate R_VIEWFORWARD right by FOV_X/2 degrees
- RotatePointAroundVector( frustum[0].normal, r_viewup, r_viewforward, -(90 - r_view_fov_x / 2));
+#if 0
+ zNear = 1.0;
+ nudge = 1.0 - 1.0 / (1<<23);
+ frustum[4].normal[0] = 0 - 0;
+ frustum[4].normal[1] = 0 - 0;
+ frustum[4].normal[2] = -1 - -nudge;
+ frustum[4].dist = 0 - -2 * zNear * nudge;
+ frustum[5].normal[0] = 0 + 0;
+ frustum[5].normal[1] = 0 + 0;
+ frustum[5].normal[2] = -1 + -nudge;
+ frustum[5].dist = 0 + -2 * zNear * nudge;
+#endif
+
+
+
+#if 0
+ frustum[0].normal[0] = m[3] - m[0];
+ frustum[0].normal[1] = m[7] - m[4];
+ frustum[0].normal[2] = m[11] - m[8];
+ frustum[0].dist = m[15] - m[12];
+
+ frustum[1].normal[0] = m[3] + m[0];
+ frustum[1].normal[1] = m[7] + m[4];
+ frustum[1].normal[2] = m[11] + m[8];
+ frustum[1].dist = m[15] + m[12];
+
+ frustum[2].normal[0] = m[3] - m[1];
+ frustum[2].normal[1] = m[7] - m[5];
+ frustum[2].normal[2] = m[11] - m[9];
+ frustum[2].dist = m[15] - m[13];
+
+ frustum[3].normal[0] = m[3] + m[1];
+ frustum[3].normal[1] = m[7] + m[5];
+ frustum[3].normal[2] = m[11] + m[9];
+ frustum[3].dist = m[15] + m[13];
+
+ frustum[4].normal[0] = m[3] - m[2];
+ frustum[4].normal[1] = m[7] - m[6];
+ frustum[4].normal[2] = m[11] - m[10];
+ frustum[4].dist = m[15] - m[14];
+
+ frustum[5].normal[0] = m[3] + m[2];
+ frustum[5].normal[1] = m[7] + m[6];
+ frustum[5].normal[2] = m[11] + m[10];
+ frustum[5].dist = m[15] + m[14];
+#endif
+
+
+
+ VectorMAM(1, r_viewforward, 1.0 / -r_refdef.frustum_x, r_viewleft, frustum[0].normal);
+ VectorMAM(1, r_viewforward, 1.0 / r_refdef.frustum_x, r_viewleft, frustum[1].normal);
+ VectorMAM(1, r_viewforward, 1.0 / -r_refdef.frustum_y, r_viewup, frustum[2].normal);
+ VectorMAM(1, r_viewforward, 1.0 / r_refdef.frustum_y, r_viewup, frustum[3].normal);
+ VectorCopy(r_viewforward, frustum[4].normal);
+ VectorNormalize(frustum[0].normal);
+ VectorNormalize(frustum[1].normal);
+ VectorNormalize(frustum[2].normal);
+ VectorNormalize(frustum[3].normal);
frustum[0].dist = DotProduct (r_vieworigin, frustum[0].normal);
+ frustum[1].dist = DotProduct (r_vieworigin, frustum[1].normal);
+ frustum[2].dist = DotProduct (r_vieworigin, frustum[2].normal);
+ frustum[3].dist = DotProduct (r_vieworigin, frustum[3].normal);
+ frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + 1.0f;
PlaneClassify(&frustum[0]);
+ PlaneClassify(&frustum[1]);
+ PlaneClassify(&frustum[2]);
+ PlaneClassify(&frustum[3]);
+ PlaneClassify(&frustum[4]);
+
+ // LordHavoc: note to all quake engine coders, Quake had a special case
+ // for 90 degrees which assumed a square view (wrong), so I removed it,
+ // Quake2 has it disabled as well.
+
+ // rotate R_VIEWFORWARD right by FOV_X/2 degrees
+ //RotatePointAroundVector( frustum[0].normal, r_viewup, r_viewforward, -(90 - r_refdef.fov_x / 2));
+ //frustum[0].dist = DotProduct (r_vieworigin, frustum[0].normal);
+ //PlaneClassify(&frustum[0]);
// rotate R_VIEWFORWARD left by FOV_X/2 degrees
- RotatePointAroundVector( frustum[1].normal, r_viewup, r_viewforward, (90 - r_view_fov_x / 2));
- frustum[1].dist = DotProduct (r_vieworigin, frustum[1].normal);
- PlaneClassify(&frustum[1]);
+ //RotatePointAroundVector( frustum[1].normal, r_viewup, r_viewforward, (90 - r_refdef.fov_x / 2));
+ //frustum[1].dist = DotProduct (r_vieworigin, frustum[1].normal);
+ //PlaneClassify(&frustum[1]);
// rotate R_VIEWFORWARD up by FOV_X/2 degrees
- RotatePointAroundVector( frustum[2].normal, r_viewleft, r_viewforward, -(90 - r_view_fov_y / 2));
- frustum[2].dist = DotProduct (r_vieworigin, frustum[2].normal);
- PlaneClassify(&frustum[2]);
+ //RotatePointAroundVector( frustum[2].normal, r_viewleft, r_viewforward, -(90 - r_refdef.fov_y / 2));
+ //frustum[2].dist = DotProduct (r_vieworigin, frustum[2].normal);
+ //PlaneClassify(&frustum[2]);
// rotate R_VIEWFORWARD down by FOV_X/2 degrees
- RotatePointAroundVector( frustum[3].normal, r_viewleft, r_viewforward, (90 - r_view_fov_y / 2));
- frustum[3].dist = DotProduct (r_vieworigin, frustum[3].normal);
- PlaneClassify(&frustum[3]);
+ //RotatePointAroundVector( frustum[3].normal, r_viewleft, r_viewforward, (90 - r_refdef.fov_y / 2));
+ //frustum[3].dist = DotProduct (r_vieworigin, frustum[3].normal);
+ //PlaneClassify(&frustum[3]);
// nearclip plane
- VectorCopy(r_viewforward, frustum[4].normal);
- frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + 1.0f;
- PlaneClassify(&frustum[4]);
+ //VectorCopy(r_viewforward, frustum[4].normal);
+ //frustum[4].dist = DotProduct (r_vieworigin, frustum[4].normal) + 1.0f;
+ //PlaneClassify(&frustum[4]);
}
static void R_BlendView(void)
{
+ int screenwidth, screenheight;
+ qboolean dobloom;
+ qboolean doblend;
rmeshstate_t m;
- if (r_refdef.viewblend[3] < 0.01f && !r_bloom.integer)
+ // set the (poorly named) screenwidth and screenheight variables to
+ // a power of 2 at least as large as the screen, these will define the
+ // size of the texture to allocate
+ for (screenwidth = 1;screenwidth < vid.width;screenwidth *= 2);
+ for (screenheight = 1;screenheight < vid.height;screenheight *= 2);
+
+ doblend = r_refdef.viewblend[3] >= 0.01f;
+ dobloom = r_bloom.integer && screenwidth <= gl_max_texture_size && screenheight <= gl_max_texture_size && r_bloom_resolution.value >= 32 && r_bloom_power.integer >= 1 && r_bloom_power.integer < 100 && r_bloom_blur.value >= 0 && r_bloom_blur.value < 512;
+
+ if (!dobloom && !doblend)
return;
GL_SetupView_Mode_Ortho(0, 0, 1, 1, -10, 100);
varray_vertex3f[3] = 1;varray_vertex3f[4] = 0;varray_vertex3f[5] = 0;
varray_vertex3f[6] = 1;varray_vertex3f[7] = 1;varray_vertex3f[8] = 0;
varray_vertex3f[9] = 0;varray_vertex3f[10] = 1;varray_vertex3f[11] = 0;
- if (r_bloom.integer && r_bloom_resolution.value >= 32 && r_bloom_power.integer >= 1 && r_bloom_power.integer < 100 && r_bloom_blur.value >= 0 && r_bloom_blur.value < 512)
+ if (dobloom)
{
- int screenwidth, screenheight, bloomwidth, bloomheight, x, dobloomblend, range;
+ int bloomwidth, bloomheight, x, dobloomblend, range;
float xoffset, yoffset, r;
renderstats.bloom++;
- // set the (poorly named) screenwidth and screenheight variables to
- // a power of 2 at least as large as the screen, these will define the
- // size of the texture to allocate
- for (screenwidth = 1;screenwidth < vid.width;screenwidth *= 2);
- for (screenheight = 1;screenheight < vid.height;screenheight *= 2);
// allocate textures as needed
if (!r_bloom_texture_screen)
r_bloom_texture_screen = R_LoadTexture2D(r_main_texturepool, "screen", screenwidth, screenheight, NULL, TEXTYPE_RGBA, TEXF_FORCENEAREST | TEXF_CLAMP | TEXF_ALWAYSPRECACHE, NULL);
renderstats.bloom_drawpixels += r_view_width * r_view_height;
}
}
- if (r_refdef.viewblend[3] >= 0.01f)
+ if (doblend)
{
// apply a color tint to the whole view
memset(&m, 0, sizeof(m));
r_view_x = bound(0, r_refdef.x, vid.width - r_refdef.width);
r_view_y = bound(0, r_refdef.y, vid.height - r_refdef.height);
r_view_z = 0;
- r_view_fov_x = bound(1, r_refdef.fov_x, 170);
- r_view_fov_y = bound(1, r_refdef.fov_y, 170);
r_view_matrix = r_refdef.viewentitymatrix;
GL_ColorMask(r_refdef.colormask[0], r_refdef.colormask[1], r_refdef.colormask[2], 1);
r_rtworld = r_shadow_realtime_world.integer;
r_farclip = R_FarClip(r_vieworigin, r_viewforward, 768.0f) + 256.0f;
if (r_rtworldshadows || r_rtdlightshadows)
- GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_view_fov_x, r_view_fov_y, 1.0f);
+ GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.frustum_x, r_refdef.frustum_y, 1.0f);
else
- GL_SetupView_Mode_Perspective(r_view_fov_x, r_view_fov_y, 1.0f, r_farclip);
+ GL_SetupView_Mode_Perspective(r_refdef.frustum_x, r_refdef.frustum_y, 1.0f, r_farclip);
GL_SetupView_Orientation_FromEntity(&r_view_matrix);
GL_Color(r, g, b, a);
}
-
static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *texture, int texturenumsurfaces, const msurface_t **texturesurfacelist, const vec3_t modelorg)
{
int texturesurfaceindex;
}
}
}
+ if (r_shownormals.integer && !r_showtrispass)
+ {
+ int j, k;
+ float v[3];
+ GL_DepthTest(true);
+ GL_DepthMask(texture->currentlayers->depthmask);
+ GL_BlendFunc(texture->currentlayers->blendfunc1, texture->currentlayers->blendfunc2);
+ memset(&m, 0, sizeof(m));
+ R_Mesh_State(&m);
+ for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
+ {
+ surface = texturesurfacelist[texturesurfaceindex];
+ RSurf_SetVertexPointer(ent, texture, surface, modelorg);
+ if (!rsurface_svector3f)
+ {
+ rsurface_svector3f = varray_svector3f;
+ rsurface_tvector3f = varray_tvector3f;
+ rsurface_normal3f = varray_normal3f;
+ Mod_BuildTextureVectorsAndNormals(surface->num_firstvertex, surface->num_vertices, surface->num_triangles, rsurface_vertex3f, surface->groupmesh->data_texcoordtexture2f, surface->groupmesh->data_element3i + surface->num_firsttriangle * 3, rsurface_svector3f, rsurface_tvector3f, rsurface_normal3f, r_smoothnormals_areaweighting.integer);
+ }
+ GL_Color(1, 0, 0, 1);
+ qglBegin(GL_LINES);
+ for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++)
+ {
+ VectorCopy(rsurface_vertex3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_svector3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ GL_Color(0, 0, 1, 1);
+ for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++)
+ {
+ VectorCopy(rsurface_vertex3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_tvector3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ GL_Color(0, 1, 0, 1);
+ for (j = 0, k = surface->num_firstvertex;j < surface->num_vertices;j++, k++)
+ {
+ VectorCopy(rsurface_vertex3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ VectorMA(v, 8, rsurface_normal3f + k * 3, v);
+ qglVertex3f(v[0], v[1], v[2]);
+ }
+ qglEnd();
+ }
+ }
}
if (texture->textureflags & Q3TEXTUREFLAG_TWOSIDED)
qglEnable(GL_CULL_FACE);