Search Unity

Setting custom culling planes doesnt seem to work

Discussion in 'High Definition Render Pipeline' started by customphase, Dec 17, 2019.

  1. customphase

    customphase

    Joined:
    Aug 19, 2012
    Posts:
    246
    Ive embedded HDRP into my project and im modifying the HDRenderPipeline code directly. The following code should, in theory, cull everything on the scene (or most of it at least, all the planes are intersecting at the same point with normals pointing towards the center) for a specific probe. The code is executed properly, ive checked, but in reality it doesnt do anything, everything is still being rendered. Am i missing something about culling in SRP/HDRP? I even tried setting frustumPlaneEquations in HDCamera, it doesnt seem to do anything either.

    (Unity 2019.1.14, HDRP 5.16.1)

    Code (CSharp):
    1. if (TryCalculateFrameParameters(
    2.         customPlanarReflectionCamera,
    3.         out _,
    4.         out var hdCamera,
    5.         out var cullingParameters
    6.     ))
    7. {
    8.     Plane[] planes = new Plane[6];
    9.     planes[0] = new Plane(visibleProbe.transform.right, visibleProbe.transform.position);
    10.     planes[1] = new Plane(-visibleProbe.transform.right, visibleProbe.transform.position);
    11.  
    12.     planes[2] = new Plane(visibleProbe.transform.up, visibleProbe.transform.position);
    13.     planes[3] = new Plane(-visibleProbe.transform.up, visibleProbe.transform.position);
    14.  
    15.     planes[4] = new Plane(visibleProbe.transform.forward, visibleProbe.transform.position);
    16.     planes[5] = new Plane(-visibleProbe.transform.forward, visibleProbe.transform.position);
    17.  
    18.     for (int n = 0; n<6; n++)
    19.     {
    20.         cullingParameters.SetCullingPlane(n, planes[n]);
    21.         hdCamera.frustumPlaneEquations[n] = new Vector4(
    22.             planes[n].normal.x,
    23.             planes[n].normal.y,
    24.             planes[n].normal.z,
    25.             planes[n].distance
    26.         );
    27.     }
    28.  
    29.     if (TryCull(
    30.         customPlanarReflectionCamera, hdCamera, renderContext, cullingParameters,
    31.         ref _cullingResults
    32.     ))
    33.     {
    34.         skipRequest = false;
    35.     }
    36. }
    37.  
     
    Last edited: Dec 17, 2019