dilevin / computer-graphics-ray-tracing

Computer Graphics Assignment about Ray Tracing
1 stars 5 forks source link

Stuck on getting shadows, mirrors, and lighting correct #59

Open RudainaK opened 1 year ago

RudainaK commented 1 year ago

Hi, I've been debugging for over a day now and I think I've gone through most of the github issues trying to see what might be wrong. I did fix a few things but I've hit a wall.

Here are some sample images, all done with max recursive calls = 10:

sphere-and-plane.json: image

two-spheres-and-plane.json: image

sphere-packing.json: image

For the sake of experimenting, i set max recursive calls = 1 and got the following:

sphere-and-plane.json: image

two-spheres-and-plane.json: image

sphere-packing.json: image

I'm pretty sure it has something to do with blinn-phong because of how weirdly bright some of the images are (especially sphere-packing), but I've double checked my equations and they seem to match unless there was something I misunderstood. If anyone has any ideas/had similar issues, I'd appreciate the help

RudainaK commented 1 year ago

Quick update, I resolved 1 issue (reflect.cpp needed to normalize some stuff), so I've started getting reflections (granted they are a little broken), and it seems adding a fudge factor at all was causing me issues with shadows, but they are still weirdly bright

max recursive calls = 10

sphere-and-plane.json: image

two-spheres-and-plane.json: image

sphere-packing.json: image

RudainaK commented 1 year ago

its definitely an issue with the diffusion part, specular + ambient only results in this

image

i don't think its completely right either, but at least its kinda pretty

panuelosj commented 1 year ago

The weird ring looks like a problem in your specular part, might be in issue in computing H. You have weird cropping in your reflections, probably due to too large a fudge factor in the offset.

AlexProtoss commented 1 year ago

I have met the same problem with you, here are some hints from my solution, maybe cannot fix to yours but ... you know, just check :)

  1. check reflect equation from textbook, noted that there are some different parameter when calculating reflect's blinn. this may help you fix some part cannot reflect(eg: reflection of the yellow ball lack of some parts)
  2. maybe you forgot to use km, which may cause strong reflect (too white).
  3. try not generate too much iteration when debuging, 1 or 2 is enough
  4. if there are further problems, try tracing into one specfic pixel and check what happen in your algo, try to compute the result by yourself from textbook and compare it
RudainaK commented 1 year ago

For parts of the image being way too bright, did you find part of the issue was in your diffusion calculation? At the moment I think that's the biggest culprit but I dont understand whats wrong with it