+ | Fixing

This commit is contained in:
RedShip
2025-01-30 18:33:01 +01:00
parent 977b4eb63e
commit 28ba1a1dd0
7 changed files with 14 additions and 16 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 18:10:10 by TheRed #+# #+# */
/* Updated: 2024/10/14 19:51:46 by ycontre ### ########.fr */
/* Updated: 2025/01/30 17:52:20 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,7 +23,7 @@ class Shader
void attach(void);
void setupVertexBuffer();
void drawTriangles(size_t size);
void drawTriangles();
// void setBool(const std::string &name, bool value) const;
void set_int(const std::string &name, int value) const;
@ -52,6 +52,8 @@ class Shader
GLuint _fragment;
GLuint _compute;
size_t _size;
void checkCompileErrors(unsigned int shader);
};

View File

@ -1,6 +1,4 @@
TEX checker
MAT 255 255 255 4.0 0.0 0.0 //light
MAT 255 255 255 0.0 0.0 0.0 //white

View File

@ -65,8 +65,6 @@ cu -9 0.98 3 3 3 3 28
MAT 244 95 28 0.0 0.5 1.0
cu -9 1.23 -6 3 3 3 29
TEX texture.jpg // 0
MAT 200 20 20 0.0 1.0 0.05 LAM 0
MAT 255 255 255 0.0 1.8 0.0 DIE -1
MAT 255 255 255 0.0 1.0 1.0

View File

@ -186,9 +186,10 @@ vec3 pathtrace(Ray ray, inout uint rng_state)
}
#endif
float miss_condition = float(hit.obj_index == -1);
light += miss_condition * transmittance * GetEnvironmentLight(ray);
float p = max(color.r, max(color.g, color.b));
float rr_continue = float(randomValue(rng_state) <= p);

View File

@ -168,7 +168,7 @@ hitInfo traceRay(Ray ray)
hitInfo hitScene;
hitInfo hit;
#if 0
#if 1
for (int i = 0; i < 10; i++) // portal ray
{
hitBVH = traverseBVHs(ray);
@ -179,7 +179,6 @@ hitInfo traceRay(Ray ray)
break ;
ray = portalRay(ray, hit);
ray.inv_direction = (1.0 / ray.direction);
return (hit);
}
#else
hitBVH = traverseBVHs(ray);

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */
/* Updated: 2025/01/28 19:01:09 by ycontre ### ########.fr */
/* Updated: 2025/01/30 18:02:33 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -154,7 +154,7 @@ int main(int argc, char **argv)
window.imGuiNewFrame();
glUseProgram(shader.getProgram());
shader.drawTriangles(size);
shader.drawTriangles();
window.imGuiRender();

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 20:21:13 by ycontre #+# #+# */
/* Updated: 2025/01/24 19:13:13 by ycontre ### ########.fr */
/* Updated: 2025/01/30 17:52:32 by ycontre ### ########.fr */
/* */
/* ************************************************************************** */
@ -155,7 +155,7 @@ void Shader::setupVertexBuffer()
{
Vertex vertices[3] = {{{-1.0f, -1.0f}, {0.0f, 0.0f}},{{3.0f, -1.0f}, {2.0f, 0.0f}},{{-1.0f, 3.0f}, {0.0f, 2.0f}}};
size_t size = sizeof(vertices) / sizeof(Vertex) / 3;
_size = sizeof(vertices) / sizeof(Vertex) / 3;
glGenVertexArrays(1, &_screen_VAO);
glGenBuffers(1, &_screen_VBO);
@ -163,7 +163,7 @@ void Shader::setupVertexBuffer()
glBindVertexArray(_screen_VAO);
glBindBuffer(GL_ARRAY_BUFFER, _screen_VBO);
glBufferData(GL_ARRAY_BUFFER, size * 3 * sizeof(Vertex), vertices, GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, _size * 3 * sizeof(Vertex), vertices, GL_STATIC_DRAW);
// Position attribute
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);
@ -177,14 +177,14 @@ void Shader::setupVertexBuffer()
glBindVertexArray(0);
}
void Shader::drawTriangles(size_t size)
void Shader::drawTriangles()
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _output_texture);
glUniform1i(glGetUniformLocation(_program, "screenTexture"), 0);
glBindVertexArray(_screen_VAO);
glDrawArrays(GL_TRIANGLES, 0, size * 3);
glDrawArrays(GL_TRIANGLES, 0, _size * 3);
}
void Shader::set_int(const std::string &name, int value) const