Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/renderer/TerrainRenderer.cpp
Show First 20 Lines • Show All 679 Lines • ▼ Show 20 Lines | if (!m->fancyWaterShader) | ||||
WaterMgr->m_RenderWater = false; | WaterMgr->m_RenderWater = false; | ||||
return false; | return false; | ||||
} | } | ||||
WaterMgr->m_NeedsReloading = false; | WaterMgr->m_NeedsReloading = false; | ||||
} | } | ||||
CLOSTexture& losTexture = g_Renderer.GetScene().GetLOSTexture(); | CLOSTexture& losTexture = g_Renderer.GetScene().GetLOSTexture(); | ||||
// creating the real depth texture using the depth buffer. | |||||
if (WaterMgr->m_WaterRealDepth) | |||||
{ | |||||
if (WaterMgr->m_depthTT == 0) | |||||
{ | |||||
GLuint depthTex; | |||||
glGenTextures(1, (GLuint*)&depthTex); | |||||
WaterMgr->m_depthTT = depthTex; | |||||
glBindTexture(GL_TEXTURE_2D, WaterMgr->m_depthTT); | |||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, g_Renderer.GetWidth(), g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); | |||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |||||
} | |||||
else | |||||
{ | |||||
glBindTexture(GL_TEXTURE_2D, WaterMgr->m_depthTT); | |||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, g_Renderer.GetWidth(), g_Renderer.GetHeight(), 0); | |||||
} | |||||
glBindTexture(GL_TEXTURE_2D, 0); | |||||
} | |||||
// Calculating the advanced informations about Foam and all if the quality calls for it. | // Calculating the advanced informations about Foam and all if the quality calls for it. | ||||
/*if (WaterMgr->m_NeedInfoUpdate && (WaterMgr->m_WaterFoam || WaterMgr->m_WaterCoastalWaves)) | /*if (WaterMgr->m_NeedInfoUpdate && (WaterMgr->m_WaterFoam || WaterMgr->m_WaterCoastalWaves)) | ||||
{ | { | ||||
WaterMgr->m_NeedInfoUpdate = false; | WaterMgr->m_NeedInfoUpdate = false; | ||||
WaterMgr->CreateSuperfancyInfo(); | WaterMgr->CreateSuperfancyInfo(); | ||||
}*/ | }*/ | ||||
double time = WaterMgr->m_WaterTexTimer; | double time = WaterMgr->m_WaterTexTimer; | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow) | ||||
m->fancyWaterShader->BindTexture(str_normalMap, WaterMgr->m_NormalMap[curTex]); | m->fancyWaterShader->BindTexture(str_normalMap, WaterMgr->m_NormalMap[curTex]); | ||||
m->fancyWaterShader->BindTexture(str_normalMap2, WaterMgr->m_NormalMap[nexTex]); | m->fancyWaterShader->BindTexture(str_normalMap2, WaterMgr->m_NormalMap[nexTex]); | ||||
if (WaterMgr->m_WaterFancyEffects) | if (WaterMgr->m_WaterFancyEffects) | ||||
{ | { | ||||
m->fancyWaterShader->BindTexture(str_waterEffectsTex, WaterMgr->m_FancyTexture); | m->fancyWaterShader->BindTexture(str_waterEffectsTex, WaterMgr->m_FancyTexture); | ||||
} | } | ||||
if (WaterMgr->m_WaterRealDepth) | if (WaterMgr->m_WaterRefraction && WaterMgr->m_WaterRealDepth) | ||||
m->fancyWaterShader->BindTexture(str_depthTex, WaterMgr->m_depthTT); | { | ||||
m->fancyWaterShader->BindTexture(str_depthTex, WaterMgr->m_RefrFboDepthTexture); | |||||
m->fancyWaterShader->Uniform(str_projInvTransform, WaterMgr->m_RefractionProjInvMatrix); | |||||
m->fancyWaterShader->Uniform(str_viewInvTransform, WaterMgr->m_RefractionViewInvMatrix); | |||||
} | |||||
if (WaterMgr->m_WaterRefraction) | if (WaterMgr->m_WaterRefraction) | ||||
m->fancyWaterShader->BindTexture(str_refractionMap, WaterMgr->m_RefractionTexture); | m->fancyWaterShader->BindTexture(str_refractionMap, WaterMgr->m_RefractionTexture); | ||||
if (WaterMgr->m_WaterReflection) | if (WaterMgr->m_WaterReflection) | ||||
m->fancyWaterShader->BindTexture(str_reflectionMap, WaterMgr->m_ReflectionTexture); | m->fancyWaterShader->BindTexture(str_reflectionMap, WaterMgr->m_ReflectionTexture); | ||||
m->fancyWaterShader->BindTexture(str_losTex, losTexture.GetTextureSmooth()); | m->fancyWaterShader->BindTexture(str_losTex, losTexture.GetTextureSmooth()); | ||||
const CLightEnv& lightEnv = g_Renderer.GetLightEnv(); | const CLightEnv& lightEnv = g_Renderer.GetLightEnv(); | ||||
Show All 22 Lines | bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGroup, ShadowMap* shadow) | ||||
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, camera.GetOrientation().GetTranslation()); | m->fancyWaterShader->Uniform(str_cameraPos, camera.GetOrientation().GetTranslation()); | ||||
if (WaterMgr->m_WaterRealDepth) | |||||
{ | |||||
m->fancyWaterShader->Uniform(str_zNear, camera.GetNearPlane()); | |||||
m->fancyWaterShader->Uniform(str_zFar, camera.GetFarPlane()); | |||||
} | |||||
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); | 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") | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator