Fixed water color in opengl rendering

This commit is contained in:
Michaël Lemaire 2013-12-24 11:48:06 +01:00 committed by Michael Lemaire
parent bf47e058ee
commit 74e707a989
2 changed files with 9 additions and 1 deletions

View file

@ -4,6 +4,9 @@
#include "OpenGLShaderProgram.h"
#include "OpenGLSharedState.h"
#include "WaterRenderer.h"
#include "Scenery.h"
#include "WaterDefinition.h"
#include "SurfaceMaterial.h"
OpenGLWater::OpenGLWater(OpenGLRenderer *renderer):
OpenGLPart(renderer)
@ -34,6 +37,9 @@ void OpenGLWater::update()
{
double water_height = renderer->getWaterRenderer()->getHeightInfo().max_height;
renderer->getSharedState()->set("waterHeight", water_height);
Color water_color = renderer->getScenery()->getWater()->material->_rgb;
renderer->getSharedState()->set("waterColor", water_color);
}
void OpenGLWater::render()

View file

@ -1,6 +1,8 @@
uniform vec4 waterColor;
void main(void)
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
gl_FragColor = waterColor;
float yoffset = GROUND_OFFSET - waterHeight;
vec3 camera = vec3(cameraLocation.x, max(cameraLocation.y + yoffset, 0.0), cameraLocation.z);