Merge branch 'master' of github.com:Dynamitos/RayTracer
This commit is contained in:
+8
-15
@@ -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;
|
||||||
}
|
}
|
||||||
+30
-5
@@ -1,9 +1,34 @@
|
|||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
Scene::Scene()
|
Scene::Scene(glm::vec3 cameraPos, glm::vec3 cameraDirection) : cameraPos(cameraPos), cameraDirection(cameraDirection) {}
|
||||||
: window(1920, 1080)
|
|
||||||
|
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
@@ -1,15 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "BVH.h"
|
#include "BVH.h"
|
||||||
#include "window/Window.h"
|
#include "window/Window.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();
|
void render(Camera cam, int width, int height, int numSamples);
|
||||||
|
constexpr const std::vector<unsigned char>& getImage() const { return image; }
|
||||||
private:
|
private:
|
||||||
Window window;
|
// the thing being displayed
|
||||||
std::vector<unsigned char> image;
|
std::vector<unsigned char> image;
|
||||||
|
// radiance accumulator
|
||||||
|
std::vector<unsigned char> accumulator;
|
||||||
BVH bvh;
|
BVH bvh;
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
target_sources(RayTracer
|
target_sources(RayTracer
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
Camera.h
|
||||||
Model.h
|
Model.h
|
||||||
Model.cpp
|
Model.cpp
|
||||||
ModelLoader.h
|
ModelLoader.h
|
||||||
|
|||||||
@@ -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;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user