Recently I come across the term forward rendering. I'm kind of curious how this could be done in OpenGL. I have done a lot of search on this, majority of the result I get are on theory but not code implementation. May I know is there any code implementation on OpenGL for this rendering technique?
Forward rendering is the classic approach to rendering where the data for a scene is generally used directly to calculate a final pixel color in a single pass (additional post-processing passes can be used as well, but these are usually still considered part of forward rendering). The alternative, deferred rendering, generally encodes much more data (not necessarily actual colors) to an intermediate target, then defers the final render pass that uses the intermediate target as its source. |
|||
|
There are two major types of rendering:
In both types you have you objects and lights present in the scene, but the difference is when to calculate lighting. Forward rendering Render object, and while running its (usually) fragment shader, for each fragment you calculate lighting from all the light sources. So, you for every object, and all of its fragments, calculate ligthing. Why is this good and why is it bad?
Deferred rendering Render into buffers the data that is required for calculating lighting later, such as diffuse color, specular power, normals... and after you've done that, run ligthing calculations for every light, but only on the parts of the image that cold possibly be affected by that light. Cons and pros?
In short, that's the difference between forward and deferred rendering. So if you put your lighting calculations directly into shading of the object, then it's called forward rendering. That means, almost any tutorial that you might find on the internet is probably implementing forward rendering type. Hope this helps. |
|||||||||||||
|