diff --git a/.gitignore b/.gitignore index b8ffb3b0..43f670bb 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ CMakeSettings.json temp tmp enc_temp_folder +profiler /common/outputs /common/configs/test* /common/assets/textures/local diff --git a/src/core/texture.h b/src/core/texture.h index 2f0146d7..a84b437c 100644 --- a/src/core/texture.h +++ b/src/core/texture.h @@ -95,7 +95,7 @@ class Texture { } Image::SharedPtr getImage() const { return mImage; } RGBA getConstant() const { return mValue; } - std::string getFilemame() const { return mFilename; } + std::string getFilename() const { return mFilename; } bool hasImage() const { return mImage && mImage->isValid(); } static Texture::SharedPtr createFromFile(const fs::path &filepath, bool flip = false, diff --git a/src/render/passes/errormeasure/metrics.cu b/src/render/passes/errormeasure/metrics.cu index e62e4dab..71c635c2 100644 --- a/src/render/passes/errormeasure/metrics.cu +++ b/src/render/passes/errormeasure/metrics.cu @@ -9,14 +9,16 @@ #include #define METRIC_IN_SRGB 0 -#define ERROR_EPS 1e-3f #define CLAMP_PIXEL_ERROR 0 -#define CLAMP_PIXEL_ERROR_THRESHOLD 10.f -#define DISCARD_FIREFLIES 0 -#define DISCARD_FIREFLIES_PRECENTAGE 0.0001f +#define DISCARD_FIREFLIES 1 + KRR_NAMESPACE_BEGIN +KRR_DEVICE constexpr float ERROR_EPS = 0; +KRR_DEVICE constexpr float CLAMP_PIXEL_ERROR_THRESHOLD = 10; +KRR_DEVICE constexpr float DISCARD_FIREFLIES_PRECENTAGE = 0.0001; + namespace { TypedBuffer intermediateResult; @@ -70,11 +72,14 @@ KRR_CALLABLE float smape(const RGB &y, const RGB &ref) { // is in fact MRSE... KRR_CALLABLE float rel_mse(const RGB &y, const RGB &ref) { - return ((y - ref) / (ref + ERROR_EPS)).square().mean(); - //RGB ret{}, diff = (y - ref).abs(); - //for (int ch = 0; ch < RGB::dim; ch++) - // ret[ch] = ref[ch] == 0.f ? 0.f : pow2(diff[ch] / (ref[ch])); - //return ret.mean(); + if constexpr (ERROR_EPS) + return ((y - ref) / (ref + ERROR_EPS)).square().mean(); + else { + RGB ret{}, diff = (y - ref).abs(); + for (int ch = 0; ch < RGB::dim; ch++) + ret[ch] = ref[ch] == 0.f ? 0.f : pow2(diff[ch] / ref[ch]); + return ret.mean(); + } } float calc_metric(const CudaRenderTarget & frame, const RGBA *reference, diff --git a/src/render/wavefront/device.cu b/src/render/wavefront/device.cu index e94759e3..c80b6cc6 100644 --- a/src/render/wavefront/device.cu +++ b/src/render/wavefront/device.cu @@ -79,8 +79,7 @@ extern "C" __global__ void KRR_RT_RG(Closest)() { if (getRayId() >= launchParams.currentRayQueue->size()) return; RayWorkItem r = getRayWorkItem(); SurfaceInteraction intr = {}; - traceRay(launchParams.traversable, r.ray, M_FLOAT_INF, - 0, OPTIX_RAY_FLAG_NONE, (void*)&intr); + traceRay(launchParams.traversable, r.ray, M_FLOAT_INF, 0, OPTIX_RAY_FLAG_NONE, (void *) &intr); } extern "C" __global__ void KRR_RT_AH(Shadow)() { diff --git a/src/render/wavefront/integrator.cpp b/src/render/wavefront/integrator.cpp index ef23969e..d0839cc9 100644 --- a/src/render/wavefront/integrator.cpp +++ b/src/render/wavefront/integrator.cpp @@ -229,10 +229,8 @@ void WavefrontPathTracer::render(RenderContext *context) { missRayQueue->reset(); shadowRayQueue->reset(); scatterRayQueue->reset(); - if (enableMedium) { - mediumSampleQueue->reset(); - mediumScatterQueue->reset(); - } + if (enableMedium) mediumSampleQueue->reset(); + if (enableMedium) mediumScatterQueue->reset(); }, gpContext->cudaStream); // [STEP#2.1] find closest intersections, filling in scatterRayQueue and hitLightQueue traceClosest(depth); diff --git a/src/render/wavefront/wavefront.h b/src/render/wavefront/wavefront.h index 94cb0f09..f7a419fe 100644 --- a/src/render/wavefront/wavefront.h +++ b/src/render/wavefront/wavefront.h @@ -101,7 +101,7 @@ KRR_HOST_DEVICE void traceTransmittance(const ShadowRayWorkItem& sr, const Surfa break; } if (ray.medium) { - float tEnd = visible ? tMax : (intr.p - ray.origin).norm() / ray.dir.norm(); + float tEnd = visible ? tMax : (intr.p - ray.origin).norm() / ray.dir.norm(); Spectrum T_maj = sampleT_maj(ray, tEnd, sampler, lambda, [&](Vector3f p, MediumProperties mp, Spectrum sigma_maj, Spectrum T_maj) {