Giter VIP home page Giter VIP logo

Comments (2)

erichlof avatar erichlof commented on June 16, 2024 2

Hello @andreasrosdal,

Thank you for your inquiry. Your Freeciv game looks really cool! It's impressive how many components it has going on at the same time!

Unfortunately at this point in time, my path tracing engine is not up to the task of handling multiple game objects and multiple materials. I have made 2 very simple games with it - a 3d pong game and a anti-gravity billiards game. But these were more proof-of-concept in nature, to show that we could have real-time pathtracing in the browser. These simple games work only because I carefully cherry-picked the genre - Pong only needing 1 sphere and 2 rectangular boxes, and the anti-gravity billiards needing 16 objects, but they are all simple small spheres of the same size (ray tracers handle spheres and boxes rather efficiently, so I leveraged this feature).

I noticed while trying your game that you have real 3d models and environments (terrain). Even if you limited your on-screen objects to a handful (which would stifle your level design I'm sure), each and every model would need its own acceleration structure, namely a BVH. Now I have tested single triangle meshes and my system has been able to efficiently walk the BVH tree for a single model in the scene, but I haven't fully handled multiple models and animation support yet (which most 3d game characters need), as this would require rebuilding the entire trees each animation frame. Something like this has been done in the past for the Brigade 3 engine, but they were using C++ and multiple GPUs to achieve this monumental feat. NVIDIA is slowly creeping up to real-time path tracing for games, but all of their software is proprietary and the end user must have a powerful RTX card to make anything run on their systems.

In other words, if you just threw all of your game objects and terrain into a scene to be pathtraced, it would probably crash the browser, especially on mobile. If it did happen to run, it would probably crawl at <5 fps. An active area of my research is trying to get cell phones and tablets to be able to path trace multiple triangle models, but I'm just not quite there yet.

I have made some baby steps in tracing multiple models, but it's not optimized enough. You can see some of the progress on my Sentinel clone project - 'The Sentinel: 2nd Look'. It has very simple triangle models (<30 triangles per model) and no animation support, just rigid rotation and translation of a stiff model in 1 pose. But there is a ton of work to do before a full game with all of its objects and their various materials could be handled at interactive framerates, let alone 30-60 fps.

I'm sorry to disappoint you with all these reasons why you can't just 'make it run' with my engine. But having said that, honestly I really like your game's current graphics and visual style! I tried it out on desktop and my phone, and it runs very smoothly on both, and the graphics are stylistic and clear. I'm not so sure that path tracing would add much to what you've already got working and looking so well.

I hope someday that we will have true path traced full games on all devices in the browser, but either I or someone else will have to make several more breakthroughs - or, we'll have to wait until the physical hardware gets way faster, like RTX cell phone chips, ha!

Thanks again for the questions and best of luck with your project!
-Erich

from three.js-pathtracing-renderer.

andreasrosdal avatar andreasrosdal commented on June 16, 2024 2

Thank you for the detailed reply about your path tracing engine. An ideal raytracer renderer for Three.js games could be implemented as a drop-in replacement for WebGLRenderer, called eg. PathTracingRenderer or RayTracerRenderer.

I hope someday that we will have true path traced full games on all devices in the browser, but either I or someone else will have to make several more breakthroughs - or, we'll have to wait until the physical hardware gets way faster, like RTX cell phone chips, ha!

I would advice to make a prototype raytracer renderer for Three.js as a replacement for WebGLRenderer, as simple and crude as possible, and then optimizing performance of this can be done in the future with Moore's law.

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.