I'm actually trying to do the reflection map for my water component, but even following the riemer's tutorial about reflection map the formulas provided doens't work. http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/Reflection_map.php
I've read somewhere on the Internet that riemer uses Z-axis as UpVector, and I'm using the Y-axis instead.
So my system for now is somethink like this:
private void DrawReflectionMap()
{
this.GraphicsDevice.SetRenderTarget(this.reflectionMap);
this.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
if (this.CameraPosition.Y > this.Options.Height)
{
Matrix reflectionMatrix = Matrix.Identity;
// Camera position
Vector3 reflectionCameraPosition = this.camera.Position;
reflectionCameraPosition.Y = -this.camera.Position.Y + this.Options.Height * 2;
// Camera target
Vector3 reflectionCameraTarget = this.camera.TargetPosition;
reflectionCameraTarget.Y = -this.camera.TargetPosition.Y + this.Options.Height * 2;
Vector3 cameraRight = Vector3.Transform(new Vector3(1, 0, 0), this.camera.Rotation);
Vector3 invUpVector = Vector3.Cross(new Vector3(1, 0, 0), reflectionCameraTarget - reflectionCameraPosition);
reflectionMatrix = Matrix.CreateLookAt(reflectionCameraPosition, reflectionCameraTarget, invUpVector);
Plane _reflectionPlane = this.CreatePlane(this.Options.Height - 0.5f, new Vector3(0, -1, 0), reflectionMatrix, true);
if (this.Options.Draw != null)
this.Options.Draw(reflectionMatrix, true, _reflectionPlane);
}
this.GraphicsDevice.SetRenderTarget(null);
}
and there is my camera: http://pastebin.com/hK9fi5DV
When I run all of this, I got this:
As you can see, it seems the reflection map is not in the right side and when I move my camera, the reflection map also moves thru the edges of the texture...
Do you have an idea from where this problem could come?
Thanks.
