Merge branch 'main' of github.com:TheRedShip/RT_GPU

This commit is contained in:
TheRedShip
2025-02-16 02:02:33 +01:00
5 changed files with 30 additions and 16 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */
/* Updated: 2025/02/14 18:26:34 by tomoron ### ########.fr */
/* Updated: 2025/02/15 22:54:52 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -74,7 +74,7 @@ int main(int argc, char **argv)
window.updateDeltaTime();
updateDataOnGPU(scene, buffers);
window.rendererUpdate(textures[0]);
window.rendererUpdate(textures, denoising_program);
glClear(GL_COLOR_BUFFER_BIT);
@ -94,7 +94,7 @@ int main(int argc, char **argv)
raytracing_program.dispathCompute((WIDTH + 15) / 16, (HEIGHT + 15) / 16, 1);
if (scene.getDenoise().enabled)
if (scene.getDenoise().enabled && !window.isRendering())
shaderDenoise(denoising_program, scene.getDenoise(), textures);
window.imGuiNewFrame();

View File

@ -6,12 +6,14 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/22 16:34:53 by tomoron #+# #+# */
/* Updated: 2025/02/13 19:03:34 by ycontre ### ########.fr */
/* Updated: 2025/02/15 22:51:54 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "RT.hpp"
void shaderDenoise(ShaderProgram &denoising_program, GPUDenoise &denoise, std::vector<GLuint> textures);
Renderer::Renderer(Scene *scene, Window *win, Arguments &args)
{
std::string *renderPath;
@ -300,7 +302,7 @@ void Renderer::initRender(void)
SWS_BILINEAR, nullptr, nullptr, nullptr);
}
void Renderer::addImageToRender(GLuint &texture)
void Renderer::addImageToRender(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram)
{
std::vector<float> image(WIDTH * HEIGHT * 4);
@ -308,7 +310,10 @@ void Renderer::addImageToRender(GLuint &texture)
long int videoFrameOffset;
long int outputImageOffset;
glBindTexture(GL_TEXTURE_2D, texture);
if(_scene->getDenoise().enabled)
shaderDenoise(denoisingProgram, _scene->getDenoise(), textures);
glBindTexture(GL_TEXTURE_2D, textures[0]);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, image.data());
glBindTexture(GL_TEXTURE_2D, 0);
@ -403,7 +408,7 @@ void Renderer::addPoint(float time)
_path.insert(pos, newPoint);
}
void Renderer::update(GLuint &texture)
void Renderer::update(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram)
{
double curTime;
@ -424,7 +429,7 @@ void Renderer::update(GLuint &texture)
if(!_testMode)
{
addImageToRender(texture);
addImageToRender(textures, denoisingProgram);
_frameCount++;
}
makeMovement(curTime - _curSplitStart, curTime);

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 16:16:24 by TheRed #+# #+# */
/* Updated: 2025/02/06 02:57:16 by tomoron ### ########.fr */
/* Updated: 2025/02/15 22:54:33 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
@ -160,6 +160,7 @@ void Window::display()
glfwSwapBuffers(_window);
}
void Window::pollEvents()
{
this->process_input();
@ -167,14 +168,20 @@ void Window::pollEvents()
glfwPollEvents();
}
bool Window::shouldClose()
{
return glfwWindowShouldClose(_window) || _renderer->shouldClose();
}
void Window::rendererUpdate(GLuint &texture)
bool Window::isRendering()
{
_renderer->update(texture);
return (_renderer->rendering());
}
void Window::rendererUpdate(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram)
{
_renderer->update(textures, denoisingProgram);
}
void Window::imGuiNewFrame()