Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Writing custom OpenGL to the depth buffer *before* Unity rendering

Discussion in 'General Graphics' started by vngthowhing, Apr 7, 2015.

  1. vngthowhing

    vngthowhing

    Joined:
    Jan 28, 2015
    Posts:
    3
    Hi,
    I know there is an existing mechanism for writing custom openGL plugins and rendering after all Unity rendering has been completed. However, I would like to render custom depth buffer data from a memory buffer *before* Unity rendering to be used during Unity's depth buffer test. For example, I may have a very specialized occlusion mask that I procedurally create and would like to put this in the depth buffer before regular Unity rendering. Is this possible?

    Victor
     
  2. AlexBM

    AlexBM

    Joined:
    Mar 26, 2015
    Posts:
    16
    So you want to fill depth buffer with some custom pattern? It's not possible directly even in OpenGL afaik. You need to render mesh with suitable shape that represents your mask before all other objects (or, before objects you want to respect your depth effect) with Colormask set to 0, and ZWrite set to On.