Skip to main content

TriangleVisibilityUtility.RenderingHandler

A private class in Root.Township, the global namespace. Reach it through att-stubs' publicized assemblies or Harmony's AccessTools.

GPU check for whether one triangle of a mesh can be seen from a point: renders the mesh black and the triangle white, shrinks the image to one pixel and reads it. Used by CalculateOccludedTriangles when baking.

Constructors​

MemberWhat it is
RenderingHandler(int renderResolution, float distance, Mesh sourceMesh, Mesh triangleMesh)Creates a TriangleVisibilityUtility.RenderingHandler from renderResolution, distance, sourceMesh and triangleMesh.

Fields​

11 private and internal fields
MemberWhat it is
private Material bgMaterialBlack material for the whole mesh.
private CommandBuffer commandBufferCommand buffer used for each render.
private Material downscaleMaterialMaterial for the Hidden/ColorTestDownscale shader.
private List<RenderTexture> downscalingRTsRender textures for each halving step, down to 1 by 1.
private Texture2D extraction1 by 1 texture the final pixel is read into.
private Matrix4x4 projectionMatrixOrthographic projection sized to the mesh.
private RenderTexture renderTextureFull resolution render target.
private Mesh sourceMeshThe mesh being tested.
private Material testMaterialWhite material for the test triangle, slightly offset so it wins depth ties.
private Mesh triangleMeshOne-triangle mesh holding the triangle being tested.
private Matrix4x4 viewMatrixFixed view matrix; the mesh is moved instead of the camera.

Methods​

MemberWhat it is
bool CheckVisibility(float distance, Vector3 center, Vector3 normalDirection)Renders from a point (or a distance out along the normal) looking back, and returns whether the triangle shows.
bool CheckVisibility(Vector3 position, Vector3 normalDirection)Renders from a point (or a distance out along the normal) looking back, and returns whether the triangle shows.
void Dispose()Destroys the materials and textures and releases the render textures and command buffer.
3 private and internal methods
MemberWhat it is
private void DownScale()Halves the render repeatedly down to 1 by 1 pixel with the downscale shader.
private bool IsVisible()Reads the final pixel; true if its red is over 0.5.
private void RenderIntoRenderTexture(Vector3 position, Vector3 lookAt)Draws the whole mesh in black and the test triangle in white from the given view.

Used in​

Members of other types that take, return or hold a RenderingHandler: