just asking for help on a really specific path tracing issue where my colours end up dropping below zero for no reason. i genuienly do not have 1 negative in my code where colour calculations are happening which means there should be no reason for my numbers to drop as low as -2. my scene also gets gradually darker as more samples get taken
im in a fully outdoor area with physically accurate lighting calculations so i have no idea why its happening. but i feel like its to do with this which i got after someone else tried helping me with another issue
Rendered here is designed to start as zero, and old colour is reading from the previous value of a buffer (which is normalised so im doing calculations using decimals between 0 and 1 for all colour values since its more convenient to do so)
and before anyone asks, yes im using a u32 for my image and writing in rgba with u8. my alpha value is also locked to 255 and i am changing my colours into rgb format by multiplying by 255.
ive also been stuck on this for like 1-2 weeks or smtn
i figured out what it was. it was part of an if statement that checked if the screen was to be replaced, but it also had a condition that checked for if the last pixel colour was pure black, where if it met either of them it would switch the last colour out for white
this was the previous code
if Mode == CEnums.ModeType.Replace or OldColour == Vec3Zero then
OldColour = White
end
while the actual code should have been
if Mode == CEnums.ModeType.Replace then
OldColour = White
end
i only noticed when going through the debugger where i saw that after this if statement ran, it set OldColour to pure white even tho i wasnt trying to replace the screen. it is completely resolved now tho and there are no more weird white artefacts
just a couple more issues like scene darkening as samples accumulate and reflections being full black or part coloured depending on if the reflected ray hit an object or went off into the sky. seems more like a light drop off error since really close reflections are reflected just fine
i also fixed lights and reflections, it was just me calculating the pixels lighting after every bounce instead of doing all the bounces and THEN calculating the pixels lighting
(which in turn also fixed lights not wanting to work indoors)