Search Unity

Are there any ways to compute deferred shading's g-buffers in C# script?

Discussion in 'Global Illumination' started by Cliff-Lee, Jul 21, 2017.

  1. Cliff-Lee

    Cliff-Lee

    Joined:
    Apr 18, 2016
    Posts:
    7
    Hello everyone:
    I am trying to compute some points' GI, but the points(sampled from the whole scene) are not in the camera's view.
    I can use many cameras across the scene to retrieve the GI of those sample points, but it's not efficient and not extendable for new scenes.
    So, I think maybe I can use deferred shading to help me with the problem.

    In my thought, if I can compute the deferred shading's g-buffers in C# script with the correct attribute of sample points, maybe I can use Unity compute the deferred shading with my custom g-buffers.
    Then I can get Unity's GI with the deferred shading result.

    I use the standard shader and precomputed GI for my system.
    There are some default g-buffers according to the manual of deferred shading.
    https://docs.unity3d.com/510/Documentation/Manual/RenderTech-DeferredShading.html
    • RT0, ARGB32 format: Diffuse color (RGB), unused (A).
    • RT1, ARGB32 format: Specular color (RGB), roughness (A).
    • RT2, ARGB2101010 format: World space normal (RGB), unused (A).
    • RT3, ARGB32 (non-HDR) or ARGBHalf (HDR) format: Emission + lighting + lightmaps + reflection probes buffer.
    I think I can set RT0, RT1 and RT2 with models' and materials' information, but I can't find the information about how to compute or retrieve the information of RT3.

    So I have three problems:
    1. Is my thought of the deferred shading achievable? (Use custom g-buffers to compute the sample points that are not in the camera's view.)

    2. How to compute or retrieve the information of RT3?

    3. How to replace the origin g-buffers with custom g-buffers in C# script?

    Thanks for helping!