Fr/Projet Rembrandt: Difference between revisions

no edit summary
No edit summary
Line 16: Line 16:


;Le stade suivant est celui de l'ombre :
;Le stade suivant est celui de l'ombre :
: we render the scene again into a depth texture from the point of view of the lights. There will be one texture for every light casting shadows.
: nous rendons encore la scène dans une texture profondeur concernant les éclairages. Il y aura une texture pour chaque lumière diffusant des ombres.


;Then comes the Lighting Stage, with several substages :
;Ensuite, c'est le stade de l'éclairage, avec plusieurs sous-stades :
:*<u>Sky pass</u>: the sky is first drawn using classical method.
:*<u>Sky pass</u>: Le ciel est dessiné d'abord selon la méthode classique.
:*<u>Ambient pass</u>: the diffuse buffer is modulated with the ambient color of the scene and is drawn as a screen-aligned textured quad
:*<u>Ambient pass</u>: la mémoire-tampon "diffuse" est modulé avec la couleur ambiante de la scène, et est dessiné comme un quad texturé aligné sur l'écran
:*<u>Sunlight pass</u>: a second screen aligned quad is drawn and a shader computes the view position of every pixel to compute its diffuse and specular color, using the normal stored in the first stage. The resulting color is blended with the previous pass. Shadows are computed here by comparing the position of the pixel with the position of the light occluder stored in the shadow map.
:*<u>Sunlight pass</u>: Un second quad aligné à l'écran est dessiné et un shader examine la position pour calculer sa couleur "diffuse" et "specular" en utilisant le "normal" stocké dans le premier stade. La couleur résultante et mélangée avec la passe précédente. Les ombres sont examinées ici par comparaison de la position du pixel avec la position du cache lumière stockée dans la carte shadows
:*<u>Additional light pass</u>: the scene graph will be traversed another time to display light volumes (cone or frusta for spot lights, sphere for omni-directional lights) and their shader will add the light contributed by the source only on pixels receiving light.
:*<u>Fog pass</u>: a new screen aligned quad is draw and the position of the pixel is computed to evaluate the amount of fog the pixel has. The fog color is blended with the result of the previous stage.
:*<u>Transparent objects pass</u>: transparent objects (and clouds) are finally rendered using classical method.


:All lighting computations are accumulated in a single buffer that will be used for the last stage, in addition of the one computed by the Geometry stage.


;In the end, the Display Stage, with optional Post-Processing effect :
:The results of the previous buffers are pushed to the main framebuffer to be displayed, optionally modified to show Glow, Motion blur, HDR, redout or blackout, screen-space ambient occlusion, anti-aliasing, etc...


In FG, we end the rendering pipeline by displaying the [[Menubar|GUI]] and the [[HUD]].
:*<u>stade de la lumière additionnelle</u>: le scene graph sera traversé une autre fois pour afficher les volumes de lumière (cône ou tronc de cône pour les taches de lumière, sphère pour les lumières omni directionnelles), et leur shader ajoutera la lumière composée uniquement par les pixels éclairés.
:*<u>stade brouillard</u>: un nouveau quad aligné sur l'écran est dessiné, et la position du pixel est calculée pour évaluer la quantité de brouillard du pixel. La couleur du brouillard est mélangée avec le résultat du stade précédent.
:*<u>Stade des objets transparents</u>: les objets transparents (et les nuages) sont enfin rendus en utilisant la méthode classique.


All these stages are more precisely described if this [http://bat710.univ-lyon1.fr/~jciehl/Public/educ/GAMA/2007/Deferred_Shading_Tutorial_SBGAMES2005.pdf tutorial] that is the basis of the current code, with some addition and modifications.
:Tous les données de lumière sont accumulées dans une seule mémoire tampon, qui sera utilisée pour le dernier stade en addition au stade Géométrie.


== Caveats ==
;A la fin, le stade affichage, avec l'option effet post-traitement :
Deferred rendering is not able to display transparency. For the moment, clouds are renderer separately and should be lit and shaded by their own. Transparent surfaces are alpha-tested and not blended. They would have to be drawn in their own bin over the composited image.
:Les résultats des précédents tampons sont poussés dans le tampon principal pour être affichés, optionnellement modifiés pour montrer Glow, Motion blur, HDR, redout ou blackout, occlusion ambiante de l'espace écran, anti-aliasing, etc...


It also don't fit with depth partitioning because the depth buffer should be kept to retain the view space position, so for the moment, z-fighting is quite visible. Depth partitioning with non overlapping depth range might be the solution and should be experimented at one point.
Dans FG, on termine le pipeline du rendu par l'affichage du [[Menubar|GUI]] et du [[HUD]].


The glow pass can make certain MFD (that use emissive color) unreadable because blurred. Should be treated as transparent.
Tous ces phases sont plus précisément décrites dans [http://bat710.univ-lyon1.fr/~jciehl/Public/educ/GAMA/2007/Deferred_Shading_Tutorial_SBGAMES2005.pdf tutorial] c'est la base du code actuel, avec quelque addition ou modifications.


== Implementation ==
== Avertissements ==
=== Repositories ===
Le rendu différé n'affiche pas la transparence. Pour le moment, les nuages doivent être éclairés et ombrés par eux-mêmes. Les surfaces transparentes sont alpha-testées et non mélangées. Elles doivent être amenées dans leur propre bin sur l'image composite.
The code is in the main branch of the [[FlightGear and Git|official repository]]. Any other location is not maintained anymore.


=== Rendering of transparent surfaces ===
La partition profondeur ne marche pas non plus, à cause de la mémoire tampon profondeur, qui doit être gardée pour retenir la position de zone de vue, et, pour le moment, z-fighting est tout à fait visible. La partition profondeur sans rangée de profondeur superposée pourrait être la solution, et devrait être essayée.
[[Image:project_rembrandt_5.png|thumb|300px|Transparent surfaces drawn after opaque objects]]
 
Transparent surfaces are detected by OSG loader plugins and their state set receive the TRANSPARENT_BIN rendering hint. In the culling pass, the cull visitor orders transparent surfaces in transparent bin. In a cull callback attached to the Geometry camera, after the scenegraph traversal, the transparent bins are removed from the render stage and saved in a temporary collection. In a cull callback attached to the Lighting camera, after the scenegraph traversal, the transparent bins saved at the previous stage, are added to the render stage of the Lighting camera with a high order num. That way, the transparent surface are drawn on top of the scene lighted from the Gbuffer.
Le passage de la lumière peut rendre certains MFD illisibles (ce qui utilisent une couleur émissive) car flous. Ils devront être traités comme transparents.
 
 
== Mise en œuvre ==
=== Répertoires ===
Le code est la principale branche du [[FlightGear and Git|répertoire officiel]]. Aucune autre localisation n'existe.
 
=== Rendu des surfaces transparentes ===
[[Image:project_rembrandt_5.png|thumb|300px|Surfaces transparentes desssinées d'après des objets opaques]]
Les surfaces transparentes sont détectées par les plugins OSG loader qui captent la nuance de rendu TRANSPARENT_BIN
In the culling pass, the cull visitor orders transparent surfaces in transparent bin. In a cull callback attached to the Geometry camera, after the scenegraph traversal, the transparent bins are removed from the render stage and saved in a temporary collection. In a cull callback attached to the Lighting camera, after the scenegraph traversal, the transparent bins saved at the previous stage, are added to the render stage of the Lighting camera with a high order num. That way, the transparent surface are drawn on top of the scene lighted from the Gbuffer.


=== Memory consumption ===
=== Memory consumption ===
88

edits