From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

Ptex Design

Work in progress!

Details the changes I've been working on to integrate Ptex into Blender. This work was started as part of GSOC2010 within the soc-2010-nicolasbishop SVN branch, but more recently I have continued development as a patch against trunk. The new patch will have only Ptex changes, the other changes from soc-2010-nicolasbishop such as paint masks are not part of this project.

Ptex library

The Ptex library is currently used for loading and saving Ptex files; in the future it will probably be needed for integration in the internal renderer as well.

Licensing note: the Ptex license is BSD-new, which is GPL-compatible.

I have imported Ptex into the extern/ directory. Since the library is C++, I've also added a small C wrapper which attempts to mirror the Ptex API very closely. (I've only wrapped the parts of the library currently in use, but it should be very quick to extend if we need additional functionality.) The header and source files are extern/ptex/ptex.h and extern/ptex/ptex_C_api.c.

DNA

Ptex data is stored primarily as CustomData, but has some limited integration into textures as well.

Brush

The only change needed for brushes is to add a field for the current Ptex paint tool (same as for all the other paint modes.)

CustomData

Added a new CustomData type, CD_MPTEX.

Mesh

Added a field to store the active subface, similar to the active face.

MeshData

typedef struct MPtexSubface {
	void *data;
	/* resolution in U and V directions, always a power of two */
	int res[2];
	int flag, pad;
} MPtexSubface;

typedef struct MPtex {
	struct MPtexSubface subfaces[4];
	/* equal to face's number of vertices */
	int totsubface;
	/* enum PtexDataType */
	char type;
	char channels;
	char pad[2];
} MPtex;

Texture

Added a new field to store the name of a Ptex layer, and added a new texture type, TEX_PTEX.

Patch

Again, work in progress!

http://www.pasteall.org/19244/diff