作者:化合价steuart_968 | 来源:互联网 | 2023-05-19 04:39
I tried this tutorial and this is how i create and use the reflection matrix (my water plane is z = 0):
我尝试了本教程,这就是我如何创建和使用反射矩阵(我的水平面是z = 0):
glm::mat4 mReflection = glm::mat4
(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, -1.0, 0.0,
0.0, 0.0, 0.0, 1.0
);
camera.setViewMatrix(mReflection * camera.View());
glCullFace(GL_FRONT);
shader:
材质:
vec4 mvpvertex = MVP_reflection * vec4(vertex, 1.0);
vec2 projCoord = mvpvertex.xy / mvpvertex.w;
projCoord = vec2(0.5, 0.5) + 0.5 * projCoord;
projCoord = clamp(projCoord, 0.0, 1.0);
But the whole scene seems to be flipped arround. The things i should see the reflection of in front of me are behind me and vice versa. I tried some more matrix transformations but none if my tries worked. What am I doing wrong and how can I fix it?
但整个场面似乎都颠倒过来了。我应该看到的在我面前的倒影在我背后,反之亦然。我尝试了更多的矩阵变换,但是如果我的尝试成功了,没有一个。我做错了什么,我该如何改正?
1 个解决方案