Screen-Space Reflections Explained
Introduction Some of the most difficult algorithms to properly implement for graphics developers are the family of algorithms used for screen-space reflections (SSR). These are difficult to implement because they require programmers to navigate peculiarities of transformations and coordinate systems inherent to their rendering API, as well as requiring a solid understanding of Linear Algebra. This is further complicated by the need for rendering multiple data buffers for use in the algorithm -- the algorithm I will describe requires buffers for depth, normal vectors, and an output color buffer from the lighting pass. These are buffers commonly generated and used in a deferred renderer though this algorithm could also be used in a forward renderer, as well. Methodology The simplest SSR algorithm starts with the view space calculation of the reflection vector (R) from the view (V) and normal (N) vectors using the formula V - 2.0 * dot(N,V) * N, where V = pixelViewSpacePosition - cameraP