summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Park <SebPark03@gmail.com>2024-05-09 17:32:19 -0400
committerSebastian Park <SebPark03@gmail.com>2024-05-09 17:32:19 -0400
commitf1230ea24dc87a3bb5c9c709d4571e3298d7d07f (patch)
tree99773c557a199bf8f79a84e9cb711d7dae55dfa1
parent3d9a55316dbcfb2ca1f32f5554d1948fcabb5d74 (diff)
Render normals to the ocean floor.
-rw-r--r--.DS_Storebin10244 -> 10244 bytes
-rw-r--r--CMakeLists.txt.user2
-rw-r--r--resources/shaders/color.frag15
-rw-r--r--resources/shaders/color.vert3
-rw-r--r--src/arap.cpp42
-rw-r--r--src/arap.h4
6 files changed, 15 insertions, 51 deletions
diff --git a/.DS_Store b/.DS_Store
index fd5deb0..d61e93a 100644
--- a/.DS_Store
+++ b/.DS_Store
Binary files 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 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 8.0.1, 2024-05-07T05:26:10. -->
+<!-- Written by QtCreator 8.0.1, 2024-05-09T03:00:17. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
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;
};