portal_x
pnormal_x
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.
Remarks:
- The PORTALCLIP flag must be set for
the clip plane to become active.
- For using the view as a mirror, render it to a target
bmap and
apply this bmap to the mirror object.
- Place a mirror view on a negative layer in order to render it
before the camera view and prevent 'trailing' artifacts. For the
same reason, use proc_late() for moving the view.
- In A6, the surface Mirror flag
automatically sets the current view's portal_x and pnormal_x vectors
when the mirror surface is visible. This automatic feature won't
be used by future versions that render levels from meshes,
not from surfaces.
- Microsoft has the following comment for using clip planes in DirectX:
"When the fixed function pipeline is used
the plane equations are assumed to be in world space. When the programmable
pipeline is used the plane equations are assumed to be in the clipping
space." This euphemism expresses that clip
planes won't work for shaders and
BEAM and STREAK
particles. The engine overcomes
that for all objects above and below the clip plane. The only problems
can occur when objects with shaders penetrate
the clip plane. Therefore,
either use the NOSHADER and NOPARTICLES flags
to suppress the rendering of penetrating shaders in a mirror view, or implement a clipping algorithm in the shader through vecPortal.
- Clip planes are not supported by some old 3D cards (GeForce4 or
below). On such cards, clipping is performed by software. Software
clipping however can not split meshes. Thus on old 3D cards meshes
won't clip on mirror planes, leading to mirror faults
when meshes penetrate the mirror plane.
Type:
VECTOR
Edition:
A6 P
A7 C P
Example:
// 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;
wait(1);
}
}
See also:
VIEW, layer, pos_x,
pos_y, x,
y, z, flags, vecPortal
► latest
version online