Closed NPTP closed 4 years ago
After some tweaks, coefficient-wise product of I and the diffuse and specular coefficients seems to bring the brightness more in line with the solution. Is this correct usage? Still curious where km comes into play.
Got this far now by also using km to coefficient-wise scale my recursive reflections. Looks like all my reflections, specular etc are in the right place, but still way too bright. Is this still related to I and km or something else might be going on? (keep in mind I am of course also scaling the ambient light by the given constant, and have checked to ensure normalization of all relevant vectors...although I might be missing something!)
Mine (too bright!):
Solution (just right):
I am encountering the same problem lol, and I have no idea what's happening.
km is a vector for "Mirror Colour" (from Material.h). I believe it will be used for reflection. From both slides and textbook, it seems like using ka, kd, and ks is enough for blinn phong shading.
@NPTP I found my bug. In my loop, I add the ambient so many times. I should only add it once.
@NPTP I found my bug. In my loop, I add the ambient so many times. I should only add it once.
I thought this might be my problem too, but I only add the ambient once per call to blinn_phong_shading()
. Then only Lambertian and specular get added within the loop. So I'm still a bit stumped!
coefficient-wise product of I and the diffuse and specular coefficients seems to bring the brightness more in line with the solution. Is this correct usage?
Yes, you should be using coefficient-wise product. It doesn't make sense to use e.g. a dot(scalar) product here.
I thought this might be my problem too, but I only add the ambient once per call to
blinn_phong_shading()
. Then only Lambertian and specular get added within the loop. So I'm still a bit stumped!
I think I've tracked the issue down to my Lambertian. Using that alone (leaving ambient/specular at 0) still creates an image that's too bright. I've got, per each light that is visible/reachable from the surface, the kd (diffuse coefficient) doing coefficient-wise product with I (intensity), multiplied by max(0, n•l), where n is the normal at the surface and l is the direction from the ray to the light. I'm still checking to see if I missed normalizing any vectors anywhere (which might scale my output wrongly) and even caught one, but it didn't change the image... still too bright.
Hi, I don't really understand how we're meant to use the km and I values from materials and lights respectively. They are both 3-vectors but somehow have to scale other values. Using coefficient-wise products leads to bad results. At what stage should km come into the picture: when calculating blinn-phong shading, or elsewhere?
Just to provide an example: I had many strange visual effects, so I turned off the recursive calls for reflections, and am testing just the ambient + diffuse + specular lighting right now. However, my sphere-and-plane is still much brighter than the example image, even though there's "less lighting" being accounted for since I'm not reflecting anything yet: Mine: Solution:
I have a suspicion this has something to do with the light intensity "I" (and maybe km when reflections are turned back on) but I'm not sure how to apply it... Thanks!!
EDIT: For completeness, here are some more images. None of these use recursive calls either (getting a different issue there)
Ambient + diffuse:
Ambient + specular:
Just ambient: