adding more gui
This commit is contained in:
+4
-1
@@ -31,11 +31,14 @@ int main()
|
||||
ImGui::Text("Render Parameters");
|
||||
ImGui::InputInt2("Dimensions", &render.width);
|
||||
ImGui::InputInt("Samples", &render.numSamples);
|
||||
|
||||
if (ImGui::Button("Render"))
|
||||
{
|
||||
scene.startRender(camera, render);
|
||||
}
|
||||
ImGui::Text("Render Stats");
|
||||
ImGui::Text("Last Sample Time: %.3f", scene.getLastSampleTime());
|
||||
ImGui::Text("Average Sample Time: %.3f", scene.getAverageSampleTime());
|
||||
ImGui::PlotLines("Sample Times", scene.getSampleTimes().data(), scene.getSampleTimes().size(), 0, 0, FLT_MAX, FLT_MAX, ImVec2(0, 40));
|
||||
window.update(scene.getImage());
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -93,17 +93,18 @@ void Renderer::render(Camera camera, RenderParameter params)
|
||||
|
||||
bvh.traceRay(r, payload, 1e-4, 1e20);
|
||||
|
||||
accumulator[w + h * params.width] += payload.accumulatedRadiance;
|
||||
accumulator[w + h * params.width] += payload.accumulatedRadiance / float(params.numSamples);
|
||||
}
|
||||
co_return;
|
||||
}(w, samp));
|
||||
}
|
||||
threadPool.runBatch(std::move(batch));
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << std::endl;
|
||||
sampleTimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / 1000.0f);
|
||||
float resolver = float(params.numSamples) / float(samp);
|
||||
for (uint32_t i = 0; i < accumulator.size(); ++i)
|
||||
{
|
||||
image[i] = glm::pow(glm::max((accumulator[i] / float(samp+1)), 0.0f), glm::vec3(0.45f));
|
||||
image[i] = glm::pow(glm::max(accumulator[i] * resolver, 0.0f), glm::vec3(0.45f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-22
@@ -1,33 +1,44 @@
|
||||
#pragma once
|
||||
#include "Scene.h"
|
||||
#include "window/Window.h"
|
||||
#include "util/Camera.h"
|
||||
#include "ThreadPool.h"
|
||||
#include "util/Camera.h"
|
||||
#include "window/Window.h"
|
||||
#include <numeric>
|
||||
|
||||
struct RenderParameter
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int numSamples;
|
||||
int width;
|
||||
int height;
|
||||
int numSamples;
|
||||
};
|
||||
|
||||
class Renderer
|
||||
{
|
||||
public:
|
||||
Renderer();
|
||||
virtual ~Renderer();
|
||||
void startRender(Camera cam, RenderParameter params);
|
||||
constexpr const std::vector<glm::vec3>& getImage() const { return image; }
|
||||
private:
|
||||
virtual void render(Camera cam, RenderParameter params);
|
||||
ThreadPool threadPool;
|
||||
std::thread worker;
|
||||
std::atomic_bool pendingCancel = false;
|
||||
// the thing being displayed
|
||||
std::vector<glm::vec3> image;
|
||||
// radiance accumulator
|
||||
std::vector<glm::vec3> accumulator;
|
||||
std::vector<PointLight> pointLights;
|
||||
std::vector<DirectionalLight> directionalLights;
|
||||
Scene bvh;
|
||||
public:
|
||||
Renderer();
|
||||
virtual ~Renderer();
|
||||
void startRender(Camera cam, RenderParameter params);
|
||||
constexpr const std::vector<glm::vec3>& getImage() const { return image; }
|
||||
constexpr const std::vector<float>& getSampleTimes() const { return sampleTimes; }
|
||||
constexpr const float getLastSampleTime() const { return sampleTimes.back(); }
|
||||
constexpr const float getAverageSampleTime() const
|
||||
{
|
||||
return std::accumulate(sampleTimes.begin(), sampleTimes.end(), 0.0f) / sampleTimes.size();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void render(Camera cam, RenderParameter params);
|
||||
ThreadPool threadPool;
|
||||
std::thread worker;
|
||||
std::atomic_bool pendingCancel = false;
|
||||
std::vector<float> sampleTimes;
|
||||
float lastSampleTime;
|
||||
float averageSampleTime;
|
||||
// the thing being displayed
|
||||
std::vector<glm::vec3> image;
|
||||
// radiance accumulator
|
||||
std::vector<glm::vec3> accumulator;
|
||||
std::vector<PointLight> pointLights;
|
||||
std::vector<DirectionalLight> directionalLights;
|
||||
Scene bvh;
|
||||
};
|
||||
+1
-1
@@ -6,7 +6,7 @@ struct Camera
|
||||
glm::vec3 position;
|
||||
glm::vec3 target;
|
||||
glm::vec2 sensorSize = glm::vec2(0.036, 0.024);
|
||||
float S_O = 6.9;
|
||||
float S_O = 20;
|
||||
float f = 0.7;
|
||||
float A = 0.35;
|
||||
};
|
||||
Reference in New Issue
Block a user