adding more gui

This commit is contained in:
Dynamitos
2025-01-26 23:41:25 +01:00
parent 011b40dbde
commit fc62bb24f8
4 changed files with 42 additions and 27 deletions
+4 -1
View File
@@ -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;
+4 -3
View File
@@ -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));
}
}
}
+13 -2
View File
@@ -1,8 +1,9 @@
#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
{
@@ -18,11 +19,21 @@ class 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
+1 -1
View File
@@ -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;
};