Skip to content

Commit

Permalink
get rid of old glare stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
PearCoding committed Jun 29, 2024
1 parent a1794a6 commit 1e384bb
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 121 deletions.
36 changes: 0 additions & 36 deletions src/device/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,42 +1826,6 @@ void Device::tonemap(uint32_t* out_pixels, const TonemapSettings& driver_setting
leaveDevice();
}

GlareOutput Device::evaluateGlare(uint32_t* out_pixels, const GlareSettings& driver_settings)
{
enterDevice();

const auto acc = sInterface->getAOVImageForDevice(driver_settings.AOV);
float* in_pixels = acc.Data;
const float inv_iter = acc.IterationCount > 0 ? 1.0f / acc.IterationCount : 0.0f;

uint32_t* device_out_pixels = sInterface->isGPU() ? sInterface->getTonemapImageGPU() : out_pixels;

::GlareSettings settings;
settings.scale = driver_settings.Scale * inv_iter;
settings.max = driver_settings.LuminanceMax;
settings.avg = driver_settings.LuminanceAverage;
settings.mul = driver_settings.LuminanceMultiplier;
settings.vertical_illuminance = driver_settings.VerticalIlluminance;

::GlareOutput output = sInterface->runGlareShader(in_pixels, device_out_pixels, settings);

GlareOutput driver_output;
driver_output.DGP = output.dgp;
driver_output.VerticalIlluminance = output.vertical_illuminance;
driver_output.AvgLum = output.avg_lum;
driver_output.AvgOmega = output.avg_omega;
driver_output.NumPixels = output.num_pixels;

if (sInterface->isGPU()) {
size_t size = sInterface->framebufferSize();
anydsl_copy(sInterface->deviceID(), device_out_pixels, 0, 0 /* Host */, out_pixels, 0, sizeof(uint32_t) * size);
}

leaveDevice();

return driver_output;
}

ImageInfoOutput Device::imageinfo(const ImageInfoSettings& driver_settings)
{
enterDevice();
Expand Down
1 change: 0 additions & 1 deletion src/device/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Device : public IRenderDevice {
[[nodiscard]] const Statistics* getStatistics() override;

void tonemap(uint32_t*, const TonemapSettings&) override;
[[nodiscard]] GlareOutput evaluateGlare(uint32_t*, const GlareSettings&) override;
[[nodiscard]] ImageInfoOutput imageinfo(const ImageInfoSettings&) override;
void bake(const ShaderOutput<void*>& shader, const std::vector<std::string>* resource_map, float* output) override;

Expand Down
6 changes: 1 addition & 5 deletions src/frontend/common/ProgramOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ ProgramOptions::ProgramOptions(int argc, char** argv, ApplicationType type, cons
"--disable-specialization", [&]() { this->Specialization = RuntimeOptions::SpecializationMode::Disable; },
"Disables specialization for parameters in shading tree. This might decrease compile time drastically for worse runtime optimization");

if (type != ApplicationType::Trace) {
if (type != ApplicationType::Trace)
app.add_flag("--denoise", Denoise, "Apply denoiser if available");
app.add_flag("--glare", Glare, "Enable glare overlay");
}

if (type == ApplicationType::Trace) {
app.add_option("-i,--input", InputRay, "Read list of rays from file instead of the standard input");
Expand Down Expand Up @@ -339,8 +337,6 @@ void ProgramOptions::populate(RuntimeOptions& options) const

options.Denoiser.Enabled = Denoise;

options.Glare.Enabled = Glare;

options.EnableCache = !NoCache;
options.CacheDir = CacheDir;

Expand Down
2 changes: 0 additions & 2 deletions src/frontend/common/ProgramOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class ProgramOptions {

bool Denoise = false;

bool Glare = false;

bool NoCache = false;
Path CacheDir;

Expand Down
32 changes: 0 additions & 32 deletions src/frontend/view/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ class ContextInternal {
bool ToneMappingGamma = true;
IG::ToneMappingMethod ToneMappingMethod = ToneMappingMethod::PbrNeutral;

// Visualization
bool VisualizeGlare = true;
float VisualizeGlare_Multiplier = 5.0f;

bool VisualizeGlare_AutoEV = true;
float VerticalIlluminance = 5.0f;
GlareOutput Glare;

size_t CurrentAOV = 0;

bool Running = true;
Expand Down Expand Up @@ -571,9 +563,6 @@ class ContextInternal {
ToneMapping_Automatic ? 1 / LastLum.Est : std::pow(2.0f, ToneMapping_Exposure),
ToneMapping_Automatic ? 0 : ToneMapping_Offset });

if (Runtime->options().Glare.Enabled && VisualizeGlare)
Glare = Runtime->evaluateGlare(buf, GlareSettings{ aov_name.c_str(), 1.0f, LastLum.SoftMax, LastLum.Avg, VisualizeGlare_Multiplier, VisualizeGlare_AutoEV ? -1.0f : VerticalIlluminance });

SDL_UpdateTexture(Texture, nullptr, buf, static_cast<int>(Width * sizeof(uint32_t)));
}

Expand Down Expand Up @@ -809,27 +798,6 @@ class ContextInternal {
ImGui::Checkbox("Gamma", &ToneMappingGamma);
}

if (Runtime->options().Glare.Enabled) {
if (ImGui::CollapsingHeader("Visualization", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Checkbox("Visualize Glare", &VisualizeGlare);
ImGui::Text("Avg. Luminance: %1.4f Lux", 179 * LastLum.Avg);
if (Glare.NumPixels > 0) {
ImGui::Text("Avg. GS Luminance: %1.4f Lux", Glare.AvgLum);
ImGui::Text("Avg. GS Omega: %1.4f", Glare.AvgOmega);
ImGui::Text("GS Pixel No: %i", Glare.NumPixels);
} else {
ImGui::TextColored(ImVec4(1, 0, 0, 1), "No glare source detected!");
}
ImGui::SliderFloat("Multiplier", &VisualizeGlare_Multiplier, 0.0, 20.0);
ImGui::Checkbox("Automatic EV", &VisualizeGlare_AutoEV);
if (!VisualizeGlare_AutoEV)
ImGui::SliderFloat("EV", &VerticalIlluminance, 0.0, 500.0);
else
ImGui::Text("EV: %1.3f", Glare.VerticalIlluminance);
ImGui::Text("DGP: %1.3f", Glare.DGP);
}
}

if (ImGui::CollapsingHeader("Poses")) {
if (ImGui::Button("Reload")) {
PoseManager.load(POSE_FILE);
Expand Down
19 changes: 0 additions & 19 deletions src/runtime/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ LoaderOptions Runtime::loaderOptions() const
lopts.EnableTonemapping = mOptions.EnableTonemapping;
lopts.Denoiser = mOptions.Denoiser;
lopts.Denoiser.Enabled = !mOptions.IsTracer && mOptions.Denoiser.Enabled && hasDenoiser();
lopts.Glare = mOptions.Glare;
lopts.Compiler = mCompiler.get();
lopts.Device = mDevice.get();
return lopts;
Expand All @@ -260,8 +259,6 @@ bool Runtime::load(const Path& path, const Scene* scene)

if (lopts.Denoiser.Enabled)
IG_LOG(L_INFO) << "Using denoiser" << std::endl;
if (lopts.Glare.Enabled)
IG_LOG(L_INFO) << "Glare overlay enabled" << std::endl;

// Extract technique
setup_technique(lopts, mOptions);
Expand Down Expand Up @@ -625,8 +622,6 @@ bool Runtime::compileShaders()
registerShader(i, "tonemap", "ig_tonemap_shader", &variant.TonemapShader, &shaders.TonemapShader);
registerShader(i, "imageinfo", "ig_imageinfo_shader", &variant.ImageinfoShader, &shaders.ImageinfoShader);
}
if (mOptions.Glare.Enabled)
registerShader(i, "glare", "ig_glare_shader", &variant.GlareShader, &shaders.GlareShader);
registerShader(i, "primary traversal", "ig_traversal_shader", &variant.PrimaryTraversalShader, &shaders.PrimaryTraversalShader);
registerShader(i, "secondary traversal", "ig_traversal_shader", &variant.SecondaryTraversalShader, &shaders.SecondaryTraversalShader);
registerShader(i, "ray generation", "ig_ray_generation_shader", &variant.RayGenerationShader, &shaders.RayGenerationShader);
Expand Down Expand Up @@ -675,20 +670,6 @@ void Runtime::tonemap(uint32* out_pixels, const TonemapSettings& settings)
mDevice->tonemap(out_pixels, settings);
}

GlareOutput Runtime::evaluateGlare(uint32* out_pixels, const GlareSettings& settings)
{
if (mTechniqueVariants.empty()) {
IG_LOG(L_ERROR) << "No scene loaded!" << std::endl;
return GlareOutput{};
}

IG_ASSERT(mDevice, "Expected device to be available");
if (mDevice)
return mDevice->evaluateGlare(out_pixels, settings);
else
return GlareOutput{};
}

ImageInfoOutput Runtime::imageinfo(const ImageInfoSettings& settings)
{
if (mTechniqueVariants.empty()) {
Expand Down
2 changes: 0 additions & 2 deletions src/runtime/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class IG_LIB Runtime {
/// A utility function to speed up tonemapping
/// out_pixels should be of size width*height!
void tonemap(uint32* out_pixels, const TonemapSettings& settings);
/// out_pixels should be of size width*height!
GlareOutput evaluateGlare(uint32* out_pixels, const GlareSettings& settings);
/// A utility function to speed up utility information from the image
ImageInfoOutput imageinfo(const ImageInfoSettings& settings);

Expand Down
5 changes: 0 additions & 5 deletions src/runtime/RuntimeSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ struct DenoiserSettings {
bool Enabled = false; // Enables the denoiser
};

struct GlareOptions {
bool Enabled = false;
};

struct RuntimeOptions {
bool IsTracer = false;
bool IsInteractive = false;
Expand Down Expand Up @@ -49,7 +45,6 @@ struct RuntimeOptions {
bool WarnUnused = true; // Warn about unused properties. They might indicate a typo or similar.

DenoiserSettings Denoiser;
GlareOptions Glare;

inline static RuntimeOptions makeDefault(bool trace = false)
{
Expand Down
17 changes: 0 additions & 17 deletions src/runtime/RuntimeStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ struct TonemapSettings {
float ExposureOffset;
};

struct GlareSettings {
const char* AOV;
float Scale;
float LuminanceMax;
float LuminanceAverage;
float LuminanceMultiplier;
float VerticalIlluminance;
};

struct GlareOutput {
float DGP;
float VerticalIlluminance; // Automatically computed vertical illuminance
int NumPixels; // Number of pixels of the glare source
float AvgLum; // Average luminance of the glare source
float AvgOmega; // Average omega of the glare source
};

struct ImageInfoSettings {
const char* AOV;
float Scale;
Expand Down
1 change: 0 additions & 1 deletion src/runtime/device/IRenderDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class IG_LIB IRenderDevice {
[[nodiscard]] virtual const Statistics* getStatistics() = 0;

virtual void tonemap(uint32_t*, const TonemapSettings&) = 0;
[[nodiscard]] virtual GlareOutput evaluateGlare(uint32_t*, const GlareSettings&) = 0;
[[nodiscard]] virtual ImageInfoOutput imageinfo(const ImageInfoSettings&) = 0;
virtual void bake(const ShaderOutput<void*>& shader, const std::vector<std::string>* resource_map, float* output) = 0;

Expand Down
1 change: 0 additions & 1 deletion src/runtime/loader/LoaderOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct LoaderOptions {
bool EnableTonemapping;
bool EnableCache;
DenoiserSettings Denoiser;
GlareOptions Glare;

ScriptCompiler* Compiler;
IRenderDevice* Device;
Expand Down

0 comments on commit 1e384bb

Please sign in to comment.