diff --git a/include/r_local.h b/include/r_local.h index 7663b513f..5f9eb2ef0 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -139,6 +139,7 @@ extern vec3_t r_worldmodelorg; extern mat4_t glsl_projection; extern mat4_t glsl_view; +void R_SetFrustum (void); void R_SpriteBegin (void); void R_SpriteEnd (void); diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index d24b7945f..919aa20d3 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -332,46 +332,6 @@ R_DrawViewModel (void) qfglDepthRange (gldepthmin, gldepthmax); } -static inline int -SignbitsForPlane (plane_t *out) -{ - int bits, j; - - // for fast box on planeside test - - bits = 0; - for (j = 0; j < 3; j++) { - if (out->normal[j] < 0) - bits |= 1 << j; - } - return bits; -} - -static void -R_SetFrustum (void) -{ - int i; - - // rotate VPN right by FOV_X/2 degrees - RotatePointAroundVector (frustum[0].normal, vup, vpn, - -(90 - r_refdef.fov_x / 2)); - // rotate VPN left by FOV_X/2 degrees - RotatePointAroundVector (frustum[1].normal, vup, vpn, - 90 - r_refdef.fov_x / 2); - // rotate VPN up by FOV_Y/2 degrees - RotatePointAroundVector (frustum[2].normal, vright, vpn, - 90 - r_refdef.fov_y / 2); - // rotate VPN down by FOV_Y/2 degrees - RotatePointAroundVector (frustum[3].normal, vright, vpn, - -(90 - r_refdef.fov_y / 2)); - - for (i = 0; i < 4; i++) { - frustum[i].type = PLANE_ANYZ; - frustum[i].dist = DotProduct (r_origin, frustum[i].normal); - frustum[i].signbits = SignbitsForPlane (&frustum[i]); - } -} - void gl_R_SetupFrame (void) { diff --git a/libs/video/renderer/glsl/glsl_alias.c b/libs/video/renderer/glsl/glsl_alias.c index 8414cd579..297e3c266 100644 --- a/libs/video/renderer/glsl/glsl_alias.c +++ b/libs/video/renderer/glsl/glsl_alias.c @@ -145,10 +145,11 @@ calc_lighting (entity_t *ent, float *ambient, float *shadelight, unsigned i; float add; vec3_t dist; + int light; VectorSet ( -1, 0, 0, lightvec); //FIXME - *ambient = max (R_LightPoint (ent->origin), max (ent->model->min_light, - ent->min_light) * 128); + light = R_LightPoint (ent->origin); + *ambient = max (light, max (ent->model->min_light, ent->min_light) * 128); *shadelight = *ambient; for (i = 0; i < r_maxdlights; i++) { diff --git a/libs/video/renderer/glsl/glsl_main.c b/libs/video/renderer/glsl/glsl_main.c index 7e87ab5d9..ca95f538f 100644 --- a/libs/video/renderer/glsl/glsl_main.c +++ b/libs/video/renderer/glsl/glsl_main.c @@ -108,6 +108,7 @@ glsl_R_SetupFrame (void) VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); + R_SetFrustum (); r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model); } diff --git a/libs/video/renderer/r_main.c b/libs/video/renderer/r_main.c index 4ed543f86..0d38123d3 100644 --- a/libs/video/renderer/r_main.c +++ b/libs/video/renderer/r_main.c @@ -85,3 +85,43 @@ int d_lightstylevalue[256]; // 8.8 fraction of base light value byte color_white[4] = { 255, 255, 255, 0 }; // alpha will be explicitly set byte color_black[4] = { 0, 0, 0, 0 }; // alpha will be explicitly set + +static inline int +SignbitsForPlane (plane_t *out) +{ + int bits, j; + + // for fast box on planeside test + + bits = 0; + for (j = 0; j < 3; j++) { + if (out->normal[j] < 0) + bits |= 1 << j; + } + return bits; +} + +void +R_SetFrustum (void) +{ + int i; + + // rotate VPN right by FOV_X/2 degrees + RotatePointAroundVector (frustum[0].normal, vup, vpn, + -(90 - r_refdef.fov_x / 2)); + // rotate VPN left by FOV_X/2 degrees + RotatePointAroundVector (frustum[1].normal, vup, vpn, + 90 - r_refdef.fov_x / 2); + // rotate VPN up by FOV_Y/2 degrees + RotatePointAroundVector (frustum[2].normal, vright, vpn, + 90 - r_refdef.fov_y / 2); + // rotate VPN down by FOV_Y/2 degrees + RotatePointAroundVector (frustum[3].normal, vright, vpn, + -(90 - r_refdef.fov_y / 2)); + + for (i = 0; i < 4; i++) { + frustum[i].type = PLANE_ANYZ; + frustum[i].dist = DotProduct (r_origin, frustum[i].normal); + frustum[i].signbits = SignbitsForPlane (&frustum[i]); + } +} diff --git a/libs/video/renderer/sw/sw_rmisc.c b/libs/video/renderer/sw/sw_rmisc.c index 547492bfb..82a3cd648 100644 --- a/libs/video/renderer/sw/sw_rmisc.c +++ b/libs/video/renderer/sw/sw_rmisc.c @@ -240,6 +240,7 @@ R_SetupFrame (void) VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); + R_SetFrustum (); // current viewleaf r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model); diff --git a/libs/video/renderer/sw32/sw32_rmisc.c b/libs/video/renderer/sw32/sw32_rmisc.c index e1fbd19ba..13bff55b5 100644 --- a/libs/video/renderer/sw32/sw32_rmisc.c +++ b/libs/video/renderer/sw32/sw32_rmisc.c @@ -237,6 +237,7 @@ sw32_R_SetupFrame (void) VectorCopy (r_refdef.vieworg, r_origin); AngleVectors (r_refdef.viewangles, vpn, vright, vup); + R_SetFrustum (); // current viewleaf r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model);