Finally working cubemap

This commit is contained in:
Vladislav Khorev 2024-06-08 20:55:56 +03:00
parent d132060e19
commit f413bbe265
16 changed files with 406 additions and 119 deletions

View File

@ -169,11 +169,8 @@ TSimpleLandClass* TGameMap::GetLand()
void TGameMap::DrawVBO() void TGameMap::DrawVBO()
{ {
Renderer->PushShader("Simple3D");
Land->DrawVBO();
Renderer->PopShader();
//Land->DrawImmediate();
Land->DrawVBO();
for (TLiteModelArr::iterator i = StaticModelArr.begin(); i != StaticModelArr.end(); ++i) for (TLiteModelArr::iterator i = StaticModelArr.begin(); i != StaticModelArr.end(); ++i)
{ {
//i->DrawImmediate(); //i->DrawImmediate();

View File

@ -1,102 +1,109 @@
2024-Jun-06 15:57:24: Log started 2024-Jun-08 20:53:34: Log started
2024-Jun-06 15:57:25: OpenGL Window created 2024-Jun-08 20:53:34: OpenGL Window created
2024-Jun-06 15:57:25: Script manager ready 2024-Jun-08 20:53:34: Script manager ready
2024-Jun-06 15:57:25: Render::OpenGL glVersion = 4.6.0 - Build 31.0.101.4887 2024-Jun-08 20:53:34: Render::OpenGL glVersion = 4.6.0 - Build 31.0.101.4887
2024-Jun-06 15:57:25: Render::OpenGL glVersion above 2.0 ok 2024-Jun-08 20:53:34: Render::OpenGL glVersion above 2.0 ok
2024-Jun-06 15:57:25: Render::OpenGL GL_ARB_framebuffer_object supported ok 2024-Jun-08 20:53:34: Render::OpenGL GL_ARB_framebuffer_object supported ok
2024-Jun-06 15:57:25: Render::OpenGL GL_ARB_uniform_buffer_object supported ok 2024-Jun-08 20:53:34: Render::OpenGL GL_ARB_uniform_buffer_object supported ok
2024-Jun-06 15:57:25: Prepare to add shader GUI 2024-Jun-08 20:53:34: Prepare to add shader GUI
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 3 2024-Jun-08 20:53:34: Shader program is - 3
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: GUI 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: GUI
2024-Jun-06 15:57:25: Prepare to add shader Parallax 2024-Jun-08 20:53:34: Prepare to add shader Parallax
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20 WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20
WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20 WARNING: 0:27: 'assign' : implicit type conversion allowed from GLSL 1.20
WARNING: 0:27: 'assign' : implicit type conversion allowed WARNING: 0:27: 'assign' : implicit type conversion allowed
2024-Jun-06 15:57:25: Shader program is - 6 2024-Jun-08 20:53:34: Shader program is - 6
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Parallax 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Parallax
2024-Jun-06 15:57:25: Prepare to add shader Directlight 2024-Jun-08 20:53:34: Prepare to add shader Directlight
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 9 2024-Jun-08 20:53:34: Shader program is - 9
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Directlight 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Directlight
2024-Jun-06 15:57:25: Prepare to add shader Env 2024-Jun-08 20:53:34: Prepare to add shader Env
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 12 2024-Jun-08 20:53:34: Shader program is - 12
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Env 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Env
2024-Jun-06 15:57:25: Prepare to add shader Water 2024-Jun-08 20:53:34: Prepare to add shader Water
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
WARNING: 0:20: 'assign' : implicit type conversion allowed from GLSL 1.20 WARNING: 0:20: 'assign' : implicit type conversion allowed from GLSL 1.20
2024-Jun-06 15:57:25: Shader program is - 15 2024-Jun-08 20:53:34: Shader program is - 15
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Water 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Water
2024-Jun-06 15:57:25: Prepare to add shader Frame 2024-Jun-08 20:53:34: Prepare to add shader Frame
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 18 2024-Jun-08 20:53:34: Shader program is - 18
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Frame 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Frame
2024-Jun-06 15:57:25: Prepare to add shader Lightview 2024-Jun-08 20:53:34: Prepare to add shader Lightview
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:5: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:5: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 21 2024-Jun-08 20:53:34: Shader program is - 21
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Lightview 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Lightview
2024-Jun-06 15:57:25: Prepare to add shader Simple3D 2024-Jun-08 20:53:34: Prepare to add shader Simple3D
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader WARNING: 0:1: '' : #version directive missing
2024-Jun-06 15:57:25: Shader program is - 24 2024-Jun-08 20:53:34: Shader program is - 24
2024-Jun-06 15:57:25: ResourceManager::ShaderManager::Shader 2024-Jun-08 20:53:34: ResourceManager::ShaderManager::Shader
2024-Jun-06 15:57:25: ResourceManager::ShaderManager shader loaded: Simple3D 2024-Jun-08 20:53:34: ResourceManager::ShaderManager shader loaded: Simple3D
2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_box_yellow.bmp with id = 1 2024-Jun-08 20:53:34: ResourceManager::TexList Texture added: bt_box_yellow.bmp with id = 1
2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_box_norm.bmp32 with id = 2 2024-Jun-08 20:53:34: ResourceManager::TexList Texture added: bt_box_norm.bmp32 with id = 2
2024-Jun-06 15:57:25: Lite model added successfully: models/bt_box_yellow.lm1 2024-Jun-08 20:53:34: Lite model added successfully: models/bt_box_yellow.lm1
2024-Jun-06 15:57:25: ResourceManager::TexList Texture added: bt_cone.bmp with id = 3 2024-Jun-08 20:53:34: ResourceManager::TexList Texture added: bt_cone.bmp with id = 3
2024-Jun-06 15:57:25: Lite model added successfully: models/bt_cone.lm1 2024-Jun-08 20:53:34: Lite model added successfully: models/bt_cone.lm1
2024-Jun-06 15:57:25: Lite model added successfully: models/girl.lm1 2024-Jun-08 20:53:34: Lite model added successfully: models/girl.lm1
2024-Jun-06 15:57:25: Lite model added successfully: models/bonemodel.lm1 2024-Jun-08 20:53:34: Lite model added successfully: models/bonemodel.lm1
2024-Jun-06 15:57:26: ResourceManager::TexList Texture added: out.bmp with id = 4 2024-Jun-08 20:53:35: ResourceManager::TexList Texture added: out.bmp with id = 4
2024-Jun-06 15:57:26: FrameManager:: frame buffer added: Skybox 2024-Jun-08 20:53:35: FrameManager:: frame buffer added: Skybox
2024-Jun-06 15:57:26: ResourceManager::TexList Texture added: normalmap.bmp with id = 6 2024-Jun-08 20:53:35: ResourceManager::TexList Texture added: normalmap.bmp with id = 6
2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ScreenBlur 2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/posx.bmp
2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ShadowBufferGlobal 2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/negx.bmp
2024-Jun-06 15:57:26: FrameManager:: frame buffer added: ShadowBufferLocal 2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/posy.bmp
2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/negy.bmp
2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/posz.bmp
2024-Jun-08 20:53:35: Going to add texture: C:\Work\OldProjects\ho3\resources\../resources/negz.bmp
2024-Jun-08 20:53:35: ResourceManager::TexList texture added succesfuly: posx.bmp
2024-Jun-08 20:53:35: FrameManager:: frame buffer added: ScreenBlur
2024-Jun-08 20:53:35: FrameManager:: frame buffer added: ShadowBufferGlobal
2024-Jun-08 20:53:35: FrameManager:: frame buffer added: ShadowBufferLocal

View File

@ -10,6 +10,7 @@ cardinal CONST_CUBEMAP_UPDATE_INTERVAL = 5000;
void TMyApplication::DrawToCubemap() void TMyApplication::DrawToCubemap()
{ {
Renderer->PushPerspectiveProjectionMatrix(pi/2, 1.0, 1, 1000);
Renderer->PushShader("Directlight"); Renderer->PushShader("Directlight");
Renderer->SwitchToCubemapBuffer("Skybox",0); Renderer->SwitchToCubemapBuffer("Skybox",0);
@ -39,6 +40,8 @@ void TMyApplication::DrawToCubemap()
Renderer->SwitchToScreen(); Renderer->SwitchToScreen();
Renderer->PopShader(); Renderer->PopShader();
Renderer->PopProjectionMatrix();
} }
void TMyApplication::DrawToShadowMap() void TMyApplication::DrawToShadowMap()
@ -86,11 +89,33 @@ void TMyApplication::DrawWaterSurface()
Renderer->PopShader(); Renderer->PopShader();
} }
void TMyApplication::DrawCubemap()
{
Renderer->PushShader("Env");
Renderer->SetGLCamAngleView();
//Renderer->LoadIdentity();
RenderUniformMatrix3fv(CONST_STRING_MODELROTATEMATRIX_UNIFORM, false, (float*)IdentityMatrix.m);
RenderUniform3fv(CONST_STRING_MODELTRANSLATEVECTOR_UNIFORM, (float*)ZeroVec3.v);
glBindTexture(GL_TEXTURE_CUBE_MAP, ResourceManager->FrameManager.GetFrameTexture("Skybox"));
//glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
EnableVertexAttribArray("vPosition");
DrawVertexDataStruct(cubemapVertexDataStruct);
DisableVertexAttribArray("vPosition");
Renderer->PopShader();
}
//What to do on init //What to do on init
void TMyApplication::InnerInit() void TMyApplication::InnerInit()
{ {
ResourceManager->PathToResources = "C:\\Work\\OldProjects\\ho3\\resources\\"; ResourceManager->PathToResources = "C:\\Work\\OldProjects\\ho3\\resources\\";
glDisable(GL_CULL_FACE);
ResourceManager->ShaderManager.AddShader("GUI", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment"); ResourceManager->ShaderManager.AddShader("GUI", "shaders/gui_transparent.vertex", "shaders/gui_transparent.fragment");
ResourceManager->ShaderManager.AddShader("Parallax", "shaders/directlight_parallax_shadow.vertex", "shaders/directlight_parallax_shadow.fragment"); ResourceManager->ShaderManager.AddShader("Parallax", "shaders/directlight_parallax_shadow.vertex", "shaders/directlight_parallax_shadow.fragment");
@ -136,6 +161,13 @@ void TMyApplication::InnerInit()
ResourceManager->TexList.AddTexture("../resources/normalmap.bmp"); ResourceManager->TexList.AddTexture("../resources/normalmap.bmp");
std::array<std::string, 6> cubemapTextureStr = {
"../resources/posx.bmp", "../resources/negx.bmp", "../resources/posy.bmp", "../resources/negy.bmp", "../resources/posz.bmp", "../resources/negz.bmp"
};
cubemapTexture = ResourceManager->TexList.AddCubemapTexture(cubemapTextureStr);
//."posx.bmp","negx.bmp","posy.bmp","negy.bmp","posz.bmp","negz.bmp"
ResourceManager->FrameManager.AddFrameRenderBuffer("ScreenBlur", 512, 512); ResourceManager->FrameManager.AddFrameRenderBuffer("ScreenBlur", 512, 512);
ResourceManager->FrameManager.AddDepthBuffer("ShadowBufferGlobal", 512, 512); ResourceManager->FrameManager.AddDepthBuffer("ShadowBufferGlobal", 512, 512);
@ -151,9 +183,119 @@ void TMyApplication::InnerInit()
glClearColor(0.2f, 0.5f, 1.0f, 1.0f); glClearColor(0.2f, 0.5f, 1.0f, 1.0f);
//Renderer->SetShadowClampValue(0.3f); //Renderer->SetShadowClampValue(0.3f);
Renderer->SetShadowClampValue(0.0f); //Renderer->SetShadowClampValue(0.0f);
Renderer->SetFogBeginDistance(15.f);
Renderer->SetFogEndDistance(30.f);
// +x
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, 10.0f });
// -x
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, 10.0f });
// +y
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, 10.0f });
// -y
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, 10.0f });
// +z
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, 10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, 10.0f });
// -z
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, -10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ 10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.PositionData.push_back({ -10.0f, 10.0f, -10.0f });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.TexCoordData.push_back({ 0.0, 0.0 });
cubemapVertexDataStruct.RefreshVBO();
} }
@ -168,12 +310,64 @@ void TMyApplication::InnerDeinit()
void TMyApplication::InnerDraw() void TMyApplication::InnerDraw()
{ {
Renderer->SwitchToScreen(); Renderer->SwitchToScreen();
glClearColor(0.0f, 1.0f, 0.0f, 1.0f); glClearColor(0.2f, 0.55f, 1.0f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
Renderer->PushShader("GUI");
Renderer->PushShader("Directlight");
DrawToCubemap();
//Renderer->SwitchToCubemapBuffer("Skybox", 0);
//Renderer->SetGlPosXView();
//DrawSceneWithoutWater();
if (view == 6)
{
DrawCubemap();
}
else
{
Renderer->PushPerspectiveProjectionMatrix(pi / 2, 1.0, 1, 1000);
if (view == 0)
{
Renderer->SetGlNegZView();
}
else if (view == 1)
{
Renderer->SetGlNegYView();
}
else if (view == 2)
{
Renderer->SetGlPosXView();
}
else if (view == 3)
{
Renderer->SetGlNegXView();
}
else if (view == 4)
{
Renderer->SetGlPosZView();
}
else if (view == 5)
{
Renderer->SetGlPosYView();
}
DrawSceneWithoutWater();
Renderer->PopProjectionMatrix();
}
//DrawCubemap();
Renderer->PopShader();
/*
Renderer->PushShader("Directlight");
DrawSceneWithoutWater(); DrawSceneWithoutWater();
Renderer->PopShader(); Renderer->PopShader();
*/
//DrawToCubemap();
/* /*
DrawToCubemap(); DrawToCubemap();
@ -270,6 +464,11 @@ void TMyApplication::OnMouseDown(TMouseState& mouseState)
if (mouseState.LeftButtonPressed) if (mouseState.LeftButtonPressed)
{ {
MouseLeftButtonPressed = true; MouseLeftButtonPressed = true;
view += 1;
if (view == 7)
{
view = 0;
}
} }
} }

View File

@ -26,6 +26,8 @@ class TMyApplication : public SE::TApplication
int MouseX0, MouseY0; int MouseX0, MouseY0;
//Mouse pos caught on right button click //Mouse pos caught on right button click
int view = 0;
float WaterTimer; float WaterTimer;
void DrawSceneWithoutWater(); void DrawSceneWithoutWater();
@ -36,6 +38,11 @@ class TMyApplication : public SE::TApplication
void DrawWaterSurface(); void DrawWaterSurface();
void DrawCubemap();
cardinal cubemapTexture;
VertexDataStruct cubemapVertexDataStruct;
public: public:
//Constructor //Constructor

BIN
resources/negx.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

BIN
resources/negy.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

BIN
resources/negz.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

BIN
resources/posx.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

BIN
resources/posy.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

BIN
resources/posz.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 KiB

View File

@ -0,0 +1,36 @@
uniform sampler2D Texture;
uniform sampler2D NormalMap;
uniform int NormalMapExists;
uniform float FogBeginDistance;
uniform float FogEndDistance;
uniform vec4 FogColor;
varying vec2 texCoord;
varying vec3 camVec;
varying vec3 lightVec;
varying vec3 vertexPos;
void main()
{
vec3 lVec = lightVec;
vec3 cVec = normalize(camVec);
//go-go-go
vec3 TexRGB = texture2D(Texture, texCoord.xy).xyz;
vec3 norm = vec3(0.0,0.0,1.0);
float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess);
float light_coef = 1.0;
vec4 ambient = gl_LightSource[0].ambient;
vec4 diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * min( max(dot(lVec,norm),0.0), light_coef);
vec4 specular = gl_LightSource[0].specular * min(shineFactor, light_coef);
float fogFactor = min(max(max(abs(vertexPos.x)-FogBeginDistance, abs(vertexPos.z)-FogBeginDistance),0.0)/(FogEndDistance - FogBeginDistance),1.0);
gl_FragColor = mix(vec4(TexRGB,1.0)*ambient+(vec4(TexRGB,1.0)*diffuse+specular), FogColor, fogFactor);
}

View File

@ -0,0 +1,35 @@
uniform vec3 CamPos;
uniform mat3 ModelRotateMatrix;
uniform vec3 ModelTranslateVector;
attribute vec3 Tangent;
attribute vec3 Binormal;
varying vec2 texCoord;
varying vec3 camVec;
varying vec3 lightVec;
varying vec3 vertexPos;
void main()
{
vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * realVertexPos;
texCoord = gl_MultiTexCoord0.st;
vec3 lVec = normalize(gl_LightSource[0].position.xyz);
vec3 cVec = (CamPos - gl_Vertex.xyz);
vertexPos = gl_Vertex.xyz;
mat3 rot;
rot[0] = normalize(Tangent);
rot[1] = normalize(Binormal);
rot[2] = normalize(gl_Normal.xyz);
rot = ModelRotateMatrix * rot;
lightVec = lVec * rot;
camVec = cVec * rot;
}

View File

@ -1,36 +1,23 @@
uniform sampler2D Texture; uniform sampler2D Texture;
uniform sampler2D NormalMap;
uniform int NormalMapExists;
uniform float FogBeginDistance; uniform float FogBeginDistance;
uniform float FogEndDistance; uniform float FogEndDistance;
uniform vec4 FogColor;
varying vec2 texCoord; varying vec2 texCoord;
varying vec3 camVec;
varying vec3 lightVec;
varying vec3 vertexPos; varying vec3 vertexPos;
void main() void main()
{ {
vec3 lVec = lightVec; vec4 texColor = texture2D(Texture,texCoord).rgba;
vec3 cVec = normalize(camVec);
//go-go-go vec4 fogColor = vec4(0.25, 0.55, 1.0, 1.0);
vec3 TexRGB = texture2D(Texture, texCoord.xy).xyz;
vec3 norm = vec3(0.0,0.0,1.0); float fogDistCoef = (vertexPos.z - FogBeginDistance) / (FogEndDistance - FogBeginDistance);
float shineFactor = 15.0 * pow(max(dot(cVec, norm),0.0),gl_FrontMaterial.shininess) / (129.0 - gl_FrontMaterial.shininess); fogDistCoef = clamp(fogDistCoef, 0.0, 1.0);
float light_coef = 1.0; vec4 resultColor = mix(texColor, fogColor, fogDistCoef);
vec4 ambient = gl_LightSource[0].ambient; gl_FragColor = vec4(resultColor.rgb, 1.0);
vec4 diffuse = gl_FrontMaterial.diffuse * gl_LightSource[0].diffuse * min( max(dot(lVec,norm),0.0), light_coef);
vec4 specular = gl_LightSource[0].specular * min(shineFactor, light_coef);
float fogFactor = min(max(max(abs(vertexPos.x)-FogBeginDistance, abs(vertexPos.z)-FogBeginDistance),0.0)/(FogEndDistance - FogBeginDistance),1.0);
gl_FragColor = mix(vec4(TexRGB,1.0)*ambient+(vec4(TexRGB,1.0)*diffuse+specular), FogColor, fogFactor);
} }

View File

@ -1,35 +1,46 @@
uniform vec3 CamPos; attribute vec3 vPosition;
attribute vec2 vTexCoord;
uniform mat4 ProjectionMatrix;
uniform mat3 ModelRotateMatrix; uniform mat3 ModelRotateMatrix;
uniform vec3 ModelTranslateVector; uniform vec3 ModelTranslateVector;
attribute vec3 Tangent;
attribute vec3 Binormal;
varying vec2 texCoord; varying vec2 texCoord;
varying vec3 camVec;
varying vec3 lightVec;
varying vec3 vertexPos; varying vec3 vertexPos;
void main() void main()
{ {
vec4 realVertexPos = vec4(ModelRotateMatrix * gl_Vertex.xyz + ModelTranslateVector, 1.0); vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * realVertexPos; gl_Position = ProjectionMatrix * realVertexPos;
vertexPos = gl_Position.xyz;
texCoord = gl_MultiTexCoord0.st; texCoord = vTexCoord.st;
//vertexPos = vPosition.xyz;
//vec3 cVec = (CamPos - vPosition.xyz);
/*
vec3 lVec = normalize(gl_LightSource[0].position.xyz); vec3 lVec = normalize(gl_LightSource[0].position.xyz);
vec3 cVec = (CamPos - gl_Vertex.xyz); vec3 cVec = (CamPos - vPosition.xyz);
vertexPos = gl_Vertex.xyz; vertexPos = vPosition.xyz;
mat3 rot; vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
rot[0] = normalize(Tangent);
rot[1] = normalize(Binormal);
rot[2] = normalize(gl_Normal.xyz);
rot = ModelRotateMatrix * rot; // Используем производные для вычисления тангентного и бинормального вектора
vec3 dp1 = dFdx(vPosition.xyz);
vec3 dp2 = dFdy(vPosition.xyz);
vec2 duv1 = dFdx(vTexCoord.st);
vec2 duv2 = dFdy(vTexCoord.st);
lightVec = lVec * rot; vec3 tangent = normalize(dp1 * duv2.y - dp2 * duv1.y);
camVec = cVec * rot; vec3 binormal = normalize(dp2 * duv1.x - dp1 * duv2.x);
// Создаем матрицу тангенциального пространства
mat3 tbnMatrix = mat3(tangent, binormal, normal);
tbnMatrix = ModelRotateMatrix * tbnMatrix;
lightVec = lVec * tbnMatrix;
camVec = cVec * tbnMatrix;*/
} }

View File

@ -3,6 +3,7 @@ uniform samplerCube Env;
varying vec3 dir; varying vec3 dir;
void main(){ void main(){
gl_FragColor = textureCube(Env, dir); gl_FragColor = textureCube(Env, normalize(dir));
//gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
} }

View File

@ -1,7 +1,14 @@
attribute vec3 vPosition;
uniform mat4 ProjectionMatrix;
uniform mat3 ModelRotateMatrix;
uniform vec3 ModelTranslateVector;
varying vec3 dir; varying vec3 dir;
void main(){ void main(){
gl_Position = ftransform(); vec4 realVertexPos = vec4(ModelRotateMatrix * vPosition.xyz + ModelTranslateVector, 1.0);
gl_Position = ProjectionMatrix * realVertexPos;
dir = gl_Vertex.xyz; dir = -vPosition;
} }