Jump to content
  • Advertisement
Sign in to follow this  

ray tracing anomolies and light question

This topic is 4560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've been browsing the forums for a while and picked up alot of info from you guys so thanks for that, anyway more to the point I've been playing about with ray tracing and I've been able to get a very basic naive recursive ray tracer working but I've come across a couple of problems. Firstly my question, I am unsure how the actual light object works. When a ray is cast through the scene it bounces off of the spheres and the final colour is the pixelcolour + the reflected colour (not implemented phong shading yet). If it doesnt hit an object the pixel colour is black. This seems to work but im not sure how to implement point lights. Does anyone have a tutorial? Im not to sure what functions to implement or how it works, eg if a ray hits a light what extra calculations/information needs to be processed? Sorry if this is a newb question. Also I am generating alot of noise in my ray traced images. If you would kindly look at http://www.flickr.com/photos/93606551@N00/88762588/in/photostream/ you will see an image that i have generated. Its noisey and a dark ring is visible. Also notice the over saturation of the pixels the further along the x axis you go. Im thinking maybe supersampling will fix this problem but i dont understand WHY the dark ring is forming, its almost as if I have a light a tthe top right hand corner but thisis impossible as I dont have any light sources yet.. Any ideas?? If not thats ok, im more interested in implementing point lights. Thank you for reading my question and if you can help me in any way that would be great. Thanks Ste

Share this post

Link to post
Share on other sites
point lights are easy. they are isotopic, that is they radiate equally in all directions. imagin a sphere of photons being emmited from a point light. the sphere will increase in surface area as it travels away from the light. the density of photons will therefore decrease with this increase in surface area. the surface area of the sphere is 4pi*r^2 so the photon density is Power/4pi*r^2 this is the power/unit area. now we know the power per unit area when the surface is a distance of r away. we need one more thing, a projection factor to take into account the surface orientation. the formula for the irradiance(ie power/area) on a sruface is

I = (N DOT L)*(Power/4pi*r^2)

where N is the surface normal. L is the unit vector in the direction of the light. I could explain the geometry if I drew something but I'm sure you can find it. this is the cosine law for irradiance. imagin a laser hitting a surface in a perpendicular direction, now imagin the same laser in an obleque direction. one configuration will produce a point another will produce an illongated elipse. this is exactly what the cosine(dot product) takes into account, the decrease of photon density with respect to orientation.

so for a diffuse surface the reflected radiance is simply

R = p*I

where p is the reflectivity. this calculation would have to be done for each component of color r,g,b.

however some choose a slightly less physically correct model. it expands the types of effects a point light can have. instead of enforcing a 1/4pir^2 drop off of intensity. the intensity can be "artistically" picked.

usually you set quadratic, linear and constant terms for a qudratic equation for dropoff ie

dropoff = 1/(quad*r^2 + lin*r + const)

I = (N DOT L)*dropoff

and the rest is the same.

note that physically correct drop off is a special case of the above with:
quad = 4pi
lin = const = 0

also I'm not quite sure why your images look the way they do. but if you're implimenting shadow rays, this can be caused by not providing a delta value. when you trace a shadow ray you trace a ray from the surface to the light. but you dont want the surface point to intersect the ray. so instead of tracing from t = 0 you trace from t = .001 or something. another thing that could be wrong is you're not clamping your values in the 0 to 1 range. so high power stuff is coming out white.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!