Particle Replacement of Geometry Script
Theremina, added 2006-11-28 23:01:07 UTC 37,060 views  Rating:
(4 ratings)
Page 1 of 1

Particle Replacement of Geometry Script
a script designed to implement NPR techniques in Maya

The Idea
The original idea came from looking at Barbara Meier's Painterly Rendered techniques and her Haystack images. Her technique was to use particles to represent the geometry and each particle had its own brush stroke applied.

Barbara Meier's Haystacks

In working in Maya I first attempted to see what existing options there were for creating such a look. My first attempts were working with Soft Bodies as they create a particle at each CV or Vertex of the geometry used to create the Soft Body. This seemed to be a reasonable equation to approach this, as most model's could still be read if CV and Vertex geometry was the only thing shown. The down sides of working with Soft Bodies in Maya is that it first creates this Soft Body as a child of the geometry so there has to be certain measures created to clean up the node layouts. The second major problem was that the particles created are all one particle object and can not be separated easily. Since the long term goal was a different brush stroke at each particle this obviously became a problem.

Laying out the Script
Of course the first step was to layout the different sections of this script. As I saw it there were three main sections of the script. Each required a significant amount of work, as I am not a programmer, and I owe a great deal of thanks to those that helped me with my programing obstacles. The three areas I concentrated on were:

Replacing the Geometry with Particles, one at every CV or Vertex. This required the script being able to determine what type of surface the object was and how many CVs or Vertices were present. Secondly was to find each CV or Vertex's coordinates in World Space and create a Particle at that position. Each particle would have its own sprite so that a texture could be mapped to each one.

Establish a Spring dynamic structure to keep the particles equal distant from each other. Since Maya already has Springs built into its program this seemed a logical solution to keep the particles spaced out evenly across the object.

Control sprites by the distance from a given object (i.e. Camera or Light). This part of the script was meant to give some control over the look or render attributes of the geometry. For example using a light the darker sprites could be applied on the back side of the object while the lighter sprites would be applied at the closest point to the light.

How the Script works
Note: This Script is designed for Maya 4.5, there may be a few problems when going to other versions of Maya

The Interface

A simple MEL scripted window that breaks the process into 3 different parts, plus a close button. Instructions are inserted above each button.

Stage 1 - Initial Geometry

The Script works with NURBS and Polygonal geometry. In this case we have a simple default NURBS Sphere.

Stage 2 - Creating a Particle with a Plane at each CV or Vertex

This is the most lengthy part of the script. The script calculates how many CVs or Vertices and where they are located and creates a particle at each point. That particle is then instanced to a simple Polygonal plane to create a sprite like effect. The planes are by default in the script set to WorldPosition rotate which makes them slightly around the surface.

Stage 3 - Applying a Spring Structure

This could've easily been integrated into the previous stage but some users may not want a Spring structure in their product. The advantage of the springs is that they keep the particles positioned evenly across the surface. The disadvantage is that the ineractivity and playback becomes significantly slower due to the computer calculating the spring dynamics.

Stage 4 - Attaching a Shader

A basic Lambert shader is created and attached to the original instanced plane which then effects all of the instances.

Stage 5 - Changing the Shader

This stage is not part of the script as every user will have totally different ideas and wishes of what they want their textures to look like. The picture above has a simple fractal and noise pattern on the Lambert.

Stage 6 - Aiming to the Camera

This stage creates a camera and aims the sprites to the camera so that the result has the planes looking towards the camera so that more of the textures are shown.

Conclusion
I feel that I made significant progress in this project, as I even got to the global stage of this script and was able to complete that work which was more then proposed for this class. I also feel that I was able to create something that could be useful and follows the lines of my area of interest. There are still some areas that I would like to work on if I had the chance. Right now they are a bit out of reach for my knowledge but they could definately help improve the script. Those areas are:

• Create a slider so that the user could create more or less sprites
• Create a slider where the user could control how the sprites were placed (i.e. evenly spread out across the surface or exactly where each CV/Vertex is located)
• Add an addition to the script that would move the sprites towards the camera evenly so that even with a small number of sprites they would cover the maximum area possible seen from the camera. This was described in the Global plan for this script already