adding more gui
This commit is contained in:
+4
-1
@@ -31,11 +31,14 @@ int main()
|
|||||||
ImGui::Text("Render Parameters");
|
ImGui::Text("Render Parameters");
|
||||||
ImGui::InputInt2("Dimensions", &render.width);
|
ImGui::InputInt2("Dimensions", &render.width);
|
||||||
ImGui::InputInt("Samples", &render.numSamples);
|
ImGui::InputInt("Samples", &render.numSamples);
|
||||||
|
|
||||||
if (ImGui::Button("Render"))
|
if (ImGui::Button("Render"))
|
||||||
{
|
{
|
||||||
scene.startRender(camera, 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());
|
window.update(scene.getImage());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -93,17 +93,18 @@ void Renderer::render(Camera camera, RenderParameter params)
|
|||||||
|
|
||||||
bvh.traceRay(r, payload, 1e-4, 1e20);
|
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;
|
co_return;
|
||||||
}(w, samp));
|
}(w, samp));
|
||||||
}
|
}
|
||||||
threadPool.runBatch(std::move(batch));
|
threadPool.runBatch(std::move(batch));
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
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)
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-4
@@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "window/Window.h"
|
|
||||||
#include "util/Camera.h"
|
|
||||||
#include "ThreadPool.h"
|
#include "ThreadPool.h"
|
||||||
|
#include "util/Camera.h"
|
||||||
|
#include "window/Window.h"
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
struct RenderParameter
|
struct RenderParameter
|
||||||
{
|
{
|
||||||
@@ -13,16 +14,26 @@ struct RenderParameter
|
|||||||
|
|
||||||
class Renderer
|
class Renderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Renderer();
|
Renderer();
|
||||||
virtual ~Renderer();
|
virtual ~Renderer();
|
||||||
void startRender(Camera cam, RenderParameter params);
|
void startRender(Camera cam, RenderParameter params);
|
||||||
constexpr const std::vector<glm::vec3>& getImage() const { return image; }
|
constexpr const std::vector<glm::vec3>& getImage() const { return image; }
|
||||||
private:
|
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);
|
virtual void render(Camera cam, RenderParameter params);
|
||||||
ThreadPool threadPool;
|
ThreadPool threadPool;
|
||||||
std::thread worker;
|
std::thread worker;
|
||||||
std::atomic_bool pendingCancel = false;
|
std::atomic_bool pendingCancel = false;
|
||||||
|
std::vector<float> sampleTimes;
|
||||||
|
float lastSampleTime;
|
||||||
|
float averageSampleTime;
|
||||||
// the thing being displayed
|
// the thing being displayed
|
||||||
std::vector<glm::vec3> image;
|
std::vector<glm::vec3> image;
|
||||||
// radiance accumulator
|
// radiance accumulator
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ struct Camera
|
|||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
glm::vec3 target;
|
glm::vec3 target;
|
||||||
glm::vec2 sensorSize = glm::vec2(0.036, 0.024);
|
glm::vec2 sensorSize = glm::vec2(0.036, 0.024);
|
||||||
float S_O = 6.9;
|
float S_O = 20;
|
||||||
float f = 0.7;
|
float f = 0.7;
|
||||||
float A = 0.35;
|
float A = 0.35;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user