Displaying X Particles Using Optix 5

107 views Asked by At

I am trying to Display 250 Frames of an animation using Nvidia Optix Ray-Tracing. I have this basical Particle Class:

struct Particle{
   float[3] location;
   float size;
   float[4] color;
   string State;

}

I am retrieving all the information (location, size, color and state) for each particle for each frame from .txt file generated in blender. The txt File looks something like this:

frame 001:
particle1 = {loc = (0,0,0), size = 0.1, color =(255, 255, 255, 255), state = "BORN"}

frame 002: 
...

I also am iterating trought all particles in frame x, converting them in an object of type particle (look above for the struct.) and putting them in an array that looks something like this:

Particles = {{part1, part2, part3}, {...}, {...}}

where each array inside of the main array represent a frame of the animation.

So I don't need to do any calculation using c++ or Optix, I just need to Render a particle of that size, at that location of that color.

I think the code would look something like this:

for(int frame = 0; frame <250; frame++){ //Iterate trought all the frames
   for(int i; i <= Particles[frame].size(), i++){ //Iterate trought all the particles in that frame
       //render them.
     }

} 

I am only missing the step to render them. I tried looking online for references but found nothing on particles in Optix. I looked into the source code of optixParticles Sample and found that in that case, optix renders particles as sphere with "Flat" shading, so in "blender way of working" spheres with an emission shader. But I cannot find anything more than that sample and I also cannot understand parts of that sample itself.

Is what I am trying to do possible in a relatively simple way? And If this is too much to ask or its unclear, is there a site of StackOverflow's family to ask explanations on a specific piece of code?

1

There are 1 answers

0
S.Frank Richarrd On

Take all your Particle data to CUDA device memory by adding your particles to the scenegraph of optix. then assign a default material that should only render the particles on the screen space with respect to the generated ray hits.