Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Diffuse lighting problem

This topic is 5233 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

Hello, I''m currently trying to implement lighting on my raytracer. I started off by Phong shading but it wasn''t working. So I decided to take it step by step. So I started to implement Diffuse lighting. The problem is I can''t seem to get it working. My code: r = r + r * lr * normal.dot(light) * diff; Where r is surface color, lr is light color, normal and light are unit vectors and diff is the surface''s diffuse constant. When debugging, the resulting color differences along a sphere are tiny, making the first 2 digits always the same, producing a sphere with a single color when converted to 24 bit colors for printing on screen. The back of the sphere is black, meaning it isn''t receiving any light, which is correct. But what about the monocolor? Is there some error on my code? Thank you for your answers, JVFF

Share this post

Link to post
Share on other sites
I think you''ve got one too many ''r''s in there - I''ve not done raytracing, but it would make sense to me that

color at a point = sum of all ( lightcolor * normal.dot(light) * diff)

If you''re doing that iteratively I can understand the first ''r = r'' bit, but are you sure you should be multiplying that second term by r?

Share this post

Link to post
Share on other sites

  • 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!