This commit is contained in:
RedShip
2025-01-10 21:31:55 +01:00
parent 9aa1de378f
commit 08fb9c37ad
8 changed files with 181 additions and 181 deletions

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */ /* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */ /* Created: 2024/12/23 18:30:18 by ycontre #+# #+# */
/* Updated: 2024/12/23 18:46:13 by ycontre ### ########.fr */ /* Updated: 2025/01/10 18:58:38 by ycontre ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -59,7 +59,7 @@ class Scene
void updateGPUData(); void updateGPUData();
const std::vector<GPUObject> &getObjectData() const; const std::vector<GPUObject> &getObjectData() const;
const std::vector<GPUMaterial> &getMaterialData() const; std::vector<GPUMaterial> &getMaterialData();
Camera *getCamera(void) const; Camera *getCamera(void) const;
Material *getMaterial(int material_index); Material *getMaterial(int material_index);

View File

@ -20,5 +20,5 @@ pl -3 0 0 1 0 0 3
pl 0 0 -3 0 0 1 4 pl 0 0 -3 0 0 1 4
pl 0 0 3 0 0 -1 2 pl 0 0 3 0 0 -1 2
po -0.33 -0.66 -1 0 1 0 0.5 0.5 0 0 2 po -0.33 -0.66 -1 0 1 0 0.5 0.5 -0.5 0 2
po -0.5 -0.5 1 0 1 0 1 0 0 1 4 po -0.5 -0.5 1 0 1 0 1 0 0 1 4

View File

@ -1,8 +1,8 @@
CAM -0.0970577 1.63916 1.69444 -13.6 -84 0 1 CAM -0.0970577 1.63916 1.69444 -13.6 -84 0 4
MAT 200 200 200 0.0 0.0 0.0 //white MAT 200 200 200 0.0 0.0 0.0 //white
MAT 255 50 50 0.0 1.0 0.0 //red MAT 255 50 50 0.0 1.0 1.0 //red
MAT 50 255 50 0.0 0.0 0.0 //green MAT 50 255 50 0.0 0.0 0.0 //green
MAT 100 100 255 0.0 0.0 0.0 //blue MAT 100 100 255 0.0 0.0 0.0 //blue
MAT 255 100 255 0.0 0.0 0.0 //purple MAT 255 100 255 0.0 0.0 0.0 //purple

View File

@ -38,17 +38,17 @@ struct GPUCamera
float focus_distance; float focus_distance;
}; };
layout(std430, binding = 1) buffer ObjectBuffer layout(std430, binding = 0) buffer ObjectBuffer
{ {
GPUObject objects[]; GPUObject objects[];
}; };
layout(std430, binding = 2) buffer MaterialBuffer layout(std430, binding = 1) buffer MaterialBuffer
{ {
GPUMaterial materials[]; GPUMaterial materials[];
}; };
layout(std140) uniform CameraData layout(std140, binding = 0) uniform CameraData
{ {
GPUCamera camera; GPUCamera camera;
}; };

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */ /* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */ /* Created: 2024/09/27 14:51:49 by TheRed #+# #+# */
/* Updated: 2025/01/09 16:17:29 by tomoron ### ########.fr */ /* Updated: 2025/01/10 19:12:40 by ycontre ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -44,7 +44,7 @@ int main(int argc, char **argv)
glGetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_gpu_size); glGetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_gpu_size);
const std::vector<GPUObject> &object_data = scene.getObjectData(); const std::vector<GPUObject> &object_data = scene.getObjectData();
const std::vector<GPUMaterial> &material_data = scene.getMaterialData(); std::vector<GPUMaterial> &material_data = scene.getMaterialData();
std::cout << "Sending " << object_data.size() << " objects for " << \ std::cout << "Sending " << object_data.size() << " objects for " << \
object_data.size() * sizeof(GPUObject) + material_data.size() * sizeof(GPUMaterial) \ object_data.size() * sizeof(GPUObject) + material_data.size() * sizeof(GPUMaterial) \
<< " / " << max_gpu_size << " bytes" << std::endl; << " / " << max_gpu_size << " bytes" << std::endl;
@ -56,11 +56,11 @@ int main(int argc, char **argv)
glBindBuffer(GL_SHADER_STORAGE_BUFFER, objectSSBO); glBindBuffer(GL_SHADER_STORAGE_BUFFER, objectSSBO);
glBufferData(GL_SHADER_STORAGE_BUFFER, object_data.size() * sizeof(GPUObject), object_data.data(), GL_DYNAMIC_DRAW); glBufferData(GL_SHADER_STORAGE_BUFFER, object_data.size() * sizeof(GPUObject), object_data.data(), GL_DYNAMIC_DRAW);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, objectSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, objectSSBO);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, materialSSBO); glBindBuffer(GL_SHADER_STORAGE_BUFFER, materialSSBO);
glBufferData(GL_SHADER_STORAGE_BUFFER, material_data.size() * sizeof(GPUMaterial), material_data.data(), GL_DYNAMIC_DRAW); glBufferData(GL_SHADER_STORAGE_BUFFER, material_data.size() * sizeof(GPUMaterial), material_data.data(), GL_DYNAMIC_DRAW);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, materialSSBO); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, materialSSBO);
GPUCamera camera_data = scene.getCamera()->getGPUData(); GPUCamera camera_data = scene.getCamera()->getGPUData();
glBindBuffer(GL_UNIFORM_BUFFER, cameraUBO); glBindBuffer(GL_UNIFORM_BUFFER, cameraUBO);

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */ /* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/23 18:29:41 by ycontre #+# #+# */ /* Created: 2024/12/23 18:29:41 by ycontre #+# #+# */
/* Updated: 2025/01/08 20:08:03 by ycontre ### ########.fr */ /* Updated: 2025/01/10 18:58:57 by ycontre ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -153,7 +153,7 @@ const std::vector<GPUObject>& Scene::getObjectData() const
return (_gpu_objects); return (_gpu_objects);
} }
const std::vector<GPUMaterial>& Scene::getMaterialData() const std::vector<GPUMaterial>& Scene::getMaterialData()
{ {
return (_gpu_materials); return (_gpu_materials);
} }

View File

@ -6,7 +6,7 @@
/* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */ /* By: ycontre <ycontre@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/13 20:21:13 by ycontre #+# #+# */ /* Created: 2024/10/13 20:21:13 by ycontre #+# #+# */
/* Updated: 2024/10/14 19:52:40 by ycontre ### ########.fr */ /* Updated: 2025/01/10 18:53:39 by ycontre ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */