Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/Renderer.cpp
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include "graphics/Model.h" | #include "graphics/Model.h" | ||||
#include "graphics/ModelDef.h" | #include "graphics/ModelDef.h" | ||||
#include "graphics/ParticleManager.h" | #include "graphics/ParticleManager.h" | ||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/ShaderManager.h" | #include "graphics/ShaderManager.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/Texture.h" | #include "graphics/Texture.h" | ||||
#include "graphics/TextureManager.h" | #include "graphics/TextureManager.h" | ||||
#include "graphics/WaterManager.h" | |||||
#include "renderer/HWLightingModelRenderer.h" | #include "renderer/HWLightingModelRenderer.h" | ||||
#include "renderer/InstancingModelRenderer.h" | #include "renderer/InstancingModelRenderer.h" | ||||
#include "renderer/ModelRenderer.h" | #include "renderer/ModelRenderer.h" | ||||
#include "renderer/OverlayRenderer.h" | #include "renderer/OverlayRenderer.h" | ||||
#include "renderer/ParticleRenderer.h" | #include "renderer/ParticleRenderer.h" | ||||
#include "renderer/PostprocManager.h" | #include "renderer/PostprocManager.h" | ||||
#include "renderer/RenderingOptions.h" | #include "renderer/RenderingOptions.h" | ||||
#include "renderer/RenderModifiers.h" | #include "renderer/RenderModifiers.h" | ||||
#include "renderer/ShadowMap.h" | #include "renderer/ShadowMap.h" | ||||
#include "renderer/SilhouetteRenderer.h" | #include "renderer/SilhouetteRenderer.h" | ||||
#include "renderer/SkyManager.h" | #include "renderer/SkyManager.h" | ||||
#include "renderer/TerrainOverlay.h" | #include "renderer/TerrainOverlay.h" | ||||
#include "renderer/TerrainRenderer.h" | #include "renderer/TerrainRenderer.h" | ||||
#include "renderer/TimeManager.h" | #include "renderer/TimeManager.h" | ||||
#include "renderer/VertexBufferManager.h" | #include "renderer/VertexBufferManager.h" | ||||
#include "renderer/WaterManager.h" | #include "renderer/WaterRendering.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
struct SScreenRect | struct SScreenRect | ||||
{ | { | ||||
GLint x1, y1, x2, y2; | GLint x1, y1, x2, y2; | ||||
}; | }; | ||||
/////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////// | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | public: | ||||
bool ShadersDirty; | bool ShadersDirty; | ||||
/// Table to display renderer stats in-game via profile system | /// Table to display renderer stats in-game via profile system | ||||
CRendererStatsTable profileTable; | CRendererStatsTable profileTable; | ||||
/// Shader manager | /// Shader manager | ||||
CShaderManager shaderManager; | CShaderManager shaderManager; | ||||
/// Water manager | WaterRendering waterRendering; | ||||
WaterManager waterManager; | |||||
/// Sky manager | /// Sky manager | ||||
SkyManager skyManager; | SkyManager skyManager; | ||||
/// Texture manager | /// Texture manager | ||||
CTextureManager textureManager; | CTextureManager textureManager; | ||||
/// Terrain renderer | /// Terrain renderer | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
}; | }; | ||||
/////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////// | ||||
// CRenderer constructor | // CRenderer constructor | ||||
CRenderer::CRenderer() | CRenderer::CRenderer() | ||||
{ | { | ||||
m = new CRendererInternals; | m = new CRendererInternals; | ||||
m_WaterManager = &m->waterManager; | |||||
m_SkyManager = &m->skyManager; | m_SkyManager = &m->skyManager; | ||||
g_ProfileViewer.AddRootTable(&m->profileTable); | g_ProfileViewer.AddRootTable(&m->profileTable); | ||||
m_Width = 0; | m_Width = 0; | ||||
m_Height = 0; | m_Height = 0; | ||||
m_TerrainRenderMode = SOLID; | m_TerrainRenderMode = SOLID; | ||||
m_WaterRenderMode = SOLID; | m_WaterRenderMode = SOLID; | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | void CRenderer::Resize(int width, int height) | ||||
// need to recreate the shadow map object to resize the shadow texture | // need to recreate the shadow map object to resize the shadow texture | ||||
m->shadow.RecreateTexture(); | m->shadow.RecreateTexture(); | ||||
m_Width = width; | m_Width = width; | ||||
m_Height = height; | m_Height = height; | ||||
m->postprocManager.Resize(); | m->postprocManager.Resize(); | ||||
m_WaterManager->Resize(); | m->waterRendering.OnRendererResize(); | ||||
} | } | ||||
////////////////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////////////////// | ||||
// SetRenderPath: Select the preferred render path. | // SetRenderPath: Select the preferred render path. | ||||
// This may only be called before Open(), because the layout of vertex arrays and other | // This may only be called before Open(), because the layout of vertex arrays and other | ||||
// data may depend on the chosen render path. | // data may depend on the chosen render path. | ||||
void CRenderer::SetRenderPath(RenderPath rp) | void CRenderer::SetRenderPath(RenderPath rp) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | void CRenderer::SetObliqueFrustumClipping(CCamera& camera, const CVector4D& worldPlane) const | ||||
matrix[14] = c.W; | matrix[14] = c.W; | ||||
// Load it back into the camera | // Load it back into the camera | ||||
camera.SetProjection(matrix); | camera.SetProjection(matrix); | ||||
} | } | ||||
void CRenderer::ComputeReflectionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const | void CRenderer::ComputeReflectionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const | ||||
{ | { | ||||
WaterManager& wm = m->waterManager; | const WaterManager& wm = g_Game->GetView()->GetWaterManager(); | ||||
ENSURE(m_ViewCamera.GetProjectionType() == CCamera::PERSPECTIVE); | ENSURE(m_ViewCamera.GetProjectionType() == CCamera::PERSPECTIVE); | ||||
float fov = m_ViewCamera.GetFOV(); | float fov = m_ViewCamera.GetFOV(); | ||||
// Expand fov slightly since ripples can reflect parts of the scene that | // Expand fov slightly since ripples can reflect parts of the scene that | ||||
// are slightly outside the normal camera view, and we want to avoid any | // are slightly outside the normal camera view, and we want to avoid any | ||||
// noticeable edge-filtering artifacts | // noticeable edge-filtering artifacts | ||||
fov *= 1.05f; | fov *= 1.05f; | ||||
camera = m_ViewCamera; | camera = 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 | // 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 | // 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 | // 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. | // of the view so we can see wavy reflections of slightly off-screen objects. | ||||
camera.m_Orientation.Scale(1, -1, 1); | camera.m_Orientation.Scale(1, -1, 1); | ||||
camera.m_Orientation.Translate(0, 2*wm.m_WaterHeight, 0); | camera.m_Orientation.Translate(0, 2*wm.GetWaterHeight(), 0); | ||||
camera.UpdateFrustum(scissor); | camera.UpdateFrustum(scissor); | ||||
// Clip slightly above the water to improve reflections of objects on the water | // Clip slightly above the water to improve reflections of objects on the water | ||||
// when the reflections are distorted. | // when the reflections are distorted. | ||||
camera.ClipFrustum(CVector4D(0, 1, 0, -wm.m_WaterHeight + 2.0f)); | camera.ClipFrustum(CVector4D(0, 1, 0, -wm.GetWaterHeight() + 2.0f)); | ||||
SViewPort vp; | SViewPort vp; | ||||
vp.m_Height = wm.m_RefTextureSize; | vp.m_Height = m->waterRendering.GetTextureSize(); | ||||
vp.m_Width = wm.m_RefTextureSize; | vp.m_Width = m->waterRendering.GetTextureSize(); | ||||
vp.m_X = 0; | vp.m_X = 0; | ||||
vp.m_Y = 0; | vp.m_Y = 0; | ||||
camera.SetViewPort(vp); | camera.SetViewPort(vp); | ||||
camera.SetPerspectiveProjection(m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane(), fov); | camera.SetPerspectiveProjection(m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane(), fov); | ||||
CMatrix3D scaleMat; | CMatrix3D scaleMat; | ||||
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); | scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); | ||||
camera.SetProjection(scaleMat * camera.GetProjection()); | camera.SetProjection(scaleMat * camera.GetProjection()); | ||||
CVector4D camPlane(0, 1, 0, -wm.m_WaterHeight + 0.5f); | CVector4D camPlane(0, 1, 0, -wm.GetWaterHeight() + 0.5f); | ||||
SetObliqueFrustumClipping(camera, camPlane); | SetObliqueFrustumClipping(camera, camPlane); | ||||
} | } | ||||
void CRenderer::ComputeRefractionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const | void CRenderer::ComputeRefractionCamera(CCamera& camera, const CBoundingBoxAligned& scissor) const | ||||
{ | { | ||||
WaterManager& wm = m->waterManager; | const WaterManager& wm = g_Game->GetView()->GetWaterManager(); | ||||
ENSURE(m_ViewCamera.GetProjectionType() == CCamera::PERSPECTIVE); | ENSURE(m_ViewCamera.GetProjectionType() == CCamera::PERSPECTIVE); | ||||
float fov = m_ViewCamera.GetFOV(); | float fov = m_ViewCamera.GetFOV(); | ||||
// Expand fov slightly since ripples can reflect parts of the scene that | // Expand fov slightly since ripples can reflect parts of the scene that | ||||
// are slightly outside the normal camera view, and we want to avoid any | // are slightly outside the normal camera view, and we want to avoid any | ||||
// noticeable edge-filtering artifacts | // noticeable edge-filtering artifacts | ||||
fov *= 1.05f; | fov *= 1.05f; | ||||
camera = m_ViewCamera; | camera = m_ViewCamera; | ||||
// Temporarily change the camera to make it render to a view port the size of the | // 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 | // 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 | // 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. | // of the view so we can see wavy refractions of slightly off-screen objects. | ||||
camera.UpdateFrustum(scissor); | camera.UpdateFrustum(scissor); | ||||
camera.ClipFrustum(CVector4D(0, -1, 0, wm.m_WaterHeight + 0.5f)); // add some to avoid artifacts near steep shores. | camera.ClipFrustum(CVector4D(0, -1, 0, wm.GetWaterHeight() + 0.5f)); // add some to avoid artifacts near steep shores. | ||||
SViewPort vp; | SViewPort vp; | ||||
vp.m_Height = wm.m_RefTextureSize; | vp.m_Height = m->waterRendering.GetTextureSize(); | ||||
vp.m_Width = wm.m_RefTextureSize; | vp.m_Width = m->waterRendering.GetTextureSize(); | ||||
vp.m_X = 0; | vp.m_X = 0; | ||||
vp.m_Y = 0; | vp.m_Y = 0; | ||||
camera.SetViewPort(vp); | camera.SetViewPort(vp); | ||||
camera.SetPerspectiveProjection(m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane(), fov); | camera.SetPerspectiveProjection(m_ViewCamera.GetNearPlane(), m_ViewCamera.GetFarPlane(), fov); | ||||
CMatrix3D scaleMat; | CMatrix3D scaleMat; | ||||
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); | scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); | ||||
camera.SetProjection(scaleMat * camera.GetProjection()); | camera.SetProjection(scaleMat * camera.GetProjection()); | ||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// RenderReflections: render the water reflections to the reflection texture | // RenderReflections: render the water reflections to the reflection texture | ||||
void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | ||||
{ | { | ||||
PROFILE3_GPU("water reflections"); | PROFILE3_GPU("water reflections"); | ||||
WaterManager& wm = m->waterManager; | |||||
// Remember old camera | // Remember old camera | ||||
CCamera normalCamera = m_ViewCamera; | CCamera normalCamera = m_ViewCamera; | ||||
ComputeReflectionCamera(m_ViewCamera, scissor); | ComputeReflectionCamera(m_ViewCamera, scissor); | ||||
m->SetOpenGLCamera(m_ViewCamera); | m->SetOpenGLCamera(m_ViewCamera); | ||||
// Save the model-view-projection matrix so the shaders can use it for projective texturing | // Save the model-view-projection matrix so the shaders can use it for projective texturing | ||||
wm.m_ReflectionMatrix = m_ViewCamera.GetViewProjection(); | m->waterRendering.m_ReflectionMatrix = m_ViewCamera.GetViewProjection(); | ||||
float vpHeight = wm.m_RefTextureSize; | float vpHeight = m->waterRendering.GetTextureSize(); | ||||
float vpWidth = wm.m_RefTextureSize; | float vpWidth = m->waterRendering.GetTextureSize(); | ||||
SScreenRect screenScissor; | SScreenRect screenScissor; | ||||
screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | ||||
screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | ||||
glEnable(GL_SCISSOR_TEST); | glEnable(GL_SCISSOR_TEST); | ||||
glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1); | glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1); | ||||
// try binding the framebuffer | // try binding the framebuffer | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_ReflectionFbo); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m->waterRendering.m_ReflectionFbo); | ||||
glClearColor(0.5f,0.5f,1.0f,0.0f); | glClearColor(0.5f,0.5f,1.0f,0.0f); | ||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||||
glFrontFace(GL_CW); | glFrontFace(GL_CW); | ||||
if (!g_RenderingOptions.GetWaterReflection()) | if (!g_RenderingOptions.GetWaterReflection()) | ||||
{ | { | ||||
Show All 31 Lines | |||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// RenderRefractions: render the water refractions to the refraction texture | // RenderRefractions: render the water refractions to the refraction texture | ||||
void CRenderer::RenderRefractions(const CShaderDefines& context, const CBoundingBoxAligned &scissor) | void CRenderer::RenderRefractions(const CShaderDefines& context, const CBoundingBoxAligned &scissor) | ||||
{ | { | ||||
PROFILE3_GPU("water refractions"); | PROFILE3_GPU("water refractions"); | ||||
WaterManager& wm = m->waterManager; | |||||
// Remember old camera | // Remember old camera | ||||
CCamera normalCamera = m_ViewCamera; | CCamera normalCamera = m_ViewCamera; | ||||
ComputeRefractionCamera(m_ViewCamera, scissor); | ComputeRefractionCamera(m_ViewCamera, scissor); | ||||
CVector4D camPlane(0, -1, 0, wm.m_WaterHeight + 2.0f); | CVector4D camPlane(0, -1, 0, g_Game->GetView()->GetWaterManager().GetWaterHeight() + 2.0f); | ||||
SetObliqueFrustumClipping(m_ViewCamera, camPlane); | SetObliqueFrustumClipping(m_ViewCamera, camPlane); | ||||
m->SetOpenGLCamera(m_ViewCamera); | m->SetOpenGLCamera(m_ViewCamera); | ||||
// Save the model-view-projection matrix so the shaders can use it for projective texturing | // Save the model-view-projection matrix so the shaders can use it for projective texturing | ||||
wm.m_RefractionMatrix = m_ViewCamera.GetViewProjection(); | m->waterRendering.m_RefractionMatrix = m_ViewCamera.GetViewProjection(); | ||||
wm.m_RefractionProjInvMatrix = m_ViewCamera.GetProjection().GetInverse(); | m->waterRendering.m_RefractionProjInvMatrix = m_ViewCamera.GetProjection().GetInverse(); | ||||
wm.m_RefractionViewInvMatrix = m_ViewCamera.GetOrientation(); | m->waterRendering.m_RefractionViewInvMatrix = m_ViewCamera.GetOrientation(); | ||||
float vpHeight = wm.m_RefTextureSize; | float vpHeight = m->waterRendering.GetTextureSize(); | ||||
float vpWidth = wm.m_RefTextureSize; | float vpWidth = m->waterRendering.GetTextureSize(); | ||||
SScreenRect screenScissor; | SScreenRect screenScissor; | ||||
screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | ||||
screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | ||||
glEnable(GL_SCISSOR_TEST); | glEnable(GL_SCISSOR_TEST); | ||||
glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1); | glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1); | ||||
// try binding the framebuffer | // try binding the framebuffer | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_RefractionFbo); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m->waterRendering.m_RefractionFbo); | ||||
glClearColor(1.0f,0.0f,0.0f,0.0f); | glClearColor(1.0f,0.0f,0.0f,0.0f); | ||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | ||||
// Render terrain and models | // Render terrain and models | ||||
RenderPatches(context, CULL_REFRACTIONS); | RenderPatches(context, CULL_REFRACTIONS); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
RenderModels(context, CULL_REFRACTIONS); | RenderModels(context, CULL_REFRACTIONS); | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) | ||||
if (m_Caps.m_Shadows && g_RenderingOptions.GetShadows()) | if (m_Caps.m_Shadows && g_RenderingOptions.GetShadows()) | ||||
{ | { | ||||
RenderShadowMap(context); | RenderShadowMap(context); | ||||
} | } | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
if (m_WaterManager->m_RenderWater) | bool renderWater = g_Game->GetView()->GetWaterManager().IsRenderingEnabled(); | ||||
if (renderWater) | |||||
{ | { | ||||
if (waterScissor.GetVolume() > 0 && m_WaterManager->WillRenderFancyWater()) | if (waterScissor.GetVolume() > 0 && g_RenderingOptions.GetWaterEffects()) | ||||
{ | { | ||||
PROFILE3_GPU("water scissor"); | PROFILE3_GPU("water scissor"); | ||||
RenderReflections(context, waterScissor); | RenderReflections(context, waterScissor); | ||||
if (g_RenderingOptions.GetWaterRefraction()) | if (g_RenderingOptions.GetWaterRefraction()) | ||||
RenderRefractions(context, waterScissor); | RenderRefractions(context, waterScissor); | ||||
} | } | ||||
} | } | ||||
Show All 28 Lines | void CRenderer::RenderSubmissions(const CBoundingBoxAligned& waterScissor) | ||||
// render other debug-related overlays before water (so they can be seen when underwater) | // render other debug-related overlays before water (so they can be seen when underwater) | ||||
m->overlayRenderer.RenderOverlaysBeforeWater(); | m->overlayRenderer.RenderOverlaysBeforeWater(); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
RenderModels(context, cullGroup); | RenderModels(context, cullGroup); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
// render water | // render water | ||||
if (m_WaterManager->m_RenderWater && g_Game && waterScissor.GetVolume() > 0) | if (renderWater && g_Game && waterScissor.GetVolume() > 0) | ||||
{ | { | ||||
if (m_WaterManager->WillRenderFancyWater()) | if (g_RenderingOptions.GetWaterEffects()) | ||||
{ | { | ||||
// Render transparent stuff, but only the solid parts that can occlude block water. | // Render transparent stuff, but only the solid parts that can occlude block water. | ||||
RenderTransparentModels(context, cullGroup, TRANSPARENT_OPAQUE, false); | RenderTransparentModels(context, cullGroup, TRANSPARENT_OPAQUE, false); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
m->terrainRenderer.RenderWater(context, cullGroup, &m->shadow); | m->terrainRenderer.RenderWater(context, cullGroup, &m->shadow); | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
▲ Show 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | void CRenderer::RenderScene(Scene& scene) | ||||
{ | { | ||||
m_CurrentCullGroup = CULL_SHADOWS; | m_CurrentCullGroup = CULL_SHADOWS; | ||||
CFrustum shadowFrustum = m->shadow.GetShadowCasterCullFrustum(); | CFrustum shadowFrustum = m->shadow.GetShadowCasterCullFrustum(); | ||||
scene.EnumerateObjects(shadowFrustum, this); | scene.EnumerateObjects(shadowFrustum, this); | ||||
} | } | ||||
CBoundingBoxAligned waterScissor; | CBoundingBoxAligned waterScissor; | ||||
if (m_WaterManager->m_RenderWater) | if (g_Game->GetView()->GetWaterManager().IsRenderingEnabled()) | ||||
{ | { | ||||
waterScissor = m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera.GetViewProjection()); | waterScissor = m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera.GetViewProjection()); | ||||
if (waterScissor.GetVolume() > 0 && m_WaterManager->WillRenderFancyWater()) | if (waterScissor.GetVolume() > 0 && g_RenderingOptions.GetWaterEffects()) | ||||
{ | { | ||||
if (g_RenderingOptions.GetWaterReflection()) | if (g_RenderingOptions.GetWaterReflection()) | ||||
{ | { | ||||
m_CurrentCullGroup = CULL_REFLECTIONS; | m_CurrentCullGroup = CULL_REFLECTIONS; | ||||
CCamera reflectionCamera; | CCamera reflectionCamera; | ||||
ComputeReflectionCamera(reflectionCamera, waterScissor); | ComputeReflectionCamera(reflectionCamera, waterScissor); | ||||
scene.EnumerateObjects(reflectionCamera.GetFrustum(), this); | scene.EnumerateObjects(reflectionCamera.GetFrustum(), this); | ||||
} | } | ||||
if (g_RenderingOptions.GetWaterRefraction()) | if (g_RenderingOptions.GetWaterRefraction()) | ||||
{ | { | ||||
m_CurrentCullGroup = CULL_REFRACTIONS; | m_CurrentCullGroup = CULL_REFRACTIONS; | ||||
CCamera refractionCamera; | CCamera refractionCamera; | ||||
ComputeRefractionCamera(refractionCamera, waterScissor); | ComputeRefractionCamera(refractionCamera, waterScissor); | ||||
scene.EnumerateObjects(refractionCamera.GetFrustum(), this); | scene.EnumerateObjects(refractionCamera.GetFrustum(), this); | ||||
} | } | ||||
// Render the waves to the Fancy effects texture | // Render the waves to the Fancy effects texture | ||||
m_WaterManager->RenderWaves(frustum); | m->waterRendering.RenderWaves(frustum); | ||||
} | } | ||||
} | } | ||||
m_CurrentCullGroup = -1; | m_CurrentCullGroup = -1; | ||||
ogl_WarnIfError(); | ogl_WarnIfError(); | ||||
RenderSubmissions(waterScissor); | RenderSubmissions(waterScissor); | ||||
▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | Status CRenderer::ReloadChangedFileCB(void* param, const VfsPath& path) | ||||
} | } | ||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
void CRenderer::MakeShadersDirty() | void CRenderer::MakeShadersDirty() | ||||
{ | { | ||||
m->ShadersDirty = true; | m->ShadersDirty = true; | ||||
m_WaterManager->m_NeedsReloading = true; | m->waterRendering.fancyWaterShader.reset(); | ||||
} | } | ||||
CTextureManager& CRenderer::GetTextureManager() | CTextureManager& CRenderer::GetTextureManager() | ||||
{ | { | ||||
return m->textureManager; | return m->textureManager; | ||||
} | } | ||||
CShaderManager& CRenderer::GetShaderManager() | CShaderManager& CRenderer::GetShaderManager() | ||||
{ | { | ||||
return m->shaderManager; | return m->shaderManager; | ||||
} | } | ||||
CParticleManager& CRenderer::GetParticleManager() | CParticleManager& CRenderer::GetParticleManager() | ||||
{ | { | ||||
return m->particleManager; | return m->particleManager; | ||||
} | } | ||||
TerrainRenderer& CRenderer::GetTerrainRenderer() | TerrainRenderer& CRenderer::GetTerrainRenderer() | ||||
{ | { | ||||
return m->terrainRenderer; | return m->terrainRenderer; | ||||
} | } | ||||
WaterRendering& CRenderer::GetWaterRendering() | |||||
{ | |||||
return m->waterRendering; | |||||
} | |||||
CTimeManager& CRenderer::GetTimeManager() | CTimeManager& CRenderer::GetTimeManager() | ||||
{ | { | ||||
return m->timeManager; | return m->timeManager; | ||||
} | } | ||||
CMaterialManager& CRenderer::GetMaterialManager() | CMaterialManager& CRenderer::GetMaterialManager() | ||||
{ | { | ||||
return m->materialManager; | return m->materialManager; | ||||
Show All 22 Lines |
Wildfire Games · Phabricator