Create .ptx directly from image collection?

36 views
Skip to first unread message

Trent Schindler

unread,
Sep 8, 2014, 4:47:22 PM9/8/14
to pt...@googlegroups.com
Hi --

I'm exploring the use of ptex for large textures that stich together datasets such as e.g. satellite imagery. However, the examples that I have found all use a 3-D painting program to create a texture that is baked out to arrive at a final .ptx, which is not how I would be working.  I'd like to write a ptex file directly by assuming (for a start, anyway) a spherical geometry of a fixed number of faces, and locating the indices and adjacency information of each face texture based on the lat/lon information embedded in a series of geotiff files.  Are there any examples available that demonstrate a similar "stitching" type of workflow using the API?  Does such a thing even make sense, or am I misunderstanding ptex? I'd appreciate any guidance!

Thanks!

Brent Burley

unread,
Sep 8, 2014, 8:39:11 PM9/8/14
to pt...@googlegroups.com
It's pretty trivial to read a bunch of image files and write them into a ptex file with adjacency data.  We do a similar (though simpler) thing with cube maps where we combine 6 image files into a ptex environment map:

    // build face info
    int adjfaces[6][4] = {
        { 3, 5, 2, 4 }, // px
        { 3, 4, 2, 5 }, // nx
        { 4, 0, 5, 1 }, // py
        { 5, 0, 4, 1 }, // ny
        { 3, 0, 2, 1 }, // pz
        { 3, 1, 2, 0 }  // nz
    };
    int adjedges[6][4] = {
        { 1, 3, 1, 1 }, // px
        { 3, 3, 3, 1 }, // nx
        { 2, 2, 2, 2 }, // py
        { 0, 0, 0, 0 }, // ny
        { 2, 3, 0, 1 }, // pz
        { 0, 3, 2, 1 }  // nz
    };
    Ptex::FaceInfo fi[6];
    for (int i = 0; i < 6; i++) {
        int w = images[i].w, h = images[i].h;
        Ptex::Res res(PtexUtils::floor_log2(w), PtexUtils::floor_log2(h));
        fi[i] = Ptex::FaceInfo(res, adjfaces[i], adjedges[i]);
    }

    std::string error;
    PtexWriter* w = PtexWriter::open(opt.dst.c_str(), Ptex::mt_quad, dt, nchan, achan,
                                     6, error);
    if (!w) {
        std::cerr << error << std::endl;
        return 0;
    }
    for (int i = 0; i < 6; i++) {
        w->writeFace(i, fi[i], images[i].data);
    }
    bool ok = w->close(error);
    if (!ok) std::cerr << error << "\n";
    w->release();

Does that help?

--

---
You received this message because you are subscribed to the Google Groups "ptex" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ptex+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Trent Schindler

unread,
Sep 9, 2014, 10:38:53 AM9/9/14
to pt...@googlegroups.com
I think this might be the kind of thing I'm looking for -- thanks!  I'll give it a shot.

Cheers
Reply all
Reply to author
Forward
0 new messages