Skip to content

Add testing for maketx --lightprobe, fix bugs #3732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/libOpenImageIO/maketexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ latlong_to_dir(float s, float t, bool y_is_up = true)



template<class SRCTYPE>
static bool
lightprobe_to_envlatl(ImageBuf& dst, const ImageBuf& src, bool y_is_up,
ROI roi = ROI::All(), int nthreads = 0)
Expand All @@ -392,8 +393,8 @@ lightprobe_to_envlatl(ImageBuf& dst, const ImageBuf& src, bool y_is_up,
float r = M_1_PI * acosf(V[2]) / hypotf(V[0], V[1]);
float u = (V[0] * r + 1.0f) * 0.5f;
float v = (V[1] * r + 1.0f) * 0.5f;
interppixel_NDC_clamped<float>(src, float(u), float(v), pixel,
false);
interppixel_NDC_clamped<SRCTYPE>(src, float(u), float(v), pixel,
false);
for (int c = roi.chbegin; c < roi.chend; ++c)
d[c] = pixel[c];
}
Expand Down Expand Up @@ -1163,7 +1164,11 @@ make_texture_impl(ImageBufAlgo::MakeTextureMode mode, const ImageBuf* input,
std::shared_ptr<ImageBuf> latlong(new ImageBuf(newspec));
// Now lightprobe holds the original lightprobe, src is a blank
// image that will be the unwrapped latlong version of it.
lightprobe_to_envlatl(*latlong, *src, true);
bool ok = true;
OIIO_DISPATCH_COMMON_TYPES(ok, "lightprobe_to_envlatl",
lightprobe_to_envlatl, src->spec().format,
*latlong, *src, true);
// lightprobe_to_envlatl(*latlong, *src, true);
// Carry on with the lat-long environment map from here on out
mode = ImageBufAlgo::MakeTxEnvLatl;
src = latlong;
Expand Down
2 changes: 2 additions & 0 deletions testsuite/maketx/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,5 @@ bumpslope.exr : 64 x 64, 6 channel, half openexr
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
oiio:subimages: 1
openexr:roundingmode: 0
Comparing "uffizi_latlong_env-128.exr" and "ref/uffizi_latlong_env-128.exr"
PASS
Binary file added testsuite/maketx/ref/uffizi_latlong_env-128.exr
Binary file not shown.
11 changes: 8 additions & 3 deletions testsuite/maketx/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

failureok = 1

outputs = [ ]

# Just for simplicity, make a checkerboard with a solid alpha
command += oiiotool (" --pattern checker 128x128 4 --ch R,G,B,=1.0"
Expand Down Expand Up @@ -116,19 +117,23 @@
"--envlatl")
command += oiiotool ("--stats -a whiteenv.exr")

# Test --lightprobe
command += maketx_command ("src/uffizi_probe-128.exr", "uffizi_latlong_env-128.exr",
"--lightprobe -d half")
outputs += [ "uffizi_latlong_env-128.exr" ]

#Test --bumpslopes to export a 6 channels height map with gradients
command += oiiotool (" --pattern noise 64x64 1"
+ " -d half -o " + make_relpath("bump.exr"))
command += maketx_command ("bump.exr", "bumpslope.exr",
"--bumpslopes -d half", showinfo=True)


outputs = [ "out.txt" ]
outputs += [ "out.txt" ]



# To do: --filter --fullpixels
# To do: --fullpixels
# --prman-metadata --ignore-unassoc
# --mipimage
# --envlatl TIFF, --envlatl EXR
# --colorconvert --unpremult -u --fovcot
Binary file added testsuite/maketx/src/uffizi_probe-128.exr
Binary file not shown.