Giter Club home page Giter Club logo

Comments (10)

Gjacquenot avatar Gjacquenot commented on May 19, 2024 1

Thanks a lot @syoyo ! It worked!

$ ./bug.exe 1
This program exposes a possible accuracy bug with nanort.
A slight variation on direction[0] makes nanort misses a real intersection.
Called without argument, we run a normal case where a ray creates an intersection on a single triangle
Called with one argument, we slightty changes the direction and have a no intersection result, that is not normal
directions[0] = -5.30288e-017
We have the expected result
Intersection isect.u =0.68 v = 0.131201

from nanort.

syoyo avatar syoyo commented on May 19, 2024

At least I can reproduce an issue. I will investigate!

from nanort.

Gjacquenot avatar Gjacquenot commented on May 19, 2024

Thanks for your time. I have reproduced it on:

  • Windows with g++ and MSVC.
  • MacOSX with g++/clang

It seems also that if we replace double with float, bug also appears (but make no sense since below float precision)

I am not an expert with template class, but I have weird to have 1.0f constant in functions/methods where we use double template. Maybe a lead to follow...

Again thanks for your time

from nanort.

syoyo avatar syoyo commented on May 19, 2024

There was an unexpected offset value added to ray direction : 7490e9b#diff-6ae3ef545df31bcbb8d6f3814304e805L2029 and this was the source of the issue.

And also removed some float precision constant value.

Now fixed and I got expected result(your test code is added to test/regression/possible-accuracy-problem-30

from nanort.

Gjacquenot avatar Gjacquenot commented on May 19, 2024

Wow, that was fast... I suspected it right, but had no clue that we should use static_cast to fix the problem. Thanks a lot!

from nanort.

syoyo avatar syoyo commented on May 19, 2024

Yeah! Recent compiler shoud generate immediate value for static_cast(CONSTANT_VALUE) at compile time optimization so no performance slowdown! > we should use static_cast

from nanort.

syoyo avatar syoyo commented on May 19, 2024

I have changed to use template specialization for IntersectRayAABB 206543c#diff-6ae3ef545df31bcbb8d6f3814304e805R1900 This will give more precise intersection result for double type

from nanort.

Gjacquenot avatar Gjacquenot commented on May 19, 2024

Hello @syoyo , I have tried to run the regression test I have proposed with g++8 and clang++ on the latest version. I thought it was solved, but the bug reappeared. Could you please try yourself?

$ make -f Makefile.dev
clang++ -I../../../ -std=c++11 -fsanitize=address -g -O0 -o bug main.cc

$ ./bug
This program exposes a possible accuracy bug with nanort.
A slight variation on direction[0] makes nanort misses a real intersection.
Called without argument, we run a normal case where a ray creates an intersection on a single triangle
Called with one argument, we slightty changes the direction and have a no intersection result, that is not normal
directions[0] = 0
We have the expected result
Intersection isect.u =0.68 v = 0.131201

$ ./bug 1
This program exposes a possible accuracy bug with nanort.
A slight variation on direction[0] makes nanort misses a real intersection.
Called without argument, we run a normal case where a ray creates an intersection on a single triangle
Called with one argument, we slightty changes the direction and have a no intersection result, that is not normal
directions[0] = -5.30288e-17
No intersection detected
We get the wrong result

from nanort.

syoyo avatar syoyo commented on May 19, 2024

I can reproduce bug 1.

After brief investigation, ray-AABB test fails for very small value(around or less than double precision epsilon which is 2.2e-16). I think ray-AABB test is not robust or fails for denormal number. I need more investigation.

from nanort.

syoyo avatar syoyo commented on May 19, 2024

Oh, its my fault. Simply I forgot to add sign when returning inf in vsafe_inverse(). Now fixed in this commit: 61309ec
and regression test should pass.

from nanort.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.