Whoever wants to contribute to this blog , posting his experiences on the same place, please send me a message !

Wednesday, February 15, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 1 (Diffuse only)

Greetings again after so long time,

In this post i will show you my first results from my implementation of  Bidirectional Path Tracing using Nvidia Optix , which I have started 3  weeks  ago, as a part of my CS Master Thesis in  A.U.E.B.  (Athens,Greece ) For a quick overview of the theory , see here .  Warning , Post in the Greek language :-)

I will try to give a hybrid approach to the problem (using both Optix on GPU and some computations being made on the CPU to balance the computational load )

In this first post, I will show you the first really good rendering ,after correcting some mistakes that i have encountered during these 20 days. The implementation includes at this POINT only the basics , diffuse only surfaces with no visual effects or importance sampling. Reflection and refraction are under construction right now. So you will have them in a later post.

The code is pretty straightforward , but i will not post it right now because it is not finished . I have only strictly implemented the theory which is described in the classic thesis of Veach and similar papers.

I have gathered the best material (theory and staff) that i gather here - >

Example snippet from the main Optix- Function:

unsigned int seed = tea<16>(screen.x*launch_index.y+launch_index.x, frame_number);
  do {
    unsigned int x = samples_per_pixel%sqrt_num_samples;
    unsigned int y = samples_per_pixel/sqrt_num_samples;
    float2 jitter = make_float2(x-rnd(seed), y-rnd(seed));
    float2 d = pixel + jitter*jitter_scale;
    float3 ray_origin = eye;
    float3 ray_direction = normalize(d.x*U + d.y*V + W);

//1st Step : Eye-Path 
unsigned int eyeDepth=0u;
float3 tmpres = pathtrace_camera(ray_origin,ray_direction,seed,eyeDepth);
//2nd Step : Light-Path
unsigned int lightDepth=0u;
tmpres = pathtrace_light(seed,lightDepth); 

//3rd Step : Combination
 float3 tmpColor=make_float3(0.0,0.0,0.0);

for(int light=0;light<lightDepth;light++)
for(int eye=0;eye<eyeDepth;eye++)

for(int i=0;i<light;i++)
uint3 lightIndex =make_uint3(launch_index,i);
contrib *= BDpathLight[lightIndex].contribution*BDpathLight[lightIndex].cosin*2.0*M_PIf;

contrib *= (BDconnection(light ,eye)*2.0*M_PIf*2.0*M_PIf);

for(int j=0;j<eye;j++)
uint3 eyeIndex =make_uint3(launch_index,j);
contrib *= BDpathEye[eyeIndex].contribution*BDpathEye[eyeIndex].cosin*2.0*M_PIf;


  color += tmpColor;
  } while (--samples_per_pixel);


  float3 pixel_color = color/(float)(sqrt_num_samples*sqrt_num_samples);

1 comment: