code: def test_rasterize_preset(self):
      model_to_eye_matrix = (
          rasterization_test_utils.make_look_at_matrix(
              look_at_point=(0.0, 0.0, 1.0)
          )
      )
      perspective_matrix = (
          rasterization_test_utils.make_perspective_matrix(
              _IMAGE_WIDTH, _IMAGE_HEIGHT
          )
      )
      view_projection_matrix = tf.linalg.matmul(
          perspective_matrix, model_to_eye_matrix
      )
      view_projection_matrix = tf.expand_dims(
          view_projection_matrix, axis=0
      )
  
      depth = 1.0
      vertices = np.array(
          [
              [
                  (-2.0 * _TRIANGLE_SIZE, 0.0, depth),
                  (0.0, _TRIANGLE_SIZE, depth),
                  (0.0, 0.0, depth),
                  (0.0, -_TRIANGLE_SIZE, depth),
              ]
          ],
          dtype=np.float32,
      )
      triangles = np.array(((1, 2, 0), (0, 2, 3)), np.int32)
  
      predicted_fb = _proxy_rasterize(
          vertices, triangles, view_projection_matrix
      )
  
      with self.subTest(name="triangle_index"):
          groundtruth_triangle_index = np.zeros(
              (1, _IMAGE_HEIGHT, _IMAGE_WIDTH, 1), dtype=np.int32
          )
          groundtruth_triangle_index[..., : _IMAGE_WIDTH // 2, 0] = 0
          groundtruth_triangle_index[
              ..., : _IMAGE_HEIGHT // 2, _IMAGE_WIDTH // 2 :, 0
          ] = 1
          self.assertAllEqual(
              groundtruth_triangle_index, predicted_fb.triangle_id
          )
  
      with self.subTest(name="mask"):
          groundtruth_mask = np.ones(
              (1, _IMAGE_HEIGHT, _IMAGE_WIDTH, 1), dtype=np.int32
          )
          groundtruth_mask[..., : _IMAGE_WIDTH // 2, 0] = 0
          self.assertAllEqual(
              groundtruth_mask, predicted_fb.foreground_mask
          )
  
      attributes = np.array(
          ((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0))
      ).astype(np.float32)
      perspective_correct_interpolation = lambda geometry, pixels: glm.perspective_correct_interpolation(  # pylint: disable=g-long-lambda,line-too-long
          geometry,
          attributes,
          pixels,
          model_to_eye_matrix,
          perspective_matrix,
          np.array((_IMAGE_WIDTH, _IMAGE_HEIGHT)).astype(np.float32),
          np.array((0.0, 0.0)).astype(np.float32),
      )
      with self.subTest(name="barycentric_coordinates_triangle_0"):
          geometry_0 = tf.gather(vertices, triangles[0, :], axis=1)
          pixels_0 = tf.transpose(
              a=grid.generate((3.5, 2.5), (6.5, 4.5), (4, 3)),
              perm=(1, 0, 2),
          )
          barycentrics_gt_0 = perspective_correct_interpolation(
              geometry_0, pixels_0
          )
          self.assertAllClose(
              barycentrics_gt_0,
              predicted_fb.barycentrics.value[0, 2:, 3:, :],
              atol=1e-3,
          )
  
      with self.subTest(name="barycentric_coordinates_triangle_1"):
          geometry_1 = tf.gather(vertices, triangles[1, :], axis=1)
          pixels_1 = tf.transpose(
              a=grid.generate((3.5, 0.5), (6.5, 1.5), (4, 2)),
              perm=(1, 0, 2),
          )
          barycentrics_gt_1 = perspective_correct_interpolation(
              geometry_1, pixels_1
          )
          self.assertAllClose(
              barycentrics_gt_1,
              predicted_fb.barycentrics.value[0, 0:2, 3:, :],
              atol=1e-3,
          )
  
file_path: graphics/tensorflow_graphics/rendering/opengl/tests/rasterization_backend_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_graphics.geometry.representation import grid
  from tensorflow_graphics.rendering.opengl import math
  from tensorflow_graphics.rendering.opengl import rasterization_backend
  from tensorflow_graphics.rendering.tests import rasterization_test_utils
  from tensorflow_graphics.util import test_case
label_desc: Use image node_id 5 for calling the RasterizationBackendTest obj's underlying member method code with example usage: obj.test_rasterize_preset() without return types