Invitation

Whoever wants to contribute to this blog , posting his experiences on the same place, please send me a message !
Showing posts with label nvidia. Show all posts
Showing posts with label nvidia. Show all posts

Tuesday, May 8, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 11 (Light sampling)

What should happen if several lights appear into the scene ?

I mean : how do we select the appropriate light to get a sample from where the light path starts?

To solve this problem i used this simple two-legged method :

First Case: having only lights covering a non-zero area (no point lights)


If the lights in the scene  are not point lights(which do not have volume or cover any area) then i select the appropriate light according to this procedure :

a.I compute the area of the surface that each light covers
b.I compute the total area of the lights
c. Each light has the probability  pi  to be chosen depending on the percentage of the total light area belonging to it. pi = lightArea/totalLightArea

Second  Case : Scene contains (zero-volume and area) point lights


In the case that a point light resides in the scene, then we have the problem using the above procedure there is no possibility to be selected for sample creation. This is logical due to the fictional nature of the point lights.

The usage of very small lights (e.g. sphere lights with the smallest possible diameter) is not a solution because the image converges extremely slow with high variance.

So i select them according to the brilliance of each light. The probability to pi select each light is
pi= lightEmmision / totalLightsEmission

Where "lightEmmision" is the light emitting power (emission color)of each light and where " totalLightsEmission" is the sum of the emission of all the lights.

First Case : Three lights 2 spheres , 1 area light 


Second Case: there is a purple-ish point light at the black dot (added to the image for illustrative reasons)

ΝΕΧΤ POSTs: Schlick specular gloss , Depth of field , Better refractions and reflections  

Saturday, May 5, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 10 (Importance sampling)

Up until the last post , i have been using a very naive importance sampling. I found the several combinations of paths for each pixel , the color of which was finally the average value of the light gathered from the various paths. This had the problem that a very probable path e.g. a path with 3 hops from the eye hitting the light , had the same weight in the total light gathering with a very long path which was a lot less probable to happen.

I have changed the weights of the paths in a manner that the more probable the paths are, the more is the contribution of that path into the final gathering.

So i used , a weighted average such as this : 


In this figure the w(x) is the weight of the path x , and p(x) is the probability of this path actually happening
So i had these results with the exact same materials and scene : 




Without Importance Sampling (1/N)


With weighted importance sampling


NEXT POST : I have also implemented the specular gloss material ,as described by Phong model, and i am implementing the Schlick metallness coefficient right now

Thursday, April 26, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 7 (Scene Loader)

My next installment in the thesis project is a scene loader.

I used the free open source Pugi XML API which is very easy , magnitudes easier than anything else I tried. And i describe my scene using an xml -document. My code is simpler now and any changes can be made quickly.

An simple example of an XML file with the scene parameters and materials only (no geometry , to maintain simplicity ) is this.

I remind you that i haven't found a way to do the tile processing , the problem that i described in the latter post. So, any help is still welcome.

Sunday, April 22, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 6 (Correct Refractions)

My last accomplishment on my way to create this renderer is the correction of the refractive materials.

In the following pictures, the material of the ball is totally refractive so it is not to be mistaken for real-world glass for example. In the last picture , the refractive material is exaggerated to highlight the appearance of colored caustics







At the moment I am creating an xml scene loader for easy scene parameter and geometry  loading.


Friday, March 30, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 4 (Multiple lights and some bug fixes)

Hello again,

This time I have very little stuff to show couple of bugs , several performance issues and multiple lights :

With the help from the nvidia developers forum i corrected a bug in my random generator. I passed my random generator "seed" from hop to hop in the path by value, whereas by reference was the best solution to update the seed variable.

On top of that I have made several performance enhancements so the project in the simple cornel scene runs at about twice the speed(and some "change") at 33fps (512X512 scene with 4 hops at each path) instead of 13 at the same configuration Rendering is here 

I have also made spherical lights and organized the Light Class so that the addition of new types will be quick and easy


Here is the rendering with the three lights at 1024X1024 resolution

Next step will be to correct my errors in the BRDFs of the reflective and refractive materials

Monday, March 12, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 3 (Simple Refractions)

Hello !

Today i managed to create the first simple refractions into my project.The refractions are far from finished yet but i think they are good enough to show them to you. As you can see i have also implemented spherical lights

The material has refractions only , without anything else and it is also simple ,without any tricks yet.

_____________________________________________________________________
SAMPLE CODE :


 //refraction coefficient


current_prd.countEmitted = true;
float ior = 0.0;
 if(!current_prd.inside)
ior=1.33;
 else
ior=1/1.33;

if(refract(current_prd.direction, ray.direction, ffnormal, ior))
{
if(current_prd.inside)
{
current_prd.cos1 = dot( -ffnormal, -ray.direction );
current_prd.cos2 = dot( ffnormal, current_prd.direction );
}
else
{
current_prd.cos1 = dot( ffnormal, -ray.direction );
current_prd.cos2 = dot( -ffnormal, current_prd.direction );
}

}
else//internal reflection
{
current_prd.direction = reflect(ray.direction,- ffnormal);

current_prd.cos1 = dot( -ffnormal, -ray.direction );
current_prd.cos2 = dot(- ffnormal, current_prd.direction );
}


current_prd.attenuation = diffuse_color*Kt;

if(current_prd.inside)
{
 //Compute Beer's law
current_prd.attenuation = current_prd.attenuation * powf( diffuse_color , t_hit);
}

current_prd.inside = !current_prd.inside;

current_prd.hitDistance =   length(ray.origin - hitpoint);
current_prd.ffnormal = ffnormal;

 _________________________________________

Please , i need your comments to make it better and find any mistakes that i make !

Render 2

Nvidia Optix 2.5 is out !

Two weeks ago , nvidia has updated Optix. The new version is way faster than 2.1 and has several bugfixes and new features ... Update your system as soon as possible!

It will speedup your applications by 40% to 3 times faster on the same hardware , depending on the code.

The 2 features that are still missing and would be useful to have in a future release are:

*Compatibility with Nvidia's Nsight debugging utility
* And mainly the ability to declare buffers within the optix code.

That would be very handy in my application!

Sunday, February 19, 2012

Bidirectional Path Tracing using Nvidia Optix , Part 2 (Diffuse + reflections)

After minimal changes , I present you my first reflections (Diffuse Coefficient is Kd=0.1 and reflectance coefficient Kr= 0.9 in this example, these probabilities are used in the Russian Roulette. )



In these two first posts, the intensity of the light is attenuating at each "hop" of the path ,  as a product  of : 
 BDpathEye[eyeIndex].contribution*BDpathEye[eyeIndex].cosin*2.0*M_PIf; 
(2*π is used because at this point only diffuse surfaces are concidered)

Contribution is the brdf of the ray-hitpoint. 



In the next post(s) , i will try to improve this factor by adding the attenuation from the traversed distance(r^2) into the mix , also i will add refraction and specular coefficient 

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++)
{
contrib=make_float3(1.0,1.0,1.0);

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;

}
tmpColor+=contrib;
}
}

    
  tmpColor/=(float)(lightDepth*eyeDepth);
  
  color += tmpColor;
  } while (--samples_per_pixel);

//combination

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

Friday, May 6, 2011

Bidirectional Ray/Path Tracing using Nvidia Optix 2.1 --- A presentation

Επιτέλους το πρωτο ποστ! // And there it is my first post!!

Καλώς το λοιπόν το πρώτο ποστ μου . Προφανώς ο στόχος που είχα θέσει ήταν υπεραισιόδοξος. Αυτό όμως δεν με εμποδίζει να ανεβάσω αυτή την παρουσίαση που έγινε στα πλαίσια του μαθήματος γραφικών της σχολής: Είναι σχετικά με το Bidirectional Ray/Path Tracing και το Nvidia Optix 2.1 και μπορούν να συνδυαστούν . Αυτό θα είναι και εκτός απροόπτου το θέμα της διπλωματικής μου εργασίας

Οριστε: presentation

In this post I present briefly the Bidirectional Ray/Path Tracing technique , Nvidia Optix 2.1  and the posibility to execute BPT on Optix. This will be part of my master-thesis due next year

Any future progress , will be posted most probably in english