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

How to culling in postprocess?

Discussion in 'General Graphics' started by liuyu, Jan 2, 2015.

  1. liuyu

    liuyu

    Joined:
    Oct 14, 2014
    Posts:
    28
    Hi,

    I want to use "Graphics.DrawMeshNow" to draw some object in my postprocess:
    Code (CSharp):
    1. public class PP_Light_Point : MonoBehaviour
    2. {
    3. ......
    4. void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture)
    5. {
    6.         Camera curCamera = GetComponent<Camera> ();
    7.         UnityEngine.Object[] _Lights = FindObjectsOfType (typeof(Light));
    8.         foreach (UnityEngine.Object obj in _Lights)
    9.         {
    10.               Light lit = obj as Light;
    11.  
    12.               // There need to cull the light is need to DrawMeshNow.
    13.  
    14.               _LightPointMatrial.SetPass(0);
    15.               Matrix4x4 kWorldMat = lit.transform.localToWorldMatrix;
    16.               Graphics.DrawMeshNow(lp.mesh, kWorldMat);
    17.         }
    18. }
    19. ......
    20. }
    Some lights are out of camera, they need not to draw. So I want to cull the light.
    How to do it? Thank you.
     
  2. Dolkar

    Dolkar

    Joined:
    Jun 8, 2013
    Posts:
    576
  3. liuyu

    liuyu

    Joined:
    Oct 14, 2014
    Posts:
    28
    It's ok,
    Thank you very much. :)