Changeset View
Changeset View
Standalone View
Standalone View
source/renderer/TerrainRenderer.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | struct TerrainRendererInternals | ||||
/// Decals that were submitted for this frame | /// Decals that were submitted for this frame | ||||
std::vector<CDecalRData*> visibleDecals[CRenderer::CULL_MAX]; | std::vector<CDecalRData*> visibleDecals[CRenderer::CULL_MAX]; | ||||
/// Fancy water shader | /// Fancy water shader | ||||
CShaderProgramPtr fancyWaterShader; | CShaderProgramPtr fancyWaterShader; | ||||
CSimulation2* simulation; | CSimulation2* simulation; | ||||
bool resized; | |||||
}; | }; | ||||
/////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////// | ||||
// Construction/Destruction | // Construction/Destruction | ||||
TerrainRenderer::TerrainRenderer() | TerrainRenderer::TerrainRenderer() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | |||||
#else | #else | ||||
glEnableClientState(GL_VERTEX_ARRAY); | glEnableClientState(GL_VERTEX_ARRAY); | ||||
for (size_t i = 0; i < visiblePatches.size(); ++i) | for (size_t i = 0; i < visiblePatches.size(); ++i) | ||||
visiblePatches[i]->RenderOutline(); | visiblePatches[i]->RenderOutline(); | ||||
glDisableClientState(GL_VERTEX_ARRAY); | glDisableClientState(GL_VERTEX_ARRAY); | ||||
#endif | #endif | ||||
} | } | ||||
// Remember that screen changed size | |||||
void TerrainRenderer::Resize() | |||||
{ | |||||
m->resized = true; | |||||
} | |||||
/////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////// | ||||
// Scissor rectangle of water patches | // Scissor rectangle of water patches | ||||
CBoundingBoxAligned TerrainRenderer::ScissorWater(int cullGroup, const CMatrix3D &viewproj) | CBoundingBoxAligned TerrainRenderer::ScissorWater(int cullGroup, const CMatrix3D &viewproj) | ||||
{ | { | ||||
std::vector<CPatchRData*>& visiblePatches = m->visiblePatches[cullGroup]; | std::vector<CPatchRData*>& visiblePatches = m->visiblePatches[cullGroup]; | ||||
CBoundingBoxAligned scissor; | CBoundingBoxAligned scissor; | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | if (!m->fancyWaterShader || WaterMgr->m_NeedsReloading) | ||||
if (!m->fancyWaterShader) | if (!m->fancyWaterShader) | ||||
{ | { | ||||
LOGERROR("Failed to load water shader. Falling back to fixed pipeline water.\n"); | LOGERROR("Failed to load water shader. Falling back to fixed pipeline water.\n"); | ||||
WaterMgr->m_RenderWater = false; | WaterMgr->m_RenderWater = false; | ||||
return false; | return false; | ||||
} | } | ||||
WaterMgr->m_NeedsReloading = false; | WaterMgr->m_NeedsReloading = false; | ||||
m->resized = true; | |||||
} | } | ||||
CLOSTexture& losTexture = g_Renderer.GetScene().GetLOSTexture(); | CLOSTexture& losTexture = g_Renderer.GetScene().GetLOSTexture(); | ||||
// creating the real depth texture using the depth buffer. | // creating the real depth texture using the depth buffer. | ||||
if (WaterMgr->m_WaterRealDepth) | if (WaterMgr->m_WaterRealDepth) | ||||
{ | { | ||||
if (WaterMgr->m_depthTT == 0) | if (WaterMgr->m_depthTT == 0) | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | if (WaterMgr->m_WaterRefraction || WaterMgr->m_WaterReflection) | ||||
skyBoxRotation.RotateY(M_PI + lightEnv.GetRotation()); | skyBoxRotation.RotateY(M_PI + lightEnv.GetRotation()); | ||||
m->fancyWaterShader->Uniform(str_skyBoxRot, skyBoxRotation); | m->fancyWaterShader->Uniform(str_skyBoxRot, skyBoxRotation); | ||||
if (WaterMgr->m_WaterRefraction) | if (WaterMgr->m_WaterRefraction) | ||||
m->fancyWaterShader->Uniform(str_refractionMatrix, WaterMgr->m_RefractionMatrix); | m->fancyWaterShader->Uniform(str_refractionMatrix, WaterMgr->m_RefractionMatrix); | ||||
if (WaterMgr->m_WaterReflection) | if (WaterMgr->m_WaterReflection) | ||||
m->fancyWaterShader->Uniform(str_reflectionMatrix, WaterMgr->m_ReflectionMatrix); | m->fancyWaterShader->Uniform(str_reflectionMatrix, WaterMgr->m_ReflectionMatrix); | ||||
} | } | ||||
if (m->resized) | |||||
m->fancyWaterShader->Uniform(str_screenSize, (float)g_Renderer.GetWidth(), (float)g_Renderer.GetHeight(), 0.0f, 0.0f); | |||||
m->fancyWaterShader->Uniform(str_sunDir, lightEnv.GetSunDir()); | m->fancyWaterShader->Uniform(str_sunDir, lightEnv.GetSunDir()); | ||||
m->fancyWaterShader->Uniform(str_sunColor, lightEnv.m_SunColor); | m->fancyWaterShader->Uniform(str_sunColor, lightEnv.m_SunColor); | ||||
m->fancyWaterShader->Uniform(str_color, WaterMgr->m_WaterColor); | m->fancyWaterShader->Uniform(str_color, WaterMgr->m_WaterColor); | ||||
m->fancyWaterShader->Uniform(str_tint, WaterMgr->m_WaterTint); | m->fancyWaterShader->Uniform(str_tint, WaterMgr->m_WaterTint); | ||||
m->fancyWaterShader->Uniform(str_waviness, WaterMgr->m_Waviness); | m->fancyWaterShader->Uniform(str_waviness, WaterMgr->m_Waviness); | ||||
m->fancyWaterShader->Uniform(str_murkiness, WaterMgr->m_Murkiness); | m->fancyWaterShader->Uniform(str_murkiness, WaterMgr->m_Murkiness); | ||||
m->fancyWaterShader->Uniform(str_windAngle, WaterMgr->m_WindAngle); | m->fancyWaterShader->Uniform(str_windAngle, WaterMgr->m_WindAngle); | ||||
m->fancyWaterShader->Uniform(str_repeatScale, 1.0f / repeatPeriod); | m->fancyWaterShader->Uniform(str_repeatScale, 1.0f / repeatPeriod); | ||||
m->fancyWaterShader->Uniform(str_losMatrix, losTexture.GetTextureMatrix()); | m->fancyWaterShader->Uniform(str_losMatrix, losTexture.GetTextureMatrix()); | ||||
m->fancyWaterShader->Uniform(str_cameraPos, camPos); | m->fancyWaterShader->Uniform(str_cameraPos, camPos); | ||||
m->fancyWaterShader->Uniform(str_fogColor, lightEnv.m_FogColor); | m->fancyWaterShader->Uniform(str_fogColor, lightEnv.m_FogColor); | ||||
m->fancyWaterShader->Uniform(str_fogParams, lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f); | m->fancyWaterShader->Uniform(str_fogParams, lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f); | ||||
m->fancyWaterShader->Uniform(str_time, (float)time); | m->fancyWaterShader->Uniform(str_time, (float)time); | ||||
m->fancyWaterShader->Uniform(str_screenSize, (float)g_Renderer.GetWidth(), (float)g_Renderer.GetHeight(), 0.0f, 0.0f); | |||||
if (WaterMgr->m_WaterType == L"clap") | if (WaterMgr->m_WaterType == L"clap") | ||||
{ | { | ||||
m->fancyWaterShader->Uniform(str_waveParams1, 30.0f,1.5f,20.0f,0.03f); | m->fancyWaterShader->Uniform(str_waveParams1, 30.0f,1.5f,20.0f,0.03f); | ||||
m->fancyWaterShader->Uniform(str_waveParams2, 0.5f,0.0f,0.0f,0.0f); | m->fancyWaterShader->Uniform(str_waveParams2, 0.5f,0.0f,0.0f,0.0f); | ||||
} | } | ||||
else if (WaterMgr->m_WaterType == L"lake") | else if (WaterMgr->m_WaterType == L"lake") | ||||
{ | { | ||||
Show All 21 Lines | for (size_t i = 0; i < visiblePatches.size(); ++i) | ||||
CPatchRData* data = visiblePatches[i]; | CPatchRData* data = visiblePatches[i]; | ||||
data->RenderWater(m->fancyWaterShader); | data->RenderWater(m->fancyWaterShader); | ||||
} | } | ||||
m->fancyWaterShader->Unbind(); | m->fancyWaterShader->Unbind(); | ||||
glDepthFunc(GL_LEQUAL); | glDepthFunc(GL_LEQUAL); | ||||
glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
m->resized = false; | |||||
return true; | return true; | ||||
} | } | ||||
void TerrainRenderer::RenderSimpleWater(int cullGroup) | void TerrainRenderer::RenderSimpleWater(int cullGroup) | ||||
{ | { | ||||
#if CONFIG2_GLES | #if CONFIG2_GLES | ||||
UNUSED2(cullGroup); | UNUSED2(cullGroup); | ||||
#else | #else | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator