Python Particles - RenderMan and Maya


This web page displays the results of using Python to procedurally create particles for both RenderMan (rib archive files) and Maya.




Reference Image


Final Render





Inspiration





When doing research for this project, I came across some black and white images of Saturn. I personally have a soft spot for black and white images and wanted to do something different so I converted an image provided by NASA and used that as my inspiration for this project. You can find the colored image with more information here. The image can also be found directly above.





Ring Breakdown


To form the rings, I used python to write two scripts that would generate particles and arrange them the way I desired. These scripts are titled rib_particles.py and gen_points_saturn.py and can be found below. The blue boxes above indicate the rings that were imported into the Maya scene. To do this, I wrote out 17 individual rings where I then imported the .rib files one at a time. The reason I did this instead of writing them out into one file was so that I could focus on each new addition of rings and make the necessary changes one at a time instead of guessing which ring was which because I overlapped some to make certain areas more dense.


To import the .rib file in maya you go to RenderMan > Archive > Import RIB Archive > and select desired file.




Links to the Python Code


rib_particles.py

gen_points_saturn.py





Texture Breakdown




To create the texture on the planet, I applied a PxrSurface to the sphere and added a PxrRamp node. Once the PxrRamp Result RGB was connected to the PxrSurface Diffuse Color, I selected individual grey values and distributed them on the Color Ramp.



When I originally set the Ramp Type I assumed that Radial or Circular was the setting to use because I was working with a sphere however I was wrong. After going through the settings and doing some further investigation I found out that T Ramp was the way to go.








Above, you can see the individual values before and after they were blended together to replicate the planets texture. When working with the PxrRamp, I found it easier to change the interpolation setting to constant so I could see the hard lines and values. Once I had all the values sorted out, I changed the interpolation setting to linear so there was a nice blend between the values like the reference image.




Technical Issues


To light the scene, I used a PxrDistantLight to mimic the direct light that the sun produces. After adding the light, the particle's became less saturated so I had to increase their density. I also had a hard time matching up the angle of the shadow on the sphere to the reference image. I guess that will come easier with some practice.


Once that was all fixed I came across another issue. When I rendered out Saturn, I found that there was a jagged edge where the light and darkness met on the sphere. The shadow falling on the geometry was not smooth (refer to the image on the left). To fix this, I went into the SphereShape attribute window and clicked on the 'Smooth Mesh' tab and made sure the 'Smooth Mesh Preview' feature was selected.







Maya Particles Final Still Renders











Inspiration










Generating Particles


To generate particles in Maya we used python code directly in the Script Editor.


For the particles to appear in your scene you must highlight the python code and select the play button.




Link to the Python Code


nParticles.py




Applying Color







When applying the colors to the particles, I adjusted the colors in the Shading section of the attribute editor. To link the colors to the object so that they would be visible when rendered, I created a PxrSurface and PxrPrimvar node. In the PxrPrimvar node the Variable Name was set to “Cs” and the Variable Type was selected to color. I then attached the result RGB of the Primvar node to the PxrSurface Diffuse Color input.


For the bowl, I used a plastic PxrSurface from the RenderMan library and made some modifications. I found that when I rendered out the stills and animation that the cup had a black line near the rim and sides. I think it has to do with how the light interacts with the cup.





Technical Issues



An issue that I ran into towards the beginning of this project was that my sphere would indefinitely fall after colliding with the generated particles. I spent some time in class with Professor Kessen and Zhifan figuring out how to fix this problem. We decided it would be best to delete the floor plane that I had a create a new one. While the plane was selected, I selected nCloth > Create Passive Collider. Then I went into the Fields/Solvers tab and selected Make Active Rigid Body. I also had to make sure that Gravity was set.





Another issue I encountered was while I was rendering out my final animation. I would get an error message that read, “Warning: Nucleus Evaluation Skipped, frame change too large”. I wasn’t really sure how to fix this so I did some research and one individual suggested that I delete the unknown nodes by going to file > optimize scene size and the check the “Unkown nodes” box. After doing this and looking at the Script Editor, it showed that some nodes were deleted however I was still getting the error.


Another individual suggested I go to Preferences, select the Time Slider Category and set the playback speed to play every frame. After trying this the error went away however the animation was still glitchy.








Final Thoughts


I enjoyed working on this project. I have never worked with particles before. I had a lot of issues when it came to rendering out the animation. My animations took a while to render which was not ideal. In the future I would like to learn how to use the render farm. I know we briefly touched on it in VSFX 502 however I still don't have a great understanding as to whats going on. In the end, I'm happy with the final still images that were rendered. I would still like to fix the animation and figure out what's causing the glitch issue. I look forward to creating more fun particle animations in the future.