SuzanneIsland: An island of Real-time rendering effects!
|
WaterEffect This is used to create a real-time reflecting and refracting horizontal water surface with small rippling waves. More...
#include <water_effect.h>
Public Member Functions | |
WaterEffect (int windowWidth, int windowHeight, float reflectionResolutionFactor, float refractionResolutionFactor, const std::string &waterDistortionDuDvMapPath, float waveAmplitude, float waveSpeed) | |
reflectionResolutionFactor and refractionResolutionFactor will be used to determine size of reflection/refraction texture as percentage of screen resolution. More... | |
void | bindReflectionFrameBuffer () |
void | bindRefractionFrameBuffer () |
void | bindFrameBuffer (GLuint frameBuffer, int width, int height) |
void | bindDefaultFrameBuffer () |
Shader * | setupWaterShader () |
void | updateWaves (float deltaT) |
WaterEffect This is used to create a real-time reflecting and refracting horizontal water surface with small rippling waves.
The fragment colors of the water surface are mixed from two textures of the scene at different camera angles for reflection and refraction: For the reflection texture we render the scene above the water surface from below, and invert the y sampling. For the refraction texture we render the scene below the water surface from above (maybe at an inclined angle). The texture sampling is distorted to create a rippling effect. The fresnel effect is modelled to attenuate reflection based on viewing angle to surface normal.
WaterEffect::WaterEffect | ( | int | windowWidth, |
int | windowHeight, | ||
float | reflectionResolutionFactor, | ||
float | refractionResolutionFactor, | ||
const std::string & | waterDistortionDuDvMapPath, | ||
float | waveAmplitude, | ||
float | waveSpeed | ||
) |
reflectionResolutionFactor and refractionResolutionFactor will be used to determine size of reflection/refraction texture as percentage of screen resolution.
values should be in [0,1].
SETUP FRAMEBUFFERS setup framebuffers with color and depth attachments. the depth attachment is used directly by opengl for depth testing, only reason to use renderbuffer instead of texture is that it is more efficient but we can do no sampling, we just render to it (write-only)
SETUP WATER SHADERS uniforms are not assigned here since they are updated each frame