rough outline

This commit is contained in:
Dynamitos
2025-01-24 21:20:06 +01:00
parent a3a2dff869
commit ff9ebb916f
3 changed files with 42 additions and 25 deletions
+8 -15
View File
@@ -4,23 +4,16 @@
int main() int main()
{ {
BVH bvh; Scene scene;
bvh.addModels(ModelLoader::loadModel("../cube.fbx"), glm::mat4()); Window window;
bvh.generate();
Window w(1920, 1080);
std::vector<unsigned char> texture(1920 * 1080 * 3);
for (int j = 100; j < 200; ++j)
{
for (int i = 0; i < 1920; ++i)
{
texture[(j * 1920 + i) * 3] = 0xff;
texture[(j * 1920 + i) * 3 + 1] = 0xff;
texture[(j * 1920 + i) * 3 + 2] = 0x0;
}
}
while (true) while (true)
{ {
w.update(texture); // IMGUI....
if (Imgui.Button())
{
scene.render();
}
window.update(scene.getImage());
} }
return 0; return 0;
} }
+22 -10
View File
@@ -6,17 +6,29 @@ Scene::~Scene() {}
void Scene::render(int width, int height, int numSamples) void Scene::render(int width, int height, int numSamples)
{ {
image.clear(); worker = std::thread(
accumulator.clear(); [&]()
image.resize(width * height * 3);
accumulator.resize(width * height * 3);
for (int samp = 0; samp < numSamples; ++samp)
{
for (int w = 0; w < width; ++w)
{ {
for (int h = 0; h < height; ++h) image.clear();
accumulator.clear();
image.resize(width * height * 3);
for (int samp = 0; samp < numSamples; ++samp)
{ {
std::function<void()> job = [&]()
{
std::vector<unsigned char> localAccumulator(width * height * 3);
for (int w = 0; w < width; ++w)
{
for (int h = 0; h < height; ++h)
{
if (cancel)
return;
bvh.traceRay();
}
}
// lock image
// add result to image
};
} }
} });
}
} }
+12
View File
@@ -3,12 +3,24 @@
#include "window/Window.h" #include "window/Window.h"
#include "util/Camera.h" #include "util/Camera.h"
/// <summary>
/// Ray1
/// Ray2
/// Ray3
/// Ray4
/// Ray5
/// GammaResolve
/// Ray1
/// Ray2
/// Ray3
/// </summary>
class Scene class Scene
{ {
public: public:
Scene(); Scene();
~Scene(); ~Scene();
void render(Camera cam, int width, int height, int numSamples); void render(Camera cam, int width, int height, int numSamples);
constexpr const std::vector<unsigned char>& getImage() const { return image; }
private: private:
// the thing being displayed // the thing being displayed
std::vector<unsigned char> image; std::vector<unsigned char> image;