diff --git a/includes/RT/Window.hpp b/includes/RT/Window.hpp index 7bac10a..2d15585 100644 --- a/includes/RT/Window.hpp +++ b/includes/RT/Window.hpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/13 16:15:41 by TheRed #+# #+# */ -/* Updated: 2025/02/15 22:54:27 by tomoron ### ########.fr */ +/* Updated: 2025/02/25 18:12:37 by ycontre ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,6 +30,8 @@ class Window bool shouldClose(); void process_input(); + + void reduceTimeFrame(); static void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods); static void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos); diff --git a/includes/RT/sansnom.hpp b/includes/RT/sansnom.hpp new file mode 100644 index 0000000..6d6372e --- /dev/null +++ b/includes/RT/sansnom.hpp @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* sansnom.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ycontre +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/02/19 18:04:15 by ycontre #+# #+# */ +/* Updated: 2025/02/19 18:19:47 by ycontre ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef ashf +# define ashf + +class RT +{ + public: + RT(Arguments &args, Window &window); + ~RT(); + + private: + Window &window; + GLuint VAO; + std::vector &textures; + + Scene *scene; + + ShaderProgram raytracing_program; +}; + +#endif diff --git a/shaders/raytracing.glsl b/shaders/raytracing.glsl index e94eda5..c5081af 100644 --- a/shaders/raytracing.glsl +++ b/shaders/raytracing.glsl @@ -216,7 +216,7 @@ vec3[2] pathtrace(Ray ray, inout uint rng_state) color /= max(p, 0.001); GPUMaterial mat = materials[hit.mat_index]; - calculateLightColor(mat, hit, color, light, rng_state); + calculateLightColor(mat, hit, color, light, rng_state, ray); if (mat.emission > 0.0 && mat.emission_texture_index == -1) break; diff --git a/srcs/RT.cpp b/srcs/RT.cpp index 5f799e8..9030501 100644 --- a/srcs/RT.cpp +++ b/srcs/RT.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */ -/* Updated: 2025/02/15 22:54:52 by tomoron ### ########.fr */ +/* Updated: 2025/02/25 18:26:41 by ycontre ### ########.fr */ /* */ /* ************************************************************************** */ @@ -83,6 +83,8 @@ int main(int argc, char **argv) raytracing_program.set_float("u_time", (float)(glfwGetTime())); raytracing_program.set_vec2("u_resolution", glm::vec2(WIDTH, HEIGHT)); + window.reduceTimeFrame(); + std::map> object_textures; object_textures["textures"] = scene.getTextureIDs(); object_textures["emissive_textures"] = scene.getEmissionTextureIDs(); diff --git a/srcs/class/ObjParser.cpp b/srcs/class/ObjParser.cpp index 7eb3fa0..3938e36 100644 --- a/srcs/class/ObjParser.cpp +++ b/srcs/class/ObjParser.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/01/16 15:00:33 by tomoron #+# #+# */ -/* Updated: 2025/02/06 02:19:50 by tomoron ### ########.fr */ +/* Updated: 2025/02/25 17:53:46 by ycontre ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,7 +62,7 @@ glm::vec3 ObjParser::getNormals(std::stringstream &line) { glm::vec3 res; - if(!(line >> res.x) || !(line >> res.y) || (!(line >> res.z)) && !line.eof()) + if((!(line >> res.x) || !(line >> res.y) || !(line >> res.z)) && !line.eof()) throw std::runtime_error("syntax error in obj file while parsing normal vertex"); return(res); } diff --git a/srcs/class/Window.cpp b/srcs/class/Window.cpp index b87704a..7c0968d 100644 --- a/srcs/class/Window.cpp +++ b/srcs/class/Window.cpp @@ -6,7 +6,7 @@ /* By: ycontre +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */ -/* Updated: 2025/02/17 21:40:43 by tomoron ### ########.fr */ +/* Updated: 2025/02/25 18:44:36 by ycontre ### ########.fr */ /* */ /* ************************************************************************** */ @@ -368,7 +368,7 @@ int Window::getPixelisation(void) if (mouse || movement) { - if(_fps < 30 && _pixelisation < 16) + if(_fps > 15 && _fps < 30 && _pixelisation < 8) _pixelisation++; if(_fps > 60 && _pixelisation > 0) _pixelisation--; @@ -377,3 +377,31 @@ int Window::getPixelisation(void) _pixelisation = 0; return (_pixelisation + 1); } + +void Window::reduceTimeFrame() +{ + static bool was_moving = false; + static int previous_bounce = _scene->getCamera()->getBounce(); + + bool mouse = glfwGetMouseButton(_window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS; + bool movement = _scene->getCamera()->getVelocity() > 0.0f; + + bool is_moving = mouse || movement; + bool has_moved = is_moving != was_moving; + + if (has_moved && is_moving && _fps < 15) + { + previous_bounce = _scene->getCamera()->getBounce(); + + _scene->getCamera()->setBounce(1); + _output_texture = 7; + } + + if (has_moved && !is_moving) + { + _scene->getCamera()->setBounce(previous_bounce); + _output_texture = 0; + } + + was_moving = is_moving; +}