An Object as a Light source?

Hello developers,
Generally in OptiX a light source is defines as a point, can we make an object (like sphere or square) as a light source?
I am working on a modeling of large furnace, in which a light source is a whole flame, so I dont know how to make any object as a light source?

Thank you.

Again, OptiX is a general purpose ray casting SDK. It allows to implement pretty much any algorithm which requires to shoot rays, and as such you can also define arbitrary methods to light your scene.

The OptiX SDK examples also use light sources made from parallelograms (for example inside the path_tracer sample), and it is of course also possible to implement lights with other shapes like spheres or even arbitrary triangle meshes.

It’s always the same mechanism, you need a function to explicitly sample a point, emission (radiance, flux, etc.), and its probability density function value on the light source for direct lighting, and a function to return the emission when it’s hit by a ray (aka. implicit light sampling).

You should be able to find more information on things like these inside standard ray tracing literature and the internet.

In OptiX I implement the explicit light sampling function as callable program so that when multiple closest hit programs use that, they don’t duplicate the code.
The implicit light sampling is done inside the closest hit programs attached to the material assigned to the different light types.

If you approximate your flame volume by a mesh geometry and the appropriate emission on its surface, you would need to have the mesh geometry information available inside both of the light’s sampling functions.
You can do that in OptiX by using bindless buffers. Your light definition structure would need to contain the bindless buffer IDs of the mesh geometry (and indices if needed) to be able to access the mesh vertices for sampling. Bindless buffer IDs are explained inside the OptiX Programming Guide.

Be careful to either specify lights in world coordinates (recommended) or to add the necessary transformations in your light sampling functions when required.

Note that proper light sampling is already a slightly advanced topic which requires solid understanding of Monte Carlo methods for global illumination algorithms.

Thank you so much for your response, I will try these suggestions and get back to you if I need some help!

Hello developers,
I am stuck in calculating the direction vector between hit point and light source? As now my Light source is not a single point (Its a triangle shape) so how would I calculate the direction vector? I have seen the Path Tracer example, they have used path tracer camera, I want to implement it using pinhole camera.
I can calculate it by calculating distance over a whole shape, and find the shortest distance, bt it would take time. Can any one suggest me the better method for calculating this vector,

Sampling area light sources is normally done by integrating the contributions of many sample points over their area.

That’s why I said it’s “a slightly advanced topic which requires understanding of Monte Carlo methods for global illumination”. Things like these are too fundamental to be explained here.

Again, please read some standard ray tracing books and search the internet for topics with combinations of these keywords: ray tracing, Monte Carlo, global illumination, light sampling, path tracing.