Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/Renderer.cpp
Show First 20 Lines • Show All 984 Lines • ▼ Show 20 Lines | void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | ||||
PROFILE3_GPU("water reflections"); | PROFILE3_GPU("water reflections"); | ||||
WaterManager& wm = m->waterManager; | 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); | ||||
const CBoundingBoxAligned refractionScissor = | |||||
m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera.GetViewProjection()); | |||||
SetViewport(m_ViewCamera.GetViewPort()); | SetViewport(m_ViewCamera.GetViewPort()); | ||||
// 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(); | wm.m_ReflectionMatrix = m_ViewCamera.GetViewProjection(); | ||||
float vpHeight = wm.m_RefTextureSize; | float vpHeight = wm.m_RefTextureSize; | ||||
float vpWidth = wm.m_RefTextureSize; | float vpWidth = wm.m_RefTextureSize; | ||||
SScreenRect screenScissor; | SScreenRect screenScissor; | ||||
screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | screenScissor.x1 = (GLint)floor((refractionScissor[0].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | screenScissor.y1 = (GLint)floor((refractionScissor[0].Y*0.5f+0.5f)*vpHeight); | ||||
screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | screenScissor.x2 = (GLint)ceil((refractionScissor[1].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | screenScissor.y2 = (GLint)ceil((refractionScissor[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, wm.m_ReflectionFbo); | ||||
glClearColor(0.5f, 0.5f, 1.0f, 0.0f); | glClearColor(0.5f, 0.5f, 1.0f, 0.0f); | ||||
Show All 33 Lines | void CRenderer::RenderReflections(const CShaderDefines& context, const CBoundingBoxAligned& scissor) | ||||
SetViewport(m_ViewCamera.GetViewPort()); | SetViewport(m_ViewCamera.GetViewPort()); | ||||
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||||
} | } | ||||
/////////////////////////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
// 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; | 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); | ||||
const CBoundingBoxAligned reflectionScissor = | |||||
m->terrainRenderer.ScissorWater(CULL_DEFAULT, m_ViewCamera.GetViewProjection()); | |||||
CVector4D camPlane(0, -1, 0, wm.m_WaterHeight + 2.0f); | CVector4D camPlane(0, -1, 0, wm.m_WaterHeight + 2.0f); | ||||
SetObliqueFrustumClipping(m_ViewCamera, camPlane); | SetObliqueFrustumClipping(m_ViewCamera, camPlane); | ||||
SetViewport(m_ViewCamera.GetViewPort()); | SetViewport(m_ViewCamera.GetViewPort()); | ||||
// 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(); | wm.m_RefractionMatrix = m_ViewCamera.GetViewProjection(); | ||||
wm.m_RefractionProjInvMatrix = m_ViewCamera.GetProjection().GetInverse(); | wm.m_RefractionProjInvMatrix = m_ViewCamera.GetProjection().GetInverse(); | ||||
wm.m_RefractionViewInvMatrix = m_ViewCamera.GetOrientation(); | wm.m_RefractionViewInvMatrix = m_ViewCamera.GetOrientation(); | ||||
float vpHeight = wm.m_RefTextureSize; | float vpHeight = wm.m_RefTextureSize; | ||||
float vpWidth = wm.m_RefTextureSize; | float vpWidth = wm.m_RefTextureSize; | ||||
SScreenRect screenScissor; | SScreenRect screenScissor; | ||||
screenScissor.x1 = (GLint)floor((scissor[0].X*0.5f+0.5f)*vpWidth); | screenScissor.x1 = (GLint)floor((reflectionScissor[0].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y1 = (GLint)floor((scissor[0].Y*0.5f+0.5f)*vpHeight); | screenScissor.y1 = (GLint)floor((reflectionScissor[0].Y*0.5f+0.5f)*vpHeight); | ||||
screenScissor.x2 = (GLint)ceil((scissor[1].X*0.5f+0.5f)*vpWidth); | screenScissor.x2 = (GLint)ceil((reflectionScissor[1].X*0.5f+0.5f)*vpWidth); | ||||
screenScissor.y2 = (GLint)ceil((scissor[1].Y*0.5f+0.5f)*vpHeight); | screenScissor.y2 = (GLint)ceil((reflectionScissor[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, wm.m_RefractionFbo); | ||||
glClearColor(1.0f, 0.0f, 0.0f, 0.0f); | glClearColor(1.0f, 0.0f, 0.0f, 0.0f); | ||||
▲ Show 20 Lines • Show All 845 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator