Spherical Light Sampling for direct lighting only back

Board: Home Board index Raytracing General Development

(L) [2012/07/13] [ost by sajis997] [Spherical Light Sampling for direct lighting only] Wayback!

Hello forum,

I am stuck with one of the most primitive concepts in path tracing. I am using the spherical area light . I decouple the cornell scene lighting computation to direct lighting and indirect lighting. I am following the theories based on the book "AGI".

I have started with the direct lighting only. I am sampling the spherical light. The number of primary rays is equal to the number of shadow rays i am sending per pixel. Please check the following image:

[LINK http://www.student.itn.liu.se/~sajis997/cornellscenearea4.png]

I think the spherical light is not making any effect over the sides and top wall . I think those areas should be brighter.

I need some hint from the forum to the issues to look into to debug this issue.


Regards
Sajjad
(L) [2012/07/13] [ost by davepermen] [Spherical Light Sampling for direct lighting only] Wayback!

Do you evaluate the distance of the ray, and attentuate?
Do you measure the hit angle of the ray, and attentuate?
(L) [2012/07/13] [ost by sajis997] [Spherical Light Sampling for direct lighting only] Wayback!

Hi

I am not sure if you i get your questions . Which rays distance to attenuate ?

I am elaborating the algorithm that i am doing to implement the direct illumination and the questions you asked will hopefully be answered through the discussion.
Code: [LINK # Select all]Color PathTracer::computeDirectIllumination(const Intersection &intersection)
{
  //declare the color to store the radiance
  //from the direct illumination
  Color outputColor;
  
  //pointer to the area light
  AreaLight *areaLight;
  
  Color incomingRadiance,BRDF;
  Vector3D lightVec;
  Vector3D lightNormal;
  float incidentAngle;
  Intersection shadowIntersection;
  Ray shadowRay;
  
  bool shadowHit = false;
  
  //get the number of area lights in the scene
  unsigned int numberOfLights = mScene->getNumberOfAreaLights();
  unsigned int samples = getNumberOfSamples();
  for(unsigned int shadowRays = 0; shadowRays < samples ; shadowRays++)
  {
     for(unsigned int i = 0; i < numberOfLights;++i)
     {
    //get the area light - i in  the scene
    areaLight = mScene->getAreaLight(i);
    
    //get the shadow ray for the area light
    //we get a new shadow ray for each sample over the light source
    shadowRay = intersection.getShadowRay(areaLight);
    
    //check if the shadow ray intersect the scene
        //we also store the shadow hit information to check the lights material
    shadowHit = mScene->intersect(shadowRay,shadowIntersection);
    
        //we calculate the outgoing radiance under two options
        //if the shadow ray do not hit any intersectables between the inersection point in the scene and light sample point
        //OR if the shadow ray hit a intersectable that happen to be the light source
    if(!shadowHit || (shadowHit && shadowIntersection.mMaterial->emissive()))
        {
       
       //calculate the light vector - the irradiance - wio
           //getWorldPosition() gets the sample point within the sphere
       lightVec = areaLight->getWorldPosition() - intersection.mPosition;
       lightVec.normalize();
       
       //the light normal is already calculated while calculating the light's
       //world position in the previous step
       lightNormal = areaLight->getSampleNormal();
       
           //get the dot product between the negated light normal and light vector
       float ndotd = std::max(-lightNormal.dot(lightVec),0.0f);
       
       //the emissive radiance from the light source
           //which does not depend over ray's incident direction
           //it is the emissive color * scaling factor
       incomingRadiance = areaLight->getRadiance();
       //length squared between the light sample point and intersection point
       float d2 = lightVec.length2();
       
       
       incidentAngle = std::max(lightVec.dot(intersection.mNormal),0.0f);
       
       //get the BRDF
       BRDF = intersection.mMaterial->evalBRDF(intersection,lightVec);
       
       
       //accumulate the color for all the lights
       outputColor += (BRDF * incomingRadiance * incidentAngle * ndotd)/(areaLight->getPDF() * d2);
        }
     }
     outputColor /= samples;
  }
  
  
  return outputColor;
}

I think i am calculating the light vector and attentuating its contribution by 1/d2.

I am also calculating the hit angle and how to attentuate the hit angle ?


If you need any more explanation please do mention .

Regards
Sajjad
(L) [2012/07/15] [ost by Igors] [Spherical Light Sampling for direct lighting only] Wayback!

There is no some "spherical light", it's a general "area light", just with spherical shape you can get sampling more convenient, as a disk turned face to each point. But all calculations remain same as for area

Sample_Illum = Light_intensity * solid_angle / PI2 * dot(sample_dir, surface_normal);

At farther distances (to light) solid_angle becomes smaller so illum fades "auto". The solid_angle value can be calculated simplified (see topic "Veach thesis" here) or fully (see formulas in Wiki)
(L) [2012/07/20] [ost by sajis997] [Spherical Light Sampling for direct lighting only] Wayback!

Thanks for the hints.

I think i have reached a bit closer to the solution . But i am still having some arti-facts over the luminaire and some of the areas around it.

Please check it here:

[LINK http://www.student.itn.liu.se/~sajis997/cornellscenearea4.png]

Any idea what might have caused it? I am following the Peter Shirley's book "realistic ray tracing" and some of the concepts described over there about sampling the spherical luminarie is not clear to me and this is why i think i am doing something wrong. I believe that some one in the forum have already had gone through the book .

Lets go to Chapter 13 : Explicit Direct Lighting. And then to 13.2 - Sampling a spherical luminaire

At the end of the first paragraph it is written - "We now use a coordinate system defined with x at the origin, and a right-handed orthonormal basis with"

What does it mean by x at the origin ? To me x is the first intersection point where we are calculating the radiance value , right ?

In my case i am defining the sphere center at (0,0,0) and then transforming the origin by world transformation to the scene and then calculating the w as mentioned in the book, v = w X n and u = v X w.
This is how i am defining the orthonormal basis

I shall looking forward to more suggestion over this issue.

Regards
Sajjad
(L) [2012/07/23] [ost by sajis997] [Spherical Light Sampling for direct lighting only] Wayback!

Hello forum,

I managed to remove those artifacts from the surface of the luminaire. But the artifacts around the luminaire still exists(side walls and top walls) and i really need some hint to remove them. Please check the following image:

[LINK http://www.student.itn.liu.se/~sajis997/cornellscenearea5.png]

I shall be eagerly looking forward to your feed-back. I am calculating the direct lighting only so far by sampling over the spherical luminaire.


Thanks
Sajjad
(L) [2012/09/07] [ost by sajis997] [Spherical Light Sampling for direct lighting only] Wayback!

Hello forum,

I have uploaded an image rendered by monte carlo ray tracing with explicit direct lighting. It is rendered with 1024 paths/pixel

But i am getting some noise probably known as "salt and peppar".

Any hint or reference to remove those noise?

I did not have those noise with 100 paths/pixel.

[LINK http://www.student.itn.liu.se/~sajis997/cornell5.png]


Thanks
Sajjad

back