Coder Social home page Coder Social logo

Comments (4)

erichlof avatar erichlof commented on July 30, 2024 2

Hi @RealTecWare
Thank you for the error report and thanks for the link to Call Stack Size calculator - that is helpful! I was searching for something like that on the internet, but only got StackOverflow help/answers as results. I somehow missed your link!

Now about the errors, I recently found that the recursive BVH builder is finicky when it comes to object dimensions. If the scaling of the object is not within a certain range with respect to the overall scene dimensions, the recursive builder will go on and on, never correctly splitting the current triangles in the current workList into 2 groups, left and right, and thus never successfully spawning 2 smaller child bounding boxes from the parent bounding box.

I did try to mitigate this with trial and error, which is why I have the exact 'model settings' that you can comment and uncomment for the appropriate model you are trying to load. I'm curious, did the Buddha model crash on your machine, using my tested dimensions settings for that Buddha model?

I am actively looking for a way to make the builder more robust to these different scaling situations. As I mentioned before on another thread in this repo, this builder is the most complex 300-or so lines of code I have ever attempted using and maintaining in a project. For months I had to go line by line, trying to understand it fully. I understand most of it, but the line 'step = (stop-start)/24' grid sizing that keeps going down as the builder steps through the levels of hierarchy I still don't fully grasp. ;-) This is where things go wrong and the recursive builder just keeps spinning its wheels until it exceeds the call stack size. Different numbers substituted for the '24' in that above equation crash certain models and scales, and perform fine on others - it's hit or miss.

Thanks again, I'll update if I make any progress.
-Erich

from three.js-pathtracing-renderer.

RealTecWare avatar RealTecWare commented on July 30, 2024 1

I try to mitigate this with trial and error, which is why I have the exact 'model settings' that you can comment and uncomment for the appropriate model you are trying to load. I'm curious, did the Buddha model crash on your machine, using my tested dimensions settings for that Buddha model?

Hy Erich,

I tested it with your information and set the model settings and with the necessary scaling of the model it works very nice, so I think the my issue is fixed by this.

Hope the callstack snippet helps you :)

Thanks for your fast answer 👍

-Fabian

from three.js-pathtracing-renderer.

erichlof avatar erichlof commented on July 30, 2024

@RealTecWare ,
Glad to hear you got it working! Yes if the model dimensions are not within a certain window, the recursive builder spins its wheels until it crashes. I'm still trying to determine the boundary condition where it succeeds up to that boundary, and beyond which it fails. Hopefully in the future I can make the builder less fragile and less prone to this kind of catastrophic error.

I'm also about to dive into writing a LBVH which uses Morton codes and bit manipulations inside the fragment shader (now available with WebGL 2.0 support from three.js). Instead of recursively building on the CPU beforehand, it basically builds and re-builds the entire acceleration structure from scratch every animation frame on a GPU texture, so you can have arbitrary morphing and animating triangle geometry, as in real-time games. That builder will be even more complex than the current one (ha), but I'll at least give it a try.

Thanks again!
-Erich

from three.js-pathtracing-renderer.

erichlof avatar erichlof commented on July 30, 2024

@RealTecWare
Hi Fabian,
Just wanted to give you a progress update on the BVH builder. I removed the recursive builder that was crashing, and in its place a created an iterative version. When I was new to BVH builders, the recursive one was more intuitive code-wise but was prone to crashing as you saw. With the iterative version, I had to create and maintain a stack and stack pointer, then the builder goes down left branches (stackptr ++) and then back up the right branches (stackptr --). It took a lot of trial and error to make it behave correctly, but now it is much more robust! You should have no problem rotating, translating, or scaling a model upon loading it with the objLoader provided by the three.js library - the builder should just do its thing and work now. :)

new Iterative builder demo

When I see that you have read this, I might close out this issue if that's ok with you - the recursive builder has been removed.
Take care,
-Erich

from three.js-pathtracing-renderer.

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.