From f1230ea24dc87a3bb5c9c709d4571e3298d7d07f Mon Sep 17 00:00:00 2001 From: Sebastian Park Date: Thu, 9 May 2024 17:32:19 -0400 Subject: Render normals to the ocean floor. --- .DS_Store | Bin 10244 -> 10244 bytes CMakeLists.txt.user | 2 +- resources/shaders/color.frag | 15 ++++++++------- resources/shaders/color.vert | 3 ++- src/arap.cpp | 42 +++--------------------------------------- src/arap.h | 4 +--- 6 files changed, 15 insertions(+), 51 deletions(-) diff --git a/.DS_Store b/.DS_Store index fd5deb0..d61e93a 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index f9d8bd9..b8e5e0a 100644 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/resources/shaders/color.frag b/resources/shaders/color.frag index fe70983..7c41c89 100644 --- a/resources/shaders/color.frag +++ b/resources/shaders/color.frag @@ -13,16 +13,16 @@ in float intensity; //uniform float intExp = 0.5f; //uniform float scale = 1.f; -uniform float multiplier = .9f; -uniform float contrast = 20.f; -uniform float intExp = 0.f; -uniform float scale = 1.f; - -//uniform float multiplier = .5f; -//uniform float contrast = 1.5f; +//uniform float multiplier = .9f; +//uniform float contrast = 20.f; //uniform float intExp = 0.f; //uniform float scale = 1.f; +uniform float multiplier = .5f; +uniform float contrast = 1.5f; +uniform float intExp = 0.f; +uniform float scale = 1.f; + //uniform vec4 baseColor =vec4(); void main() { @@ -39,4 +39,5 @@ void main() { finalInt = clamp(finalInt, 0, 1); fragColor = vec4(1, 1, 1, finalInt * scale); // fragColor = vec4(vec3(1), pow(oldArea / newArea * .2f, 1.5f)); + fragColor = vec4((normal_worldSpace + 1) / 2, 1.f); } diff --git a/resources/shaders/color.vert b/resources/shaders/color.vert index 677abf6..d607ff9 100644 --- a/resources/shaders/color.vert +++ b/resources/shaders/color.vert @@ -4,7 +4,7 @@ layout(location = 0) in vec3 position; // Position of the vertex layout(location = 1) in vec3 normal; // Normal of the vertex layout(location = 2) in vec3 texCoords; // Normal of the vertex -uniform float depth = -3000.f; +uniform float depth = -1000.f; uniform float skyHeight = 500.f; uniform mat4 proj; uniform mat4 view; @@ -89,4 +89,5 @@ void main() { oldPosFlat = moveToTopDown(position); pos = moveToTopDown(vec3(refractedPositionAndProb)); gl_Position = vec4(pos, 1.f); + gl_Position = vec4(oldPosFlat, 1.f); } diff --git a/src/arap.cpp b/src/arap.cpp index 2f10849..e1ab1ca 100644 --- a/src/arap.cpp +++ b/src/arap.cpp @@ -51,42 +51,6 @@ void ARAP::init minCorner = coeffMin; maxCorner = coeffMax; - - -// m_shape.initGroundPlane("cornell_box_full_lighting.png") -// QImage ocean_floor_image; -// GLuint ocean_floor_texture; -// // Prepare filepath -// QString ocean_floor_filepath = QString(":/resources/images/kitten.png"); - -// // TASK 1: Obtain image from filepath -// ocean_floor_image = QImage(ocean_floor_filepath); - -// // TASK 2: Format image to fit OpenGL -// ocean_floor_image = ocean_floor_image.convertToFormat(QImage::Format_RGBA8888).mirrored(); - -// // TASK 3: Generate kitten texture -// glGenTextures(1, &ocean_floor_texture); - -// // TASK 9: Set the active texture slot to texture slot 0 -// glActiveTexture(GL_TEXTURE0); - -// // TASK 4: Bind kitten texture -// glBindTexture(GL_TEXTURE_2D, ocean_floor_texture); - -// // TASK 5: Load image into kitten texture -// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ocean_floor_image.width(), ocean_floor_image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, ocean_floor_image.bits()); - -// // TASK 6: Set min and mag filters' interpolation mode to linear -// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); -// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - -// // TASK 7: Unbind kitten texture -// glBindTexture(GL_TEXTURE_2D, 0); - -// // TASK 10: set the texture.frag uniform for our texture -// glUseProgram(m_texture_shader); -// glUniform1i(glGetUniformLocation(m_texture_shader, "sampler"), 0); } void ARAP::update(double seconds) @@ -104,12 +68,12 @@ void ARAP::update(double seconds) // the last update m_ocean.fft_prime(m_time); - // m_shape.setVertices_and_Normals(m_ocean.get_vertices(), m_ocean.getNormals()); - m_shape.setVertices(m_ocean.get_vertices()); +// m_shape.setVertices_and_Normals(m_ocean.get_vertices(), m_ocean.getNormals()); + m_shape.setVertices(m_ocean.get_vertices()); m_time += m_timestep; - // std::cout << m_time << std::endl; +// std::cout << m_time << std::endl; } // Move an anchored vertex, defined by its index, to targetPosition diff --git a/src/arap.h b/src/arap.h index 331cc3d..7c8c76a 100644 --- a/src/arap.h +++ b/src/arap.h @@ -38,8 +38,6 @@ public: void draw(Shader *shader, GLenum mode) { - - m_shape.draw(shader, mode); } @@ -84,7 +82,7 @@ public: ocean_alt m_ocean; double m_time = 0.00; - double m_timestep = 0.03; + double m_timestep = 0.1; Eigen::Vector3f minCorner, maxCorner; }; -- cgit v1.2.3-70-g09d2 From 481e582be02385271f87524bfe46d6c41654e23c Mon Sep 17 00:00:00 2001 From: Sebastian Park Date: Thu, 9 May 2024 22:02:12 -0400 Subject: "raytraced" caustics. --- .DS_Store | Bin 10244 -> 10244 bytes CMakeLists.txt | 6 ++-- resources/shaders/caustics.frag | 20 +++++++++++++ resources/shaders/caustics.vert | 53 +++++++++++++++++++++++++++++++++ resources/shaders/shader.frag | 3 +- src/arap.cpp | 63 ++++++++++++++++++++++++++++++++++++++++ src/arap.h | 6 +++- src/glwidget.cpp | 61 +++++++++++++++++++++++++++++++++++--- src/glwidget.h | 7 +++++ 9 files changed, 211 insertions(+), 8 deletions(-) create mode 100644 resources/shaders/caustics.frag create mode 100644 resources/shaders/caustics.vert diff --git a/.DS_Store b/.DS_Store index d61e93a..69d2a61 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d35a8d..81eca1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ add_executable(${PROJECT_NAME} src/graphics/meshloader.cpp src/graphics/shader.cpp src/graphics/shape.cpp + src/graphics/simpleshape.cpp # src/graphics/oceanshape.cpp src/mainwindow.h @@ -47,6 +48,7 @@ add_executable(${PROJECT_NAME} src/graphics/meshloader.h src/graphics/shader.h src/graphics/shape.h + src/graphics/simpleshape.h # src/graphics/oceanshape.h util/tiny_obj_loader.h @@ -102,8 +104,8 @@ qt6_add_resources(${PROJECT_NAME} "Resources" resources/shaders/texture.frag resources/shaders/color.vert resources/shaders/color.frag - - + resources/shaders/caustics.vert + resources/shaders/caustics.frag ) # GLEW: this provides support for Windows (including 64-bit) diff --git a/resources/shaders/caustics.frag b/resources/shaders/caustics.frag new file mode 100644 index 0000000..f746896 --- /dev/null +++ b/resources/shaders/caustics.frag @@ -0,0 +1,20 @@ +#version 410 core +out vec4 fragColor; + +in vec3 normal_worldSpace; +in vec3 pos; +in vec3 newPos; +in vec4 col; +in float refractProb; + +uniform sampler2D normSamp; + +void main() { +// fragColor = vec4(vec3((pos[0] + 1) / 2, (pos[1] + 1) / 2, 0.f), 1.f); + float oldArea = length(dFdx(vec3(pos[0], pos[2], pos[1]))) * length(dFdy(vec3(pos[0], pos[2], pos[1]))); + float newArea = length(dFdx(vec3(newPos[0], newPos[2], newPos[1]))) * length(dFdy(vec3(newPos[0], newPos[2], newPos[1]))); + float areaRatio = oldArea / newArea; + float intensity = pow(areaRatio * .3f, 1.5f); + fragColor = vec4(0.98, 1, .78, intensity * refractProb); +// fragColor = col; +} diff --git a/resources/shaders/caustics.vert b/resources/shaders/caustics.vert new file mode 100644 index 0000000..298f5e1 --- /dev/null +++ b/resources/shaders/caustics.vert @@ -0,0 +1,53 @@ +#version 330 core + +layout(location = 0) in vec3 position; // Position of the vertex +layout(location = 1) in vec3 normal; // Normal of the vertex +layout(location = 2) in vec3 texCoords; // Normal of the vertex + +uniform float depth = -1000.f; +uniform float skyHeight = 500.f; + +uniform sampler2D normSamp; + +out vec3 normal_worldSpace; +out vec3 pos; +out vec3 newPos; +out vec4 col; +out float refractProb; + +vec4 refractToFloor(vec3 l, vec3 p, vec3 n, float d) { + // Refracts incoming light direction l through normal n at point p until hits floor at depth d + vec3 w_o = normalize(l); + float cos_theta_i = dot(-w_o, n); + float n_i = 1; + float n_t = 1.33f; + float determinant = 1.f - (pow((n_i / n_t), 2.f) * (1.f - pow(cos_theta_i, 2.f))); + + float r0 = pow((n_i - n_t) / (n_i + n_t), 2.f); // variable required to calculate probability of reflection + float prob_to_refl = r0 + ((1 - r0) * pow((1 - cos_theta_i), 5.f)); + + if (determinant >= 0) { + float cos_theta_t = sqrt(determinant); + vec3 w_t = (n_i / n_t) * w_o + ((n_i / n_t) * cos_theta_i - cos_theta_t) * n; + float dist = p.z - d; + float depthScale = dist / w_t.z; +// vec3 groundContactPoint = -(w_t * depthScale) + p; + vec3 groundContactPoint = (w_t * depthScale) + p; + return vec4(groundContactPoint, 1.f - prob_to_refl); + } else { + return vec4(0, 0, 0, 0); + } +} + +void main() { + normal_worldSpace = normal; + pos = position; + vec4 sampledNormal = texture(normSamp, vec2((pos + 1) / 2)); + sampledNormal = (sampledNormal * 2.f) - 1.f; + col = sampledNormal; + vec4 newPosAndProb = refractToFloor(vec3(0, 0, 1), pos, normalize(vec3(sampledNormal)), 0.01f); + newPos = vec3(newPosAndProb[0], newPosAndProb[1], 0.f); + refractProb = newPosAndProb[3]; +// newPos = pos; + gl_Position = vec4(newPos, 1.f); +} diff --git a/resources/shaders/shader.frag b/resources/shaders/shader.frag index 88c783d..2bc8043 100755 --- a/resources/shaders/shader.frag +++ b/resources/shaders/shader.frag @@ -71,7 +71,8 @@ void main() { vec2 reflUV = uvFromWorldPoint(reflPos); // float waterMurkiness = 0.002f; // TODO: Make uniform - float waterMurkiness = 0.0005f; // TODO: Make uniform +// float waterMurkiness = 0.0005f; // TODO: Make uniform + float waterMurkiness = 0.f; // TODO: Make uniform vec3 waterVolumeColor = vec3(red * 0.1f, green * 0.2f, blue * 0.2f); float murkDiffuse = 0.3f; float murkAmbient = 0.8f; diff --git a/src/arap.cpp b/src/arap.cpp index e1ab1ca..ae7240d 100644 --- a/src/arap.cpp +++ b/src/arap.cpp @@ -51,6 +51,8 @@ void ARAP::init minCorner = coeffMin; maxCorner = coeffMax; + + initCausticsShape(10); } void ARAP::update(double seconds) @@ -98,3 +100,64 @@ void ARAP::move // - Minus and equal keys (click repeatedly) to change the size of the vertices } +void ARAP::initCausticsShape(int res) { +// std::vector gridPoints; +// float step = 2.f / ((float) res); + +// for (int i = 0; i < res; ++i) { +// for (int j = 0; j < res; ++j) { +// float x = -1.f + i * step; // calculate x coordinate +// float y = -1.f + j * step; // calculate y coordinate +// gridPoints.push_back(Eigen::Vector3f(x, y, 0.f)); // add point to grid +// } +// } +// std::vector verts; +// float step = 2.f / ((float) res); + +// for (int i = 0; i < res; ++i) { +// for (int j = 0; j < res; ++j) { +// float x = -1.f + i * step; // calculate x coordinate +// float y = -1.f + j * step; // calculate y coordinate +// Eigen::Vector3f bottomLeft = Eigen::Vector3f(x, y, 0.f); +// Eigen::Vector3f bottomRight = Eigen::Vector3f(x + step, y, 0.f); +// Eigen::Vector3f topRight = Eigen::Vector3f(x + step, y + step, 0.f); +// Eigen::Vector3f topLeft = Eigen::Vector3f(x, y + step, 0.f); +// verts.push_back(topLeft); +// verts.push_back(bottomLeft); +// verts.push_back(bottomRight); +// verts.push_back(topLeft); +// verts.push_back(bottomRight); +// verts.push_back(topRight); +// } +// } +// m_causticsShape.setVertices(verts); + std::vector verts; + std::vector faces; + float size = 2.f; + float step = size / ((float) res); + + for (int i = 0; i <= res; ++i) { + for (int j = 0; j <= res; ++j) { + float x = -(size / 2.f) + i * step; // calculate x coordinate + float y = -(size / 2.f) + j * step; // calculate y coordinate + Eigen::Vector3f bottomLeft = Eigen::Vector3f(x, y, 0.f); + verts.push_back(bottomLeft); + } + } + + for (int i = 0; i < res; ++i) { + for (int j = 0; j < res; ++j) { + int bottomLeft = i * (res + 1) + j; + int bottomRight = i * (res + 1) + j + 1; + int topRight = (i + 1) * (res + 1) + j + 1; + int topLeft = (i + 1) * (res + 1) + j; + faces.push_back(Eigen::Vector3i(topLeft, bottomLeft, bottomRight)); + faces.push_back(Eigen::Vector3i(topLeft, bottomRight, topRight)); + faces.push_back(Eigen::Vector3i(bottomRight, bottomLeft, topLeft)); + faces.push_back(Eigen::Vector3i(topRight, bottomRight, topLeft)); + } + } + m_causticsShape.init(verts, faces); + m_causticsShape.setColor(0.27f, .803f, .96f); +} + diff --git a/src/arap.h b/src/arap.h index 7c8c76a..2c768bb 100644 --- a/src/arap.h +++ b/src/arap.h @@ -1,6 +1,7 @@ #pragma once #include "graphics/shape.h" +//#include "graphics/simpleshape.h" //#include "graphics/oceanshape.h" #include "Eigen/StdList" #include "Eigen/StdVector" @@ -20,7 +21,7 @@ class ARAP private: Shape m_shape; // OceanShape m_oceanShape; - + void initCausticsShape(int res); public: ARAP(); @@ -38,6 +39,7 @@ public: void draw(Shader *shader, GLenum mode) { +// m_causticsShape.draw(shader, mode); m_shape.draw(shader, mode); } @@ -85,5 +87,7 @@ public: double m_timestep = 0.1; Eigen::Vector3f minCorner, maxCorner; + + Shape m_causticsShape; }; diff --git a/src/glwidget.cpp b/src/glwidget.cpp index bac695c..62d8482 100755 --- a/src/glwidget.cpp +++ b/src/glwidget.cpp @@ -67,7 +67,7 @@ void GLWidget::initializeGL() glClearColor(1, 0.98f, 0.85f, 1); // Enable depth-testing and backface culling - glEnable(GL_DEPTH_TEST); +// glEnable(GL_DEPTH_TEST); // glEnable(GL_CULL_FACE); // glCullFace(GL_BACK); // glShadeModel(GL_SMOOTH); @@ -78,7 +78,7 @@ void GLWidget::initializeGL() m_pointShader = new Shader(":resources/shaders/anchorPoint.vert", ":resources/shaders/anchorPoint.geom", ":resources/shaders/anchorPoint.frag"); // m_texture_shader = new Shader(":/resources/shaders/texture.vert", ":/resources/shaders/texture.frag"); m_colorShader = new Shader(":resources/shaders/color.vert", ":resources/shaders/color.frag"); - + m_causticsShader = new Shader(":resources/shaders/caustics.vert", ":resources/shaders/caustics.frag"); initCaustics(); // INITIALIZE TEXTURE STUFF @@ -103,11 +103,12 @@ void GLWidget::initializeGL() m_devicePixelRatio = this->devicePixelRatio(); - m_defaultFBO = 2; + m_defaultFBO = 3; m_fbo_width = size().width() * m_devicePixelRatio; m_fbo_height = size().height() * m_devicePixelRatio; makeFBO(); + makeFBO1(); // FBO STUFF END @@ -171,7 +172,7 @@ void GLWidget::paintCaustics() { glClearColor(0.68f, 0.58f, 0.38f, 1); // glClearColor(0., 0., 0., 1); - glBindFramebuffer(GL_FRAMEBUFFER, m_fbo); + glBindFramebuffer(GL_FRAMEBUFFER, m_fbo1); // glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFBO); // Clear Screen @@ -189,6 +190,7 @@ void GLWidget::paintCaustics() { //// // Draw the VAO // glDrawArrays(GL_TRIANGLES, 0, 3); + m_colorShader->bind(); // m_colorShader->setUniform("proj", m_camera.getProjection()); @@ -205,6 +207,23 @@ void GLWidget::paintCaustics() { // Unbind the shader glUseProgram(0); + + m_causticsShader->bind(); + +// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBindFramebuffer(GL_FRAMEBUFFER, m_fbo_texture); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable( GL_BLEND ); + + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, m_fbo_texture1); + glUniform1i(glGetUniformLocation(m_causticsShader ->id(), "normSamp"), 2); + + m_arap.m_causticsShape.draw(m_causticsShader, GL_TRIANGLES); + glBindVertexArray(0); + glUseProgram(0); } void GLWidget::initCaustics() { @@ -307,7 +326,37 @@ void GLWidget::makeFBO() { // Task 22 glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFBO); +} +void GLWidget::makeFBO1() { + // Task 19 + glActiveTexture(GL_TEXTURE2); + glGenTextures(1, &m_fbo_texture1); + glBindTexture(GL_TEXTURE_2D, m_fbo_texture1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_fbo_width, m_fbo_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glBindTexture(GL_TEXTURE_2D, 0); + + // Task 20 + glGenRenderbuffers(1, &m_fbo_renderbuffer1); + glBindRenderbuffer(GL_RENDERBUFFER, m_fbo_renderbuffer1); + glRenderbufferStorage(GL_RENDERBUFFER, + GL_DEPTH24_STENCIL8, + m_fbo_width, + m_fbo_height); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + + // Task 18 + glGenFramebuffers(1, &m_fbo1); + glBindFramebuffer(GL_FRAMEBUFFER, m_fbo1); + + // Task 21 + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fbo_texture1, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_fbo_renderbuffer1); + + // Task 22 + glBindFramebuffer(GL_FRAMEBUFFER, m_defaultFBO); } void GLWidget::paintGL() @@ -356,7 +405,11 @@ void GLWidget::resizeGL(int w, int h) glDeleteTextures(1, &m_fbo_texture); glDeleteRenderbuffers(1, &m_fbo_renderbuffer); glDeleteFramebuffers(1, &m_fbo); + glDeleteTextures(1, &m_fbo_texture1); + glDeleteRenderbuffers(1, &m_fbo_renderbuffer1); + glDeleteFramebuffers(1, &m_fbo1); makeFBO(); + makeFBO1(); } // ================== Event Listeners diff --git a/src/glwidget.h b/src/glwidget.h index 810829a..f77c4ee 100755 --- a/src/glwidget.h +++ b/src/glwidget.h @@ -41,6 +41,7 @@ private: void keyReleaseEvent (QKeyEvent *event) override; void makeFBO(); + void makeFBO1(); void initCaustics(); void paintCaustics(); @@ -55,6 +56,7 @@ private: Shader *m_defaultShader; Shader *m_pointShader; Shader *m_texture_shader; + Shader *m_causticsShader; Shader *m_colorShader; @@ -70,6 +72,11 @@ private: GLuint m_fbo; GLuint m_fbo_texture; GLuint m_fbo_renderbuffer; + + GLuint m_fbo1; + GLuint m_fbo_texture1; + GLuint m_fbo_renderbuffer1; + GLuint m_defaultFBO; GLuint m_floor_vbo; -- cgit v1.2.3-70-g09d2 From 99c588d4da2ca044df8276b7efbd9d27c19c8352 Mon Sep 17 00:00:00 2001 From: Sebastian Park Date: Thu, 9 May 2024 22:39:25 -0400 Subject: Fix depth test thing. --- resources/shaders/shader.frag | 2 +- src/glwidget.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/shaders/shader.frag b/resources/shaders/shader.frag index 2bc8043..1b73b96 100755 --- a/resources/shaders/shader.frag +++ b/resources/shaders/shader.frag @@ -72,7 +72,7 @@ void main() { // float waterMurkiness = 0.002f; // TODO: Make uniform // float waterMurkiness = 0.0005f; // TODO: Make uniform - float waterMurkiness = 0.f; // TODO: Make uniform + float waterMurkiness = 0.0005f; // TODO: Make uniform vec3 waterVolumeColor = vec3(red * 0.1f, green * 0.2f, blue * 0.2f); float murkDiffuse = 0.3f; float murkAmbient = 0.8f; diff --git a/src/glwidget.cpp b/src/glwidget.cpp index 62d8482..1e9b26b 100755 --- a/src/glwidget.cpp +++ b/src/glwidget.cpp @@ -67,7 +67,7 @@ void GLWidget::initializeGL() glClearColor(1, 0.98f, 0.85f, 1); // Enable depth-testing and backface culling -// glEnable(GL_DEPTH_TEST); + glEnable(GL_DEPTH_TEST); // glEnable(GL_CULL_FACE); // glCullFace(GL_BACK); // glShadeModel(GL_SMOOTH); @@ -216,6 +216,7 @@ void GLWidget::paintCaustics() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); + glDisable( GL_DEPTH_TEST ); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, m_fbo_texture1); @@ -369,6 +370,7 @@ void GLWidget::paintGL() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); + glEnable(GL_DEPTH_TEST); m_defaultShader->bind(); m_defaultShader->setUniform("proj", m_camera.getProjection()); -- cgit v1.2.3-70-g09d2