Thursday, November 22, 2012

Particle Generation Methodology

So here are the steps I'm going through to create particles (splats) for my nebula.

1. Generator.cpp: Takes in an OBJ file (or 2 or 3) of a mesh, creates a bounding box, and voxelizes it to create particle positions.  The positions are jittered and then written out to a text file.

2. SubDivSet.cpp: Takes an initial set of positions and subdivides it using a max amount per file.  For example, given a 4.8M set, with a 500K limit, we'd get 9 text files with 500K positions and 1 file with the remaining 300K.  I'm doing this to break up the culling operation, which can get a little slow with larger data sets.

NOTE- May have an issue here... In recombining the sets, I'm getting overlapping sections.  Need to look into this.

3. ParticleCuller.py: Runs through mayapy in the terminal.  Uses a pre-set up file to compare the position sets to the initial mesh.  Discards positions that are too far away, and does a texture lookup for the others to assign RGB and opacity.  500K sets take 10-20 minutes to run, depending on how many positions work (the more we get, the more texture lookups are needed, the slower the code runs).  Saves a new maya file, which we can write out a PDA file from using this MEL command:

dynExport -mnf 1 -mxf 1 -os 2 -atr position -atr rgbPP -atr opacityPP -p "pda" -f "pda" particle1; 

NOTEThe texture lookup in the particleculler.py script fails about 6% of the time.  As of right now, I'm isolating the failed (black) particles and pushing them through the particleCuller again.  When run through the script editor, this seems to succeed for every particle.  (See my post on 12/2/2012). 

3B. Find_Black.cpp: Loops through culled particles looking for RGB values all equal to zero.  Separates the initial set into 2, so that the failed particles can be re-run through the culling script.  Both of these files can be combined using combinePDA.cpp.

4. CombinePDA.cpp: For each of the PDA files, combine them together into a single data set.  In this case, I combine each attribute into single files- so all of the rgbPP data goes into one, all of the positions into another, etc.  From here, the data could go into the C render code, or be converted into a PDC for lookdev work in Maya.

5. PDCWriterS106.cpp: Translates each attribute into a single PDC file which can be read into Maya for look dev testing.

No comments:

Post a Comment