Front to back alpha and reflection rendering

Published December 04, 2020
Advertisement

The way I had been blending was wrong the whole time, but only presented itself when alpha and reflections were used together. The math was sound, but because the functions were recursive, it would do all of the reflections before all of the alpha blends, which failed miserable. The solution was to remove the recursion and do a breadth-first algorithm instead. I looked at what it would take and was concerned, so, instead, I looked back at the math. I'd pulled the blending algorithm from somewhere else, and it worked, but it had a combination of multiplication, addition, and subtraction. I realized that if I could rework the equation to have only multiplication, it wouldn't matter if it was recursive or breadth-first because multiplication is associative. I took a few hours to work out an advanced set of reflections with alpha by hand, then plugged in some variables, reworked the calculus into an algebraic set, and did manage to figure out how to make every single pipelines function be multiplication. All that was required was one extra float per pixel to act as temporary storage.

Here it is working:

The map view shows you that you are actually looking at a corner. On the left, that wall is a mirror, reflecting what's on the right side. On the side side, there is a blue wall with a very low alpha value, allowing you to see the untextured wall behind it with the color grid. This is not fake screen space reflection, but true, bounced raycasts.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement