static int R_Shadow_CullFrustumSides(rtlight_t *rtlight, float size, float border)
{
int i;
- vec3_t p, n;
+ vec3_t o, p, n;
int sides = 0x3F, masks[6] = { 3<<4, 3<<4, 3<<0, 3<<0, 3<<2, 3<<2 };
float scale = (size - 2*border)/size, len;
float bias = border / (float)(size - border), dp, dn, ap, an;
// check if cone enclosing side would cross frustum plane
scale = 2 / (scale*scale + 2);
+ Matrix4x4_OriginFromMatrix(&rtlight->matrix_lighttoworld, o);
for (i = 0;i < 5;i++)
{
- if (PlaneDiff(rtlight->shadoworigin, &r_refdef.view.frustum[i]) > -0.03125)
+ if (PlaneDiff(o, &r_refdef.view.frustum[i]) > -0.03125)
continue;
Matrix4x4_Transform3x3(&rtlight->matrix_worldtolight, r_refdef.view.frustum[i].normal, n);
len = scale*VectorLength2(n);
if(n[1]*n[1] > len) sides &= n[1] < 0 ? ~(1<<2) : ~(2 << 2);
if(n[2]*n[2] > len) sides &= n[2] < 0 ? ~(1<<4) : ~(2 << 4);
}
- if (PlaneDiff(rtlight->shadoworigin, &r_refdef.view.frustum[4]) >= r_refdef.farclip - r_refdef.nearclip + 0.03125)
+ if (PlaneDiff(o, &r_refdef.view.frustum[4]) >= r_refdef.farclip - r_refdef.nearclip + 0.03125)
{
Matrix4x4_Transform3x3(&rtlight->matrix_worldtolight, r_refdef.view.frustum[4].normal, n);
- len = scale*VectorLength(n);
+ len = scale*VectorLength2(n);
if(n[0]*n[0] > len) sides &= n[0] >= 0 ? ~(1<<0) : ~(2 << 0);
if(n[1]*n[1] > len) sides &= n[1] >= 0 ? ~(1<<2) : ~(2 << 2);
if(n[2]*n[2] > len) sides &= n[2] >= 0 ? ~(1<<4) : ~(2 << 4);
{
int i;
float scale, size, radius, dot1, dot2;
+ prvm_vec3_t prvmshadowdir, prvmshadowfocus;
vec3_t shadowdir, shadowforward, shadowright, shadoworigin, shadowfocus, shadowmins, shadowmaxs;
entity_render_t *ent;
scale = r_shadow_shadowmapping_precision.value * r_shadows_shadowmapscale.value;
radius = 0.5f * size / scale;
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
dot1 = DotProduct(r_refdef.view.forward, shadowdir);
dot2 = DotProduct(r_refdef.view.up, shadowdir);
VectorMA(r_refdef.view.up, -dot2, shadowdir, shadowforward);
VectorNormalize(shadowforward);
CrossProduct(shadowdir, shadowforward, shadowright);
- Math_atov(r_shadows_focus.string, shadowfocus);
+ Math_atov(r_shadows_focus.string, prvmshadowfocus);
+ VectorCopy(prvmshadowfocus, shadowfocus);
VectorM(shadowfocus[0], r_refdef.view.right, shadoworigin);
VectorMA(shadoworigin, shadowfocus[1], r_refdef.view.up, shadoworigin);
VectorMA(shadoworigin, -shadowfocus[2], r_refdef.view.forward, shadoworigin);
vec3_t relativelightdirection, relativeforward, relativeright;
vec3_t relativeshadowmins, relativeshadowmaxs;
vec3_t shadowdir, shadowforward, shadowright, shadoworigin, shadowfocus;
+ prvm_vec3_t prvmshadowdir, prvmshadowfocus;
float m[12];
matrix4x4_t shadowmatrix, cameramatrix, mvpmatrix, invmvpmatrix, scalematrix, texmatrix;
r_viewport_t viewport;
r_shadow_shadowmap_parameters[2] = 1.0;
r_shadow_shadowmap_parameters[3] = bound(0.0f, 1.0f - r_shadows_darken.value, 1.0f);
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
- Math_atov(r_shadows_focus.string, shadowfocus);
+ Math_atov(r_shadows_focus.string, prvmshadowfocus);
+ VectorCopy(prvmshadowfocus, shadowfocus);
VectorM(shadowfocus[0], r_refdef.view.right, shadoworigin);
VectorMA(shadoworigin, shadowfocus[1], r_refdef.view.up, shadoworigin);
VectorMA(shadoworigin, -shadowfocus[2], r_refdef.view.forward, shadoworigin);
vec3_t relativelightdirection;
vec3_t relativeshadowmins, relativeshadowmaxs;
vec3_t tmp, shadowdir;
+ prvm_vec3_t prvmshadowdir;
if (!r_refdef.scene.numentities || !vid.stencil || (r_shadow_shadowmode != R_SHADOW_SHADOWMODE_STENCIL && r_shadows.integer != 1))
return;
// get shadow dir
if (r_shadows.integer == 2)
{
- Math_atov(r_shadows_throwdirection.string, shadowdir);
+ Math_atov(r_shadows_throwdirection.string, prvmshadowdir);
+ VectorCopy(prvmshadowdir, shadowdir);
VectorNormalize(shadowdir);
}
n = 0;
while (*s)
{
- t = s;
/*
+ t = s;
shadow = true;
for (;COM_Parse(t, true) && strcmp(
if (COM_Parse(t, true))
=============================================================================
*/
-void R_LightPoint(vec3_t color, const vec3_t p, const int flags)
+void R_LightPoint(float *color, const vec3_t p, const int flags)
{
int i, numlights, flag;
float f, relativepoint[3], dist, dist2, lightradius2;