+ | Pixelisation when moving

This commit is contained in:
TheRedShip
2025-01-10 23:44:17 +01:00
parent bd2a371b50
commit e46f41a4b4
7 changed files with 33 additions and 7 deletions

View File

@ -19,7 +19,7 @@ int main(int argc, char **argv)
if (argc <= 1 || !scene.parseScene(argv[1]))
return (1);
Window window(&scene, WIDTH, HEIGHT, "RT_GPU", 0);
Window window(&scene, WIDTH, HEIGHT, "RT_GPU", 5);
Shader shader("shaders/vertex.vert", "shaders/frag.frag", "shaders/compute.glsl");
GLint max_gpu_size;
@ -72,6 +72,7 @@ int main(int argc, char **argv)
shader.set_int("u_frameCount", window.getFrameCount());
shader.set_int("u_objectsNum", object_data.size());
shader.set_int("u_pixelisation", window.getPixelisation() * 10 + 1);
shader.set_float("u_time", (float)(glfwGetTime()));
shader.set_vec2("u_resolution", glm::vec2(WIDTH, HEIGHT));

View File

@ -117,6 +117,11 @@ GPUCamera Camera::getGPUData()
return (data);
}
float Camera::getVelocity()
{
return (glm::length(_velocity));
}
void Camera::setPosition(glm::vec3 position)
{
_position = position;

View File

@ -162,3 +162,13 @@ int Window::getFrameCount(void) const
{
return (_frameCount);
}
int Window::getPixelisation(void)
{
bool mouse = glfwGetMouseButton(_window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS;
bool movement = _scene->getCamera()->getVelocity() > 0.0f;
if (mouse || movement)
return (1);
return (0);
}