Exemplo n.º 1
0
 def estimate_radiance_fn(point_light_position, surface_point_position,
                          surface_point_normal, observation_point):
     return point_light.estimate_radiance(point_light_radiance_init,
                                          point_light_position,
                                          surface_point_position,
                                          surface_point_normal,
                                          observation_point, fake_brdf)
Exemplo n.º 2
0
  def test_estimate_radiance_value_exceptions_raised(self):
    """Tests that the value exceptions are raised correctly."""
    point_light_radiance = random_tensor(tensor_shape=(1, 1))
    point_light_position = random_tensor(tensor_shape=(1, 3))
    surface_point_position = random_tensor(tensor_shape=(3,))
    surface_point_normal = random_tensor(tensor_shape=(3,))
    observation_point = random_tensor(tensor_shape=(3,))

    # Verify that an InvalidArgumentError is raised as the given
    # surface_point_normal is not normalized.
    with self.assertRaises(tf.errors.InvalidArgumentError):
      self.evaluate(
          point_light.estimate_radiance(point_light_radiance,
                                        point_light_position,
                                        surface_point_position,
                                        surface_point_normal, observation_point,
                                        returning_zeros_brdf))
Exemplo n.º 3
0
    def test_estimate_radiance_preset(self,
                                      light_radiance,
                                      light_pos,
                                      observation_pos,
                                      expected_result,
                                      reflected_light_fall_off=False):
        """Tests the output of estimate radiance function with various parameters.

    In this test the point on the surface is always [0, 0, 0] ,the surface
    normal is [0, 0, 1] and the fake brdf function returns the (normalized)
    direction of the outgoing light as its output.

    Args:
     light_radiance: An array of size K representing the point light radiances.
     light_pos: An array of size [3,] representing the point light positions.
     observation_pos: An array of size [3,] representing the observation point.
     expected_result: An array of size [3,] representing the expected result of
       the estimated reflected radiance function.
     reflected_light_fall_off: A boolean specifying whether or not to include
       the fall off of the reflected light in the calculation. Defaults to
       False.
    """
        tensor_size = np.random.randint(3) + 1
        tensor_shape = np.random.randint(1, 10, size=(tensor_size)).tolist()
        lights_tensor_size = np.random.randint(3) + 1
        lights_tensor_shape = np.random.randint(
            1, 10, size=(lights_tensor_size)).tolist()
        point_light_radiance = np.tile(light_radiance,
                                       lights_tensor_shape + [1])
        point_light_position = np.tile(light_pos, lights_tensor_shape + [1])
        surface_point_normal = np.tile([0.0, 0.0, 1.0], tensor_shape + [1])
        surface_point_position = np.tile([0.0, 0.0, 0.0], tensor_shape + [1])
        observation_point = np.tile(observation_pos, tensor_shape + [1])
        expected = np.tile(expected_result,
                           tensor_shape + lights_tensor_shape + [1])

        pred = point_light.estimate_radiance(
            point_light_radiance,
            point_light_position,
            surface_point_position,
            surface_point_normal,
            observation_point,
            fake_brdf,
            reflected_light_fall_off=reflected_light_fall_off)

        self.assertAllClose(expected, pred)