Game Development Reference
In-Depth Information
// C++ pseudocode
Matrix Mirror = CreateMirrorMatrix(ReflectionPlaneWS);
Matrix ReflectView = Mirror * View;
Matrix ClipProjection = NearObliqueMatrix(ReflectionPlaneVS);
Matrix ViewProjection = View * ClipProjection;
// Image proxy specific
Vector ReflectViewOrigin = Mirror * ViewOrigin;
Matrix InverseReflectView = ReflectView.Inverse();
Vector ViewUp = -InverseReflectView * Vector(0,1,0);
// Following is done for each IP (Image proxy)
// Calc X and Y sprite vector based on option.
Vector YVector = IP->LocalToWorld * Vector(0, 1, 0);
if (IP->bCameraFacing) {
float ScaleFactor = YVector.Length();
YVector = CameraUp.Normalize() * ScaleFactor;
}
Vector CameraDirWS = (CameraWS - IP->Location).Normalize();
Vector XVector = IP->LocalToWorld * Vector(1, 0, 0);
if (IP->bCameraFacing || IP->bCameraFacingReflectionAxis) {
float ScaleFactor = XVector.Lenght();
XVector = CameraDir ˆ YVector;
XVector = XVector.Normalize() * ScaleFactor;
}
// Shader code
float4x4 LocalToWorld;
float4x4 ViewProjection;
float3 IPPosition;
VertexMain() {
float3 VPosition = IPPosition + InPosition.x * XVector -
InPosition.y * YVector;
float4 PositionSS = mul(ViewProjection , float4 (VPosition, 1));
OutPosition = PositionSS;
UVOut = UV;
}
float4 IPColor;
PixelMain() {}
OutColor = IPColor * tex2D(SpriteTexture , InUV);
}
Listing 1.2. Pseudocode for parallax-corrected rendering of image proxies.
A disturbing problem of naively rendering image proxies as presented here is
temporal aliasing. The low resolution of our textures (both 2D reflection textures
and image proxy textures) causes severe aliasing along the edges of image proxies,
especially when the camera moves near the boundaries of the geometry proxy.
To minimize aliasing we set the alpha value of image proxy texture borders to be
fully translucent, forcing us to render the image proxies as transparent objects
( Figure 1.5 ) . It would also be possible to set this value from within the shader.
 
 
Search Nedrilad ::




Custom Search