Matrix4x4_Transform4 (&v->projectmatrix, temp, out);
iw = 1.0f / out[3];
out[0] = v->x + (out[0] * iw + 1.0f) * v->width * 0.5f;
- out[1] = v->y + v->height - (out[1] * iw + 1.0f) * v->height * 0.5f;
+
+ // for an odd reason, inverting this is wrong for R_Shadow_ScissorForBBox (we then get badly scissored lights)
+ //out[1] = v->y + v->height - (out[1] * iw + 1.0f) * v->height * 0.5f;
+ out[1] = v->y + (out[1] * iw + 1.0f) * v->height * 0.5f;
+
out[2] = v->z + (out[2] * iw + 1.0f) * v->depth * 0.5f;
}
// now convert the scissor rectangle to integer screen coordinates
ix1 = (int)(x1 - 1.0f);
- iy1 = vid.height - (int)(y2 - 1.0f);
+ //iy1 = vid.height - (int)(y2 - 1.0f);
+ //iy1 = r_refdef.view.viewport.width + 2 * r_refdef.view.viewport.x - (int)(y2 - 1.0f);
+ iy1 = (int)(y1 - 1.0f);
ix2 = (int)(x2 + 1.0f);
- iy2 = vid.height - (int)(y1 + 1.0f);
+ //iy2 = vid.height - (int)(y1 + 1.0f);
+ //iy2 = r_refdef.view.viewport.height + 2 * r_refdef.view.viewport.y - (int)(y1 + 1.0f);
+ iy2 = (int)(y2 + 1.0f);
//Con_Printf("%f %f %f %f\n", x1, y1, x2, y2);
// clamp it to the screen