Why exactly is deferred rendering faster?
The GPU is still doing the same work per pixel, isn’t it?
Is it because there is less dependency chains as the buffers (albedo, normal, light, emission, …) are independent?
#gamdev #rendering #opengl
@[email protected] @[email protected] @opengl @[email protected]
TL;DR : With deferred rendering the light is calculated only once per pixel. With the forward rendering however the light can be calculated thousand of times per pixel.
No, there is less calculation with the deferred rendering. It’s because there is a lot of objects on a scene. The rendering engine (actually the 3D API like Vulkan) is trying to render each object. It identify what pixel on the screen the object is using and it is launching the calculation of the color of the pixel. This process is looping for each object in the scene. If two objects are using the same pixels, the engine is determining for each pixel if it is closer or not of the camera compared to the previous object rendered. If it is closer, it launch the calculation of the color for this new pixel. You can think of it like drawing. On a sketch, you are drawing a line, then another and another on top of each other. This is so obvious that this process of rendering a 3D scene is also called drawing.
However, as you can tell, the calculation of a texel (texture pixel) can be run a lot of times for a single pixel. This is why forward rendering is soo inefficient because if you rerender a texel 1000 times, you recalculate the light and all 1000 times.
The goal of deferred rendering is to do the rendering of a scene in two stage. The first stage is producing multiple texture with basic data : the depth of the pixel (how far is it from the camera), the raw texture applied on each objects of the scene along with the normal map, etc. And then, in the second stage, the light, shadow, etc. is calculated based on the texture made by the first stage. The big aventage of this method is that the light and other expensive calculation are only made once per pixel.
Usually renderers do a z pre-pass to eliminate overdraw. Real reason for deferred shading to be faster would be lights. In normal forward, every light has to be accumulated for every pixel. And this problem is solved today with clustered shading (aka forward+). Link to paper: https://www.cse.chalmers.se/~uffe/clustered_shading_preprint.pdf
In short, these days deferred shading is slower because of memory bandwidth.