Skip to content
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

Support for Sphere Primitives in Ray Tracing #150

Open
ACMLCZH opened this issue Jun 2, 2024 · 1 comment
Open

Support for Sphere Primitives in Ray Tracing #150

ACMLCZH opened this issue Jun 2, 2024 · 1 comment

Comments

@ACMLCZH
Copy link

ACMLCZH commented Jun 2, 2024

Hello,

I’ve been using LuisaRender for scene rendering and I’m really impressed with its efficiency and performance. However, I’ve noticed that particles (represented as sphere primitives) are created as meshes in the scene. This can be memory-intensive, especially when rendering a large number of spheres or particles, even when the subdivision is set to 0.

I understand that OptiX, which is used in LuisaCompute for ray tracing, supports sphere primitives. This feature could potentially reduce the memory footprint and improve the efficiency of rendering scenes with a large number of spheres or particles.

In the LuisaCompute code, specifically in the file [src/backends/cuda/optix_api.h], I noticed that sphereArray is defined in BuildInput but it doesn’t seem to be used anywhere. I’m wondering if it would be possible to add support for sphere primitives in the ray tracing process using this or a similar approach.

It would also be helpful if you could provide some guidance on how to modify the LuisaCompute and LuisaRender code to support this functionality. For example, how to add spheres in CUDA in LuisaCompute and how to modify the accel_option in LuisaRender.

@Mike-Leo-Smith
Copy link
Contributor

Mike-Leo-Smith commented Jun 3, 2024

Hi, @ACMLCZH

We're very encouraged to hear that you're using Luisa in your work and thanks for the valuable feedback!

The optix_api.h file is generated from the official OptiX headers so the original sphere interfaces are included but we haven't made wrapper interfaces for it as a LuisaCompute feature.

As an alternative, in LuisaCompute (but not LuisaRender), we currently support procedural primitives, which are generic AABBs with user-defined intersection/any-hit functions. Examples can be found in test_procedural (featuring custom sphere primitives) and test_path_tracing_cutout (featuring user-controlled intersection behavior). I guess this feature should be sufficient for implementing an efficient particle system.

The current LuisaRender design is somewhat coupled with triangle meshes and hasn't incorporated other primitives into its scene geometry representation. To extend the geometry, the main files to change include

  • LuisaRender/src/base/shape.[h|cpp]: the base class for all primitive/instanced shapes;
  • LuisaRender/src/base/geometry.[h|cpp]: controlling the scene geometry representation and ray intersection; and
  • LuisaRender/src/lights/diffuse.cpp: the area light plug-in that samples the surfaces of primitives.

This would be a very meaningful extension for the renderer and I'm willing to implement it soon. I might do the refactoring in the following week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants