+
+ shdata.uniform("world_eye_matrix", matrix);
+ shdata.uniform("eye_world_matrix", view_matrix);
+
+ update_frustum_planes();
+}
+
+void Camera::update_frustum_planes()
+{
+ // TODO Handle off-center and rotated frustums
+ if(is_orthographic())
+ {
+ frustum_planes[0] = Vector4(0, 1, 0, height);
+ frustum_planes[1] = Vector4(0, -1, 0, height);
+
+ frustum_planes[2] = Vector4(1, 0, 0, height*aspect);
+ frustum_planes[3] = Vector4(-1, 0, 0, height*aspect);
+ }
+ else
+ {
+ float y = tan(fov/2.0f);
+ float s = sqrt(y*y+1);
+ frustum_planes[0] = Vector4(0, 1/s, -y/s, 0);
+ frustum_planes[1] = Vector4(0, -1/s, -y/s, 0);
+
+ float x = y*aspect;
+ s = sqrt(x*x+1);
+ frustum_planes[2] = Vector4(1/s, 0, -x/s, 0);
+ frustum_planes[3] = Vector4(-1/s, 0, -x/s, 0);
+ }
+
+ frustum_planes[4] = Vector4(0, 0, 1, clip_far);
+ frustum_planes[5] = Vector4(0, 0, -1, -clip_near);
+
+ for(unsigned i=0; i<6; ++i)
+ {
+ Vector3 normal = frustum_planes[i].slice<3>(0);
+ normal = (matrix*compose(normal, 0.0f)).slice<3>(0);
+ frustum_planes[i] = compose(normal, frustum_planes[i].w-dot(normal, matrix.column(3).slice<3>(0)));
+ }
+}
+
+void Camera::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ shdata.set_debug_name(name+" [UBO]");
+#else
+ (void)name;
+#endif