Lighting bug
Hi! I ported this to Rust (https://github.com/adihodos/raytracer.git), all went pretty smooth (I even added multithreadead support) until I added lighting support. Raytracing the Cornell box results in this ugliness :
.
Can you give me some hints as to why this is happening ?
That looks like possibly an overfliw from [O,1] when the reals are converted to int pixel values for output?
On Fri, Mar 22, 2019 at 7:02 AM Windows [email protected] wrote:
Hi! I ported this to Rust, all went pretty smooth (I even added multithreadead support) until I added lighting support. Raytracing the Cornell box results in this ugliness : [image: raytraced] https://user-images.githubusercontent.com/155867/54824392-75292b00-4cb3-11e9-8a4f-0e3fbcf8c5a4.png . Can you give me some hints as to why this is happening ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/petershirley/raytracingthenextweek/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/ACq6iiLCDUdgClG8132_zyni6AhC0v6Nks5vZNRzgaJpZM4cDhdO .
I understand. I printed out the pixel values and some are greater than 1. How can this be fixed ?
@adihodos I got same same thing but when I convert from PPM to PNG use this site https://www.freefileconvert.com/ppm-png it works and those over-saturated image disappear and look as it should Issue is what @petershirley said is but instead you can just use some Image crate
This looks similar to an issue I had, which I fixed by normalising the color when I converted to RGB.
Compute the max of r,g,b in the color vector, and scale so it doesn't wrap over 8 bits:
col = vec3( sqrt(col[0]), sqrt(col[1]), sqrt(col[2]) );
float max = ffmax(col[0], ffmax(col[1], col[2]))
int ir = int(255.99*col[0]/max);
int ig = int(255.99*col[1]/max);
int ib = int(255.99*col[2]/max);
(there might be a typo here, I didn't copy/paste my code which is in go not C++)
You can use this to add a color cap:
inline int colCap(int x) {
return x > 255 ? 255 : x;
}
Looks like a duplicate of RayTracing/raytracing.github.io#93 , or the same issue elsewhere.
Duplicate of #93