1
0
forked from 0ad/0ad

Reflection and refraction cameras should now take more advantage of the textures' resolutions, by stretching the image according to the inverse of the screen's aspect ratio to cover it all without requiring a larger Field of View. This should result in higher-resolution reflections and refractions.

Also increased water repeat period slightly, to 17.

This was SVN commit r3919.
This commit is contained in:
Matei 2006-05-31 22:37:23 +00:00
parent 99e0dbddca
commit aa9a1c4f29
4 changed files with 21 additions and 10 deletions

View File

@ -103,12 +103,11 @@ class CCamera
// This is the orientation matrix. The inverse of this
// is the view matrix
CMatrix3D m_Orientation;
private:
// keep the projection matrix private
// so others can't fiddle with it.
// Should not be tweaked externally if possible
CMatrix3D m_ProjMat;
private:
float m_NearPlane;
float m_FarPlane;
float m_FOV;

View File

@ -15,7 +15,6 @@
#include "Quaternion.h"
#include "self_test.h"
CMatrix3D::CMatrix3D ()
{
}

View File

@ -1028,7 +1028,11 @@ void CRenderer::RenderReflections()
// Remember old camera
CCamera normalCamera = m_ViewCamera;
// Temporarily change the camera to one that is reflected
// Temporarily change the camera to one that is reflected.
// Also, for texturing purposes, make it render to a view port the size of the
// water texture, stretch the image according to our aspect ratio so it covers
// the whole screen despite being rendered into a square, and cover slightly more
// of the view so we can see wavy reflections of slightly off-screen objects.
m_ViewCamera.m_Orientation.Translate(0, -wm.m_WaterHeight, 0);
m_ViewCamera.m_Orientation.Scale(1, -1, 1);
m_ViewCamera.m_Orientation.Translate(0, wm.m_WaterHeight, 0);
@ -1038,7 +1042,10 @@ void CRenderer::RenderReflections()
vp.m_X = 0;
vp.m_Y = 0;
m_ViewCamera.SetViewPort(&vp);
m_ViewCamera.SetProjection(1, 5000, DEGTORAD(25));
m_ViewCamera.SetProjection(1, 5000, DEGTORAD(21)); // Slightly higher than view FOV of 20
CMatrix3D scaleMat;
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f);
m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat;
SetCamera(m_ViewCamera, m_CullCamera);
CVector4D camPlane(0, 1, 0, -wm.m_WaterHeight);
@ -1094,14 +1101,20 @@ void CRenderer::RenderRefractions()
// Remember old camera
CCamera normalCamera = m_ViewCamera;
// Temporarily change the camera to have a higher FOV (so we get bits on the edge of the view)
// Temporarily change the camera to make it render to a view port the size of the
// water texture, stretch the image according to our aspect ratio so it covers
// the whole screen despite being rendered into a square, and cover slightly more
// of the view so we can see wavy refractions of slightly off-screen objects.
SViewPort vp;
vp.m_Height = wm.m_RefractionTextureSize;
vp.m_Width = wm.m_RefractionTextureSize;
vp.m_X = 0;
vp.m_Y = 0;
m_ViewCamera.SetViewPort(&vp);
m_ViewCamera.SetProjection(1, 5000, DEGTORAD(25));
m_ViewCamera.SetProjection(1, 5000, DEGTORAD(21)); // Slightly higher than view FOV of 20
CMatrix3D scaleMat;
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f);
m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat;
SetCamera(m_ViewCamera, m_CullCamera);
CVector4D camPlane(0, 1, 0, -wm.m_WaterHeight);

View File

@ -53,7 +53,7 @@ WaterManager::WaterManager()
m_WaterTexTimer = 0.0;
m_Shininess = 200.0f;
m_Waviness = 2.9f;
m_RepeatPeriod = 16.0f;
m_RepeatPeriod = 17.0f;
for (uint i = 0; i < ARRAY_SIZE(m_WaterTexture); i++)
m_WaterTexture[i] = 0;