paramlist,
        dataset.BSDFAt(iteration=bi, superiteration=options.superiteration))

    for k in range(dataset.testSet().numLights()):
        print "Iteration ", i, "/", testset.numIterations(
        ), ", Light ", k, "/", dataset.testSet().numLights(), "\r",
        sys.stdout.flush()

        testset.renderables[k].setEmbeddedParameter("sampleCount",
                                                    options.directSamples)
        testset.renderables[k].setParameter("blockSize", 8)
        copyfile(meshfile,
                 "/tmp/mts_mesh_intensity_slot_" + format(k) + ".ply")
        merl_io.merl_write(
            "/tmp/tabular-bsdf-" + format(k) + ".binary",
            dataset.tabularBSDFAt(iteration=bi,
                                  superiteration=options.superiteration))

        testset.renderables[k].setEmbeddedParameter("depth", 2)
        testset.renderables[k].setEmbeddedParameter("meshSlot", k)
        de = dataset.errorAtN(lindex=k,
                              iteration=i,
                              superiteration=options.superiteration)

        #testset.renderables[k].setEmbeddedParameter("width", de.shape[0])
        #testset.renderables[k].setEmbeddedParameter("height", de.shape[1])

        directIntensity = testset.renderables[k].renderReadback(
            readmode="hds",
            distribution=options.distribution,
            output="/tmp/indirects-" + format(k) + ".hds",
            localThreads=2,
Exemple #2
0
renderable = testset.renderables[0]
renderable.setEmbeddedParameter("meshSlot", 0)

if not options.sourceMesh:
    renderable.setFile(sphereXMLP)

renderable.setEmbeddedParameter("width", options.resolution)
renderable.setEmbeddedParameter("height", options.resolution)

Es = []
baseDir = directory + "/merl-compare/"

if not os.path.exists(baseDir):
    os.mkdir(baseDir)

if dataset.tabularBSDFAt(iteration=options.iteration) is None:
    print "Couldn't find tabular BSDF at i=", options.iteration
    sys.exit(1)

for envmap in envmaps:
    renderable.setEmbeddedParameter("envmap", envmap + ".exr")

    merl_io.merl_write("/tmp/tabular-bsdf-0.binary", dataset.tabularBSDFAt(iteration=options.iteration))

    print "Rendering ", envmap, " - ", " Optimized"
    sphereImage = renderable.renderReadback(
        readmode="hds",
        distribution=options.distribution,
        output="/tmp/sphere-bsdf-testing.hds",
        embedded={"sampleCount": options.sampleCount},
        localThreads=2,
        testset.gradientRenderables[k].setEmbeddedParameter("sampleCount", options.samples)
        testset.gradientRenderables[k].setParameter("blockSize", 8)
        testset.renderables[k].setEmbeddedParameter("sampleCount", options.samples)
        testset.renderables[k].setParameter("blockSize", 8)
        copyfile(meshfile,
                            "/tmp/mts_mesh_gradient_slot_" + format(k) + ".ply")
        copyfile(meshfile,
                            "/tmp/mts_mesh_intensity_slot_" + format(k) + ".ply")
        testset.gradientRenderables[k].setEmbeddedParameter("depth", 2)
        testset.gradientRenderables[k].setEmbeddedParameter("meshSlot", k)
        testset.renderables[k].setEmbeddedParameter("depth", 2)
        testset.renderables[k].setEmbeddedParameter("meshSlot", k)

        os.system("rm /tmp/tabular-bsdf-" + format(k) + ".binary")
        merl_io.merl_write("/tmp/tabular-bsdf-" + format(k) + ".binary", dataset.tabularBSDFAt(iteration=bi, superiteration=options.superiteration))

        de = dataset.errorAtN(lindex=k, iteration=i, superiteration=options.superiteration)
        width = de.shape[0]
        height = de.shape[1]
        testset.gradientRenderables[k].setEmbeddedParameter("width", width)
        testset.gradientRenderables[k].setEmbeddedParameter("height", height)

        #plt.imshow(de)
        #plt.show()
        hdsutils.writeHDSImage("/tmp/reductor-" + format(k) + ".hds", de.shape[0], de.shape[1], 1, de[:,:,np.newaxis])

        normalGradients, bsdfGradients = testset.gradientRenderables[k].renderReadback(
            readmode="shds",
            distribution=options.distribution,
            output="/tmp/single-bounce-gradients-" + format(k) + ".shds",
        readmode="hds",
        distribution=options.distribution,
        output="/tmp/sphere-bsdf-testing.hds",
        embedded={"sampleCount": options.sampleCount},
        localThreads=2,
        quiet=True)

    np.save(baseDir + "/target-" + envmap + ".npy", sphereImageTarget)

    targets.append(sphereImageTarget)

for i in range(-1, testset.numBSDFIterations(), options.skip):
    if options.iteration != None and options.iteration != i:
        continue

    if dataset.tabularBSDFAt(iteration=i) is None and i != -1:
        continue

    if i != -1:
        print("Rendering iteration " + format(i) + "...")
    else:
        print("Rendering initialization")

    error = 0.0
    for eidx, envmap in enumerate(envmaps):
        renderable.setEmbeddedParameter("envmap", envmap + ".exr")

        if i != -1:
            merl_io.merl_write("/tmp/tabular-bsdf-0.binary", dataset.tabularBSDFAt(iteration=i))
        else:
            merl_io.merl_write("/tmp/tabular-bsdf-0.binary", testset.initialTabularBSDF())