Finally somehow correct cubemap

This commit is contained in:
Vladislav Khorev 2024-06-08 23:24:03 +03:00
parent 84ee2dc70c
commit 79cfbeada3
2 changed files with 48 additions and 17 deletions

View File

@ -60,12 +60,12 @@ public:
void SetGLCamAngleView();
void SetGLCamView();
void SetGlIdentityView();
void SetGlPosXView();
void SetGlNegXView();
void SetGlPosYView();
void SetGlNegYView();
void SetGlPosZView();
void SetGlNegZView();
void SetGlPosXView(bool renderToFrame = false);
void SetGlNegXView(bool renderToFrame = false);
void SetGlPosYView(bool renderToFrame = false);
void SetGlNegYView(bool renderToFrame = false);
void SetGlPosZView(bool renderToFrame = false);
void SetGlNegZView(bool renderToFrame = false);
void MoveAlpha(float dAlpha);

View File

@ -190,9 +190,13 @@ void TSalmonRendererInterface::SetGLCamAngleView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
RenderUniform3fv(CONST_STRING_CAMPOS_UNIFORM,CamPos.v);*/
LoadIdentity();
TranslateMatrix(vec3(0.0f, 0.0f, -CamDist));
RotateMatrix(vec4(1.f * sin(CamPhi / 2.f), 0.f, 0.f, 1.f * cos(CamPhi / 2.f)));
RotateMatrix(vec4(0.f, 1.f * sin(CamAlpha / 2.f), 0.f, 1.f * cos(CamAlpha / 2.f)));
TranslateMatrix(CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
@ -247,7 +251,7 @@ void TSalmonRendererInterface::SetGlIdentityView()
SetUniforms();
}
void TSalmonRendererInterface::SetGlPosXView()
void TSalmonRendererInterface::SetGlPosXView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -260,7 +264,15 @@ void TSalmonRendererInterface::SetGlPosXView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/
LoadIdentity();
if (renderToFrame)
{
RotateMatrix(vec4(0.f, -1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
}
else
{
RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
}
TranslateMatrix(-CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();
@ -270,7 +282,7 @@ void TSalmonRendererInterface::SetGlPosXView()
}
void TSalmonRendererInterface::SetGlNegXView()
void TSalmonRendererInterface::SetGlNegXView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -283,7 +295,15 @@ void TSalmonRendererInterface::SetGlNegXView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/
LoadIdentity();
RotateMatrix(vec4(0.f, -1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
if (renderToFrame)
{
RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
}
else
{
RotateMatrix(vec4(0.f, 1.f * sin(pi / 4.f), 0.f, 1.f * cos(pi / 4.f)));
}
TranslateMatrix(-CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();
@ -292,7 +312,7 @@ void TSalmonRendererInterface::SetGlNegXView()
SetUniforms();
}
void TSalmonRendererInterface::SetGlPosYView()
void TSalmonRendererInterface::SetGlPosYView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -305,7 +325,7 @@ void TSalmonRendererInterface::SetGlPosYView()
LoadIdentity();
RotateMatrix(vec4(1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
RotateMatrix(vec4(-1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
TranslateMatrix(-CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();
@ -315,7 +335,7 @@ void TSalmonRendererInterface::SetGlPosYView()
}
void TSalmonRendererInterface::SetGlNegYView()
void TSalmonRendererInterface::SetGlNegYView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -327,7 +347,7 @@ void TSalmonRendererInterface::SetGlNegYView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/
LoadIdentity();
RotateMatrix(vec4(-1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
RotateMatrix(vec4(1.f * sin(pi / 4.f), 0.0f, 0.f, 1.f * cos(pi / 4.f)));
TranslateMatrix(-CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();
@ -336,7 +356,7 @@ void TSalmonRendererInterface::SetGlNegYView()
SetUniforms();
}
void TSalmonRendererInterface::SetGlPosZView()
void TSalmonRendererInterface::SetGlPosZView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -349,6 +369,13 @@ void TSalmonRendererInterface::SetGlPosZView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);
*/
LoadIdentity();
RotateMatrix(vec4(0.f, 1.f * sin(pi / 2.f), 0.f, 1.f * cos(pi / 2.f)));
if (renderToFrame)
{
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
}
TranslateMatrix(-CamPos);
/*LoadIdentity();
@ -364,7 +391,7 @@ void TSalmonRendererInterface::SetGlPosZView()
SetUniforms();
}
void TSalmonRendererInterface::SetGlNegZView()
void TSalmonRendererInterface::SetGlNegZView(bool renderToFrame)
{
/*
glLoadIdentity();
@ -376,8 +403,12 @@ void TSalmonRendererInterface::SetGlNegZView()
CamInversedModelViewMatrix = InverseModelViewMatrix(CamModelViewMatrix);*/
LoadIdentity();
//RotateMatrix(vec4(0.f, 1.f * sin(pi / 2.f), 0.f, 1.f * cos(pi / 2.f)));
if (renderToFrame)
{
RotateMatrix(vec4(0.f, 0.f, 1.f * sin(pi / 2.f), 1.f * cos(pi / 2.f)));
}
RotateMatrix(vec4(0.f, 1.f * sin(pi / 2.f), 0.f, 1.f * cos(pi / 2.f)));
TranslateMatrix(-CamPos);
CamModelViewMatrix = ModelviewMatrixStack.top();