Merge branch 'master' of github.com:Dynamitos/RayTracer
This commit is contained in:
+30
-5
@@ -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
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user