private void MeshDepthFromLight(object @object, int x, int y, float z) { if (x < RenderWidth && y < RenderHeight) { if (z.ApproxLessThan(ShadowMap.Values[x][y], 1E-4f)) { ShadowMap.Values[x][y] = z; } } }
// Check if point is visible from the camera private void ZBufferCheck(object colour, int x, int y, float z) { try { if (z.ApproxLessThan(zBuffer.Values[x][y], 1E-4f)) { zBuffer.Values[x][y] = z; colourBuffer.Values[x][y] = (Color)colour; } } catch (IndexOutOfRangeException e) { throw new IndexOutOfRangeException($"Attempted to render outside the canvas at ({x}, {y}, {z})", e); } }
private void TexturedCheckAgainstZBuffer(Bitmap texture, int x, int y, float z, int tx, int ty) { try { if (z.ApproxLessThan(zBuffer.Values[x][y], 1E-4f)) { zBuffer.Values[x][y] = z; colourBuffer.Values[x][y] = texture.GetPixel(tx, ty * -1 + texture.Height - 1); } } catch (IndexOutOfRangeException e) { throw new IndexOutOfRangeException($"Attempted to render outside the canvas at ({x}, {y}, {z})", e); } }