Merge branch 'master' of github.com:Dynamitos/RayTracer

This commit is contained in:
Gamemaker1998
2025-01-24 21:55:02 +01:00
5 changed files with 67 additions and 22 deletions
+8 -15
View File
@@ -4,23 +4,16 @@
int main()
{
BVH bvh;
bvh.addModels(ModelLoader::loadModel("../cube.fbx"), glm::mat4());
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;
}
}
Scene scene;
Window window;
while (true)
{
w.update(texture);
// IMGUI....
if (Imgui.Button())
{
scene.render();
}
window.update(scene.getImage());
}
return 0;
}
+30 -5
View File
@@ -1,9 +1,34 @@
#include "Scene.h"
Scene::Scene()
: window(1920, 1080)
Scene::Scene(glm::vec3 cameraPos, glm::vec3 cameraDirection) : cameraPos(cameraPos), cameraDirection(cameraDirection) {}
Scene::~Scene() {}
void Scene::render(int width, int height, int numSamples)
{
worker = std::thread(
[&]()
{
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
};
}
});
}
void Scene::render() {}
+17 -2
View File
@@ -1,15 +1,30 @@
#pragma once
#include "BVH.h"
#include "window/Window.h"
#include "util/Camera.h"
/// <summary>
/// Ray1
/// Ray2
/// Ray3
/// Ray4
/// Ray5
/// GammaResolve
/// Ray1
/// Ray2
/// Ray3
/// </summary>
class Scene
{
public:
Scene();
~Scene();
void render();
void render(Camera cam, int width, int height, int numSamples);
constexpr const std::vector<unsigned char>& getImage() const { return image; }
private:
Window window;
// the thing being displayed
std::vector<unsigned char> image;
// radiance accumulator
std::vector<unsigned char> accumulator;
BVH bvh;
};
+1
View File
@@ -1,5 +1,6 @@
target_sources(RayTracer
PRIVATE
Camera.h
Model.h
Model.cpp
ModelLoader.h
+11
View File
@@ -0,0 +1,11 @@
#pragma once
#include <glm/glm.hpp>
struct Camera
{
glm::vec3 position;
glm::vec3 direction;
glm::vec2 sensorSize = glm::vec2(0.036, 0.024);
float S_O = 6.9;
float f = 0.7;
};