Additional clip plane to be used for mirrors and similar effects. Everything outside the plane is not rendered in the view. The plane is defined by a point and a normal vector. The portal_x, portal_y and portal_z parameters are the coordinates of the point, the pnormal_x, pnormal_y and pnormal_z parameters are the direction of the normal. Their default values define a horizontal plane through the level origin.





 A6    P 
 A7    C   P 


// Code to emulate a horizontal mirror by generating a mirrored camera view
VIEW view_mirror { layer = -1; };

function mfx_mirror()
// do nothing if mirror is already running
	if (view_mirror.visible == on) { return; }

	view_mirror.visible = on;
	view_mirror.noshadow = on;	// suppress shadows in the mirror
	view_mirror.nocull = on;    // view through walls
	view_mirror.portalclip = on; // clip at portal plane
	vec_set(view_mirror.portal_x,vector(0,0,my.z + my.max_z)); // at top entity position
	vec_set(view_mirror.pnormal_x,vector(0,0,1.0)); // horizontal plane
	while (view_mirror.visible == on)
		proc_late();	// place it at the end of the function list - the camera must be moved before
		view_mirror.genius = camera.genius;
		view_mirror.aspect = camera.aspect;
		view_mirror.arc    = camera.arc;
		view_mirror.fog_start = camera.fog_start;
		view_mirror.fog_end   = camera.fog_end;
		view_mirror.clip_far  = camera.clip_far * 0.5;
		view_mirror.clip_near = camera.clip_near * 2;
		view_mirror.x 	   = camera.x;
		view_mirror.y 	   = camera.y;
		view_mirror.z 	   = 2*view_mirror.portal_z-camera.z;	// move the camera at its mirror position
		view_mirror.pan    = camera.pan;
		view_mirror.tilt   = -camera.tilt;	// flip the vertical camera angle
		view_mirror.roll   = -camera.roll;

See also:

VIEW, layer, pos_x, pos_y, x, y, z, flags, vecPortal

► latest version online