ProFX2 integration


In this page, you will find detailled instructions for using ProFX in your application. You'll find also a basic example application in "sample/ProFX2_sample_01.cpp", which loads and renders a set of textures, and then saves them in Direct3D .dds files.

Requirements


Clic here to open hardware requirements and supported platforms.

Setting up your project


On PC

Your application needs to be linked against "lib/win32/ProFX2_0_MD_Eval.lib" ("ProFX2_0_MD.lib" in the release version of the kit).

On XBOX360

Your application needs to be linked against "lib/Xenon/ProFX2_0_Xenon_Eval.lib" ("ProFX2_0_Xenon.lib" in the release version of the kit).
You need also to define the environment variable XBOX in your project settings.

Including the ProFX header


The ProFX2.h header needs to be included in all files where ProFX functions are called.

Setting up Direct3D for ProFX


Creating the Direct3D device

The D3DPRESENT_PARAMETERS structure used to create the Direct3D device is not used directly in ProFX2. It has no effect on texture generation.

Render and sampler states

You need to set the following render and samplers set before calling the ProFX2 render() function.

On PC:

Render states:
D3DRS_SRGBWRITEENABLE 0
D3DRS_SEPARATEALPHABLENDENABLE FALSE
D3DRS_STENCILENABLE FALSE
D3DRS_SCISSORTESTENABLE FALSE
D3DRS_ZFUNC D3DCMP_LESS
D3DRS_ZWRITEENABLE TRUE
D3DRS_SHADEMODE D3DSHADE_GOURAUD
D3DRS_FOGENABLE FALSE
D3DRS_SPECULARENABLE FALSE
D3DRS_FOGTABLEMODE D3DFOG_NONE

Sampler states for the first four samplers:
D3DSAMP_SRGBTEXTURE 0
D3DSAMP_ELEMENTINDEX 0

The DepthStencilSurface must be set to NULL.

On XBOX360:

Render states:
D3DRS_SEPARATEALPHABLENDENABLE FALSE
D3DRS_STENCILENABLE FALSE
D3DRS_SCISSORTESTENABLE FALSE
D3DRS_ZFUNC D3DCMP_LESS
D3DRS_ZWRITEENABLE TRUE
D3DRS_HALFPIXELOFFSET TRUE

Sampler states for the first four samplers:
D3DSAMP_MAXANISOTROPY 1
D3DSAMP_ADDRESSW D3DTADDRESS_WRAP

Also, on XBOX360, the RenderTarget 0 and DepthStencilSurface must be set to NULL.

NB: Render states, texture sampler states, render target and depth buffer surface are not restored to their initial values.

Initializing ProFX


First, you need to create a ProFX2Parameters structure containing the parameters for ProFX. As of today, this structure only needs to contain a pointer to the Direct3D device. Using this structure, you can then create a ProFX2Handle object that will be used to access all ProFX functions.

Loading the textures file


ProFX procedural texture files (.pfx), are loaded using the "load" member function of the ProFX2Handle class, which takes as parameter an input ASCII stream opened on the required .pfx file.

Rendering and getting back the textures


To each texture in the set (ie an output node of the graph in the MaPZone editor) corresponds an (integer) output index and an (ASCII) output name, which can be obtained using the getOutputIndexFromName and getOutputNameFromIndex functions respectively. To list the output names contained in a texture set, use the .PFX viewer ("PFXviewer.exe") provided with ProFX.

Calling the render() function launches the rendering of all enabled textures in the set (textures can be individually disabled using the switchOutput()
function, and are all enabled by default). When completed, all rendered textures can be accessed using the grabResult function. The resulting texture format (raw or DXT-compressed, number of mipmap levels, etc.) can be set in the MaPZone editor.

In order to be informed of the progress of the rendering process, one can make the ProgressCallbackFunc function pointer point to a user defined progress callback. However, if you perform any Direct3D operation in this callback (e.g. updating a progress bar) please remember that you need to restore the Direct3D state as it was set in section 3/ before exiting this callback (as well as the RenderTarget on XBox360).

Exiting


The releaseRessources() function releases all texture memory and all D3D objects that were set up for the rendering. It is called automaticaly at the ProFX2 handle destruction time.


Clic-here to open Doxygen documentation.

Categories
CategoryProgramming

There are no comments on this page. [Add comment]

Page was generated in 0.2031 seconds