Wow, Retinex is powerful!

Not sure about RawTherapee’s implementation but retinex has been around for a long time. There is no shortage of literature on the topic.