<p>With the help of this article I was able to fix the problem. The problem was the the missing inversion.</p>

<p><a href="http://www.bcnine.com/articles/water/water.md.html" rel="nofollow noreferrer">http://www.bcnine.com/articles/water/water.md.html</a></p>

<p>The working code is available via the above given links.</p>

CC BY-SA 4.0
2020-03-07T09:15:25.650Z
2020-03-07T09:15:25.650Z
Martin Gerhardy
<p>Here is a youtube video showing my problem:</p>

<ul>
<li><a href="https://www.youtube.com/watch?v=y8J7VhS2pkM" rel="nofollow noreferrer">youtube.com/watch?v=y8J7VhS2pkM</a></li>
</ul>

<p>I think I'm either doing the texture lookup on the reflection texture wrong, or the reflection or view matrix is somehow wrong.</p>

<p>The reflection matrix is calculated after Goldman formula with plane normal pointing in positive y-Axis (world up vector).</p>

<ul>
<li><a href="https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/WorldRenderer.cpp#L97" rel="nofollow noreferrer">WorldRenderer.cpp#L97</a> (<code>reflectionMatrix()</code> and <code>renderClippingPlanes()</code> at those positions)</li>
<li><a href="https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/shaders/water.vert" rel="nofollow noreferrer">Water vertex shader</a></li>
<li><a href="https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/shaders/water.frag" rel="nofollow noreferrer">Water fragment shader</a></li>
<li><a href="https://github.com/mgerhardy/engine/blob/master/src/modules/video/Camera.cpp#L309" rel="nofollow noreferrer">Camera viewmatrix calculation</a></li>
</ul>

<p>What am I doing wrong here? Notice the renderings of the framebuffer textures in the debug ui.</p>

<p>I was following this water rendering tutorial series here: <a href="https://www.youtube.com/watch?v=0NH9k4zTAqk&amp;list=PLRIWtICgwaX23jiqVByUs0bqhnalNTNZh&amp;index=3" rel="nofollow noreferrer">Youtube Water rendering tutorial</a></p>

<p>There are other projects following this tutorial:</p>

<ul>
<li><a href="https://github.com/fede-vaccaro/TerrainEngine-OpenGL" rel="nofollow noreferrer">https://github.com/fede-vaccaro/TerrainEngine-OpenGL</a></li>
<li><a href="https://github.com/codycoolwaffle/avaritia" rel="nofollow noreferrer">https://github.com/codycoolwaffle/avaritia</a></li>
</ul>

<p>I couldn't find my error even after looking at the above code bases.</p>

<p>What might the error be? Anyone any ideas?</p>

<opengl><glsl><mathematics><reflection><glm>
Wrong reflection
Martin Gerhardy
# Wrong reflection

(Asked by: username_0 on 2020-03-01)

Here is a youtube video showing my problem:

* [youtube.com/watch?v=y8J7VhS2pkM](https://www.youtube.com/watch?v=y8J7VhS2pkM)

I think I'm either doing the texture lookup on the reflection texture wrong, or the reflection or view matrix is somehow wrong.

The reflection matrix is calculated after Goldman formula with plane normal pointing in positive y-Axis (world up vector).

* [WorldRenderer.cpp#L97](https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/WorldRenderer.cpp#L97) (`reflectionMatrix()` and `renderClippingPlanes()` at those positions)
* [Water vertex shader](https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/shaders/water.vert)
* [Water fragment shader](https://github.com/mgerhardy/engine/blob/master/src/modules/voxelrender/shaders/water.frag)
* [Camera viewmatrix calculation](https://github.com/mgerhardy/engine/blob/master/src/modules/video/Camera.cpp#L309)

What am I doing wrong here? Notice the renderings of the framebuffer textures in the debug ui.

I was following this water rendering tutorial series here: [Youtube Water rendering tutorial](https://www.youtube.com/watch?v=0NH9k4zTAqk&list=PLRIWtICgwaX23jiqVByUs0bqhnalNTNZh&index=3)

There are other projects following this tutorial:

* <https://github.com/fede-vaccaro/TerrainEngine-OpenGL>
* <https://github.com/codycoolwaffle/avaritia>

I couldn't find my error even after looking at the above code bases.

What might the error be? Anyone any ideas?

**Tags:** opengl, glsl, mathematics, reflection, glm


---

## 1 answers

### Answer by username_0 on 2020-03-07. Score: 0 | Accepted answer

With the help of this article I was able to fix the problem. The problem was the the missing inversion.

<http://www.bcnine.com/articles/water/water.md.html>

The working code is available via the above given links.


---

