Exemplo n.º 1
0
    def testColorSums(self):
        """Check that subdivision depth doesn't change the total amount of light."""

        image = IECore.Reader.create(
            "test/IECoreImage/data/exr/carPark.exr").read()
        for n in ["R", "G", "B"]:
            p = image[n]
            p.data = IECore.DataCastOp()(
                object=image[n],
                targetType=IECore.FloatVectorData.staticTypeId())
            image[n] = p

        lastColorSum = None
        for i in range(0, 10):

            lights = IECoreImage.EnvMapSampler()(image=image,
                                                 subdivisionDepth=i)
            colorSum = sum(lights["colors"], imath.Color3f(0))

            if lastColorSum:
                self.assertAlmostEqual(colorSum[0], lastColorSum[0], 5)
                self.assertAlmostEqual(colorSum[1], lastColorSum[1], 5)
                self.assertAlmostEqual(colorSum[2], lastColorSum[2], 5)

            lastColorSum = colorSum
Exemplo n.º 2
0
    def test(self):

        image = IECore.Reader.create(
            "test/IECoreImage/data/exr/carPark.exr").read()
        for n in ["R", "G", "B"]:
            p = image[n]
            p.data = IECore.DataCastOp()(
                object=image[n],
                targetType=IECore.FloatVectorData.staticTypeId())
            image[n] = p

        lights = IECoreImage.EnvMapSampler()(image=image, subdivisionDepth=5)

        self.assertEqual(len(lights), 2)

        directions = lights["directions"]
        colors = lights["colors"]

        self.assert_(
            directions.isInstanceOf(IECore.V3fVectorData.staticTypeId()))
        self.assert_(
            colors.isInstanceOf(IECore.Color3fVectorData.staticTypeId()))

        self.assertEqual(len(directions), len(colors))
        self.assertEqual(len(directions), 32)

        for d in directions:

            self.assertAlmostEqual(d.length(), 1, 6)