From 9bf7d2c80cf60ada402b48e71507711a14561f53 Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Thu, 7 Nov 2024 15:51:13 +0100 Subject: [PATCH] Update render executables to use right unit In 695586b, the field conversion executables were updated to use units other than tesla, which broke the rendering executables. This commit makes the rendering executables aware of the change, allowing them to produce nice images again. --- examples/cpu/render_slice.cpp | 12 ++++++++---- examples/cuda/render_slice.cu | 10 ++++++++-- examples/cuda/render_slice_texture.cu | 10 ++++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/cpu/render_slice.cpp b/examples/cpu/render_slice.cpp index 215de3e..a56d83c 100644 --- a/examples/cpu/render_slice.cpp +++ b/examples/cpu/render_slice.cpp @@ -157,10 +157,14 @@ int main(int argc, char ** argv) img[vm["height"].as() * x + y] = static_cast(std::lround( - 255.f * - std::min( - std::sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 1.0f - ) + 255.f * std::min( + std::sqrt( + std::pow(p[0] / 0.000299792458f, 2.f) + + std::pow(p[1] / 0.000299792458f, 2.f) + + std::pow(p[2] / 0.000299792458f, 2.f) + ), + 1.0f + ) )); } } diff --git a/examples/cuda/render_slice.cu b/examples/cuda/render_slice.cu index cdd3e66..4a57817 100644 --- a/examples/cuda/render_slice.cu +++ b/examples/cuda/render_slice.cu @@ -96,8 +96,14 @@ __global__ void render( typename field_t::output_t p = vf.at(fx * 20000.f - 10000.f, fy * 20000.f - 10000.f, z); out[height * x + y] = static_cast(std::lround( - 255.f * - std::min(std::sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 1.0f) + 255.f * std::min( + std::sqrt( + std::pow(p[0] / 0.000299792458f, 2.f) + + std::pow(p[1] / 0.000299792458f, 2.f) + + std::pow(p[2] / 0.000299792458f, 2.f) + ), + 1.0f + ) )); } } diff --git a/examples/cuda/render_slice_texture.cu b/examples/cuda/render_slice_texture.cu index 69c094e..f5553f8 100644 --- a/examples/cuda/render_slice_texture.cu +++ b/examples/cuda/render_slice_texture.cu @@ -97,8 +97,14 @@ __global__ void render( typename field_t::output_t p = vf.at(fx * 20000.f - 10000.f, fy * 20000.f - 10000.f, z); out[height * x + y] = static_cast(std::lround( - 255.f * - std::min(std::sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]), 1.0f) + 255.f * std::min( + std::sqrt( + std::pow(p[0] / 0.000299792458f, 2.f) + + std::pow(p[1] / 0.000299792458f, 2.f) + + std::pow(p[2] / 0.000299792458f, 2.f) + ), + 1.0f + ) )); } }