Skip to content

Fix floating point precision issue with "--bumpslopes" exporter #1913

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
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
6 changes: 3 additions & 3 deletions src/libOpenImageIO/maketexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ lightprobe_to_envlatl (ImageBuf &dst, const ImageBuf &src, bool y_is_up,



// compute slopes in s,t space using a Sobel gradient filter
// compute slopes in pixel space using a Sobel gradient filter
template<class SRCTYPE>
static void
sobel_gradient (const ImageBuf &src, const ImageBuf::Iterator<float> &dstpix,
Expand All @@ -456,8 +456,8 @@ sobel_gradient (const ImageBuf &src, const ImageBuf::Iterator<float> &dstpix,
*h = srcval;
}

*dh_ds = *dh_ds * src.spec().width / 8.0f ; // sobel normalization
*dh_dt = *dh_dt * src.spec().height / 8.0f ;
*dh_ds = *dh_ds / 8.0f ; // sobel normalization
*dh_dt = *dh_dt / 8.0f ;
}


Expand Down
6 changes: 3 additions & 3 deletions testsuite/maketx/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,16 @@ whiteenv.exr : 4 x 2, 3 channel, half openexr (+mipmap)
Reading bumpslope.exr
bumpslope.exr : 64 x 64, 6 channel, half openexr
MIP-map levels: 64x64 32x32 16x16 8x8 4x4 2x2 1x1
SHA-1: A36E88E8144C7FFE4DEE79682175EEFFF3666876
SHA-1: 8A309ED5DD4C7ADC8B752735651BAEE9FA326B82
channel list: b0_h, b1_dhds, b2_dhdt, b3_dhds2, b4_dhdt2, b5_dh2dsdt
tile size: 64 x 64
oiio:ColorSpace: "Linear"
openexr:roundingmode: 0
textureformat: "Plain Texture"
compression: "zip"
fovcot: 1
oiio:AverageColor: "0.499779,-0.0293083,-0.00267029,8.07388,7.3275,0.141625"
oiio:SHA-1: "F7C2558A51D7333FFE1908ADAD42C401A9563273"
oiio:AverageColor: "0.499779,-0.000457942,-4.17233e-05,0.00197116,0.00178894,3.45764e-05"
oiio:SHA-1: "49B533110A914CE89BE0B14753A6A4CC037C964F"
PixelAspectRatio: 1
screenWindowCenter: 0 0
screenWindowWidth: 1
Expand Down
56 changes: 28 additions & 28 deletions testsuite/oiiotool-maketx/ref/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -381,73 +381,73 @@ whiteenv.exr : 4 x 2, 3 channel, half openexr (+mipmap)
Monochrome: Yes
bumpslope.exr : 64 x 64, 6 channel, half openexr (+mipmap)
MIP 0 of 7 (64 x 64):
Stats Min: 0.131714 -9.882812 -9.468750 0.000000 0.000000 -53.593750 (float)
Stats Max: 0.823730 10.078125 10.609375 101.500000 112.562500 47.031250 (float)
Stats Avg: 0.499779 -0.029305 -0.002668 8.073893 7.327511 0.141631 (float)
Stats StdDev: 0.099583 2.841299 2.706928 11.169512 10.638643 7.398137 (float)
Stats Min: 0.131714 -0.154419 -0.147949 0.000000 0.000000 -0.013084 (float)
Stats Max: 0.823730 0.157471 0.165771 0.024780 0.027481 0.011482 (float)
Stats Avg: 0.499779 -0.000458 -0.000042 0.001968 0.001786 0.000035 (float)
Stats StdDev: 0.099583 0.044395 0.042296 0.002729 0.002599 0.001806 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 4096 4096 4096 4096 4096 4096
Constant: No
Monochrome: No
MIP 1 of 7 (32 x 32):
Stats Min: 0.353027 -5.378906 -7.136719 0.065491 0.088745 -24.593750 (float)
Stats Max: 0.648438 5.746094 5.726562 49.593750 52.312500 18.546875 (float)
Stats Avg: 0.499778 -0.029305 -0.002658 8.073977 7.327510 0.141653 (float)
Stats StdDev: 0.051041 1.782274 1.793243 6.860120 6.770573 4.035535 (float)
Stats Min: 0.353027 -0.084045 -0.111511 0.000000 0.000000 -0.006004 (float)
Stats Max: 0.648438 0.089783 0.089478 0.012108 0.012772 0.004528 (float)
Stats Avg: 0.499778 -0.000458 -0.000042 0.001971 0.001789 0.000034 (float)
Stats StdDev: 0.051041 0.027848 0.028019 0.001675 0.001653 0.000985 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 1024 1024 1024 1024 1024 1024
Constant: No
Monochrome: No
MIP 2 of 7 (16 x 16):
Stats Min: 0.408203 -2.318359 -2.291016 1.525391 0.869629 -6.511719 (float)
Stats Max: 0.571777 1.604492 2.441406 24.937500 29.703125 7.585938 (float)
Stats Avg: 0.499782 -0.029325 -0.002681 8.074070 7.327562 0.141667 (float)
Stats StdDev: 0.025250 0.747315 0.821157 4.219419 4.267972 2.138862 (float)
Stats Min: 0.408203 -0.036224 -0.035797 0.000372 0.000212 -0.001590 (float)
Stats Max: 0.571777 0.025070 0.038147 0.006088 0.007252 0.001852 (float)
Stats Avg: 0.499782 -0.000458 -0.000042 0.001971 0.001789 0.000035 (float)
Stats StdDev: 0.025250 0.011677 0.012831 0.001030 0.001042 0.000522 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 256 256 256 256 256 256
Constant: No
Monochrome: No
MIP 3 of 7 (8 x 8):
Stats Min: 0.476562 -0.568359 -0.545898 3.021484 3.214844 -2.289062 (float)
Stats Max: 0.521973 0.496338 0.542969 16.359375 11.960938 3.521484 (float)
Stats Avg: 0.499767 -0.029307 -0.002679 8.073853 7.327240 0.141658 (float)
Stats StdDev: 0.011861 0.241849 0.270719 2.677819 1.987326 1.185046 (float)
Stats Min: 0.476562 -0.008881 -0.008530 0.000738 0.000785 -0.000559 (float)
Stats Max: 0.521973 0.007755 0.008484 0.003994 0.002920 0.000860 (float)
Stats Avg: 0.499767 -0.000457 -0.000042 0.001971 0.001789 0.000032 (float)
Stats StdDev: 0.011861 0.003779 0.004230 0.000654 0.000485 0.000289 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 64 64 64 64 64 64
Constant: No
Monochrome: No
MIP 4 of 7 (4 x 4):
Stats Min: 0.493896 -0.224976 -0.245972 6.308594 5.472656 -1.125977 (float)
Stats Max: 0.506836 0.211792 0.241699 9.656250 9.757812 1.217773 (float)
Stats Avg: 0.499771 -0.029306 -0.002665 8.072998 7.327881 0.141689 (float)
Stats StdDev: 0.003707 0.108191 0.148444 1.073994 1.155472 0.615748 (float)
Stats Min: 0.493896 -0.003515 -0.003843 0.001540 0.001336 -0.000275 (float)
Stats Max: 0.506836 0.003309 0.003777 0.002357 0.002382 0.000297 (float)
Stats Avg: 0.499771 -0.000458 -0.000042 0.001971 0.001789 0.000035 (float)
Stats StdDev: 0.003707 0.001690 0.002319 0.000262 0.000282 0.000149 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 16 16 16 16 16 16
Constant: No
Monochrome: No
MIP 5 of 7 (2 x 2):
Stats Min: 0.497070 -0.084290 -0.061310 7.578125 6.847656 -0.067810 (float)
Stats Max: 0.501953 0.052460 0.029831 8.906250 7.773438 0.638672 (float)
Stats Avg: 0.499756 -0.029305 -0.002676 8.074219 7.327148 0.141563 (float)
Stats StdDev: 0.002028 0.050268 0.036886 0.503088 0.345856 0.290336 (float)
Stats Min: 0.497070 -0.001317 -0.000958 0.001850 0.001672 -0.000000 (float)
Stats Max: 0.501953 0.000820 0.000466 0.002174 0.001898 0.000156 (float)
Stats Avg: 0.499756 -0.000458 -0.000042 0.001971 0.001789 0.000039 (float)
Stats StdDev: 0.002028 0.000785 0.000576 0.000123 0.000084 0.000068 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 4 4 4 4 4 4
Constant: No
Monochrome: No
MIP 6 of 7 (1 x 1):
Stats Min: 0.499756 -0.029312 -0.002670 8.070312 7.328125 0.141602 (float)
Stats Max: 0.499756 -0.029312 -0.002670 8.070312 7.328125 0.141602 (float)
Stats Avg: 0.499756 -0.029312 -0.002670 8.070312 7.328125 0.141602 (float)
Stats Min: 0.499756 -0.000458 -0.000000 0.001970 0.001789 0.000000 (float)
Stats Max: 0.499756 -0.000458 -0.000000 0.001970 0.001789 0.000000 (float)
Stats Avg: 0.499756 -0.000458 0.000000 0.001970 0.001789 0.000000 (float)
Stats StdDev: 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 (float)
Stats NanCount: 0 0 0 0 0 0
Stats InfCount: 0 0 0 0 0 0
Stats FiniteCount: 1 1 1 1 1 1
Constant: Yes
Constant Color: 0.499756 -0.029312 -0.002670 8.070312 7.328125 0.141602 (float)
Constant Color: 0.499756 -0.000458 -0.000000 0.001970 0.001789 0.000000 (float)
Monochrome: No