this post was submitted on 06 Jul 2023
1 points (100.0% liked)
GameDev
2768 readers
1 users here now
A community about game development.
Rules:
- Adhere to the general lemmy.blahaj.zone rules (#1 being no homophobia, transphobia, racism or other exclusionary content)
- Self-promotion is fine as long as it's not spammy - share your progress, insights, techniques and mishaps! If you recently posted, update the previous post instead of filling the frontpage with your project
- Hide NSFW/NSFL content behind a clear warning, for example: [NSFW Nudity]
More rules might follow if they become necessary; general rule is don't be a pain in the butt. Have fun! ♥
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
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.