diff options
author | Sebastian Park <SebPark03@gmail.com> | 2024-05-06 02:23:43 -0400 |
---|---|---|
committer | Sebastian Park <SebPark03@gmail.com> | 2024-05-06 02:23:43 -0400 |
commit | dcab788763ff0af5918ca0c50538daa8bbfc84d8 (patch) | |
tree | dc42bf81e8fcae01756c7fe4c2bfa58d3f521076 | |
parent | 85e2ef8c9d7cdb24715a7375e149d5d1e7d580b1 (diff) |
make depth and skyheight uniforms.
-rwxr-xr-x | resources/shaders/shader.vert | 9 | ||||
-rwxr-xr-x | src/glwidget.cpp | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/resources/shaders/shader.vert b/resources/shaders/shader.vert index 2d0bfe2..1409039 100755 --- a/resources/shaders/shader.vert +++ b/resources/shaders/shader.vert @@ -4,7 +4,8 @@ layout(location = 0) in vec3 position; // Position of the vertex layout(location = 1) in vec3 normal; // Normal of the vertex layout(location = 3) in vec3 texCoords; // Normal of the vertex - +uniform float depth = -1500.f; +uniform float skyHeight = 500.f; uniform mat4 proj; uniform mat4 view; uniform mat4 model; @@ -25,7 +26,7 @@ out vec2 uv; out float matIor; vec4 getRefrPos() { - float depth = -1000.f; // TODO: Pass as uniform +// float depth = -1000.f; // TODO: Pass as uniform vec3 w_o = normalize(pos - camera_worldSpace); float cos_theta_i = dot(-w_o, normal_worldSpace); float n_i = 1; @@ -55,11 +56,11 @@ vec4 getRefrPos() { } vec3 getReflPos() { - float depth = 500.f; // TODO: Pass as uniform +// float depth = 500.f; // TODO: Pass as uniform vec3 w_o = normalize(pos - camera_worldSpace); vec3 reflectedRay = w_o - 2 * dot(w_o, normal_worldSpace) * normal_worldSpace; - float dist = depth - position.y; + float dist = skyHeight - position.y; float depthScale = dist / reflectedRay.y; vec3 skyContactPoint = (reflectedRay * depthScale) + position; return skyContactPoint; diff --git a/src/glwidget.cpp b/src/glwidget.cpp index 06461d0..4c8696d 100755 --- a/src/glwidget.cpp +++ b/src/glwidget.cpp @@ -321,6 +321,7 @@ void GLWidget::paintGL() m_defaultShader->setUniform("widthBounds", m_arap.minCorner[0], m_arap.maxCorner[0]); m_defaultShader->setUniform("lengthBounds", m_arap.minCorner[2], m_arap.maxCorner[2]); + // Set the ocean floor to the painted caustics glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, m_fbo_texture); glUniform1i(glGetUniformLocation(m_defaultShader->id(), "groundSampler"), 2); |