Ambient Shadow Baker

A few months ago I was working on trying to bake AO for transparent objects. While i didn’t find a perfect solution, I did find that i could get decent results by baking shadows  from ambient lights if they were arranged properly. After running quick Gaussian Blur in photoshop, the results aren’t terrible. Here is an example on the tree i made recently, without and with baked shadows.
I made this tool to speed up the process in setting up the lights and baking the shadows. It creates a Geodesic Sphere (based on a script by Trevor van Hoof )and places lights on every point to ensure even lighting. You can set the tessellation of the sphere via DetailLevels,  choose between ambient or point lights, and set a min height to create lights at to allow hemispherical lighting. Finally in terms of baking you can choose the UV channel to use, as well as the directory to place the baked texture in.

Source Code:

baseuiwindow.py
File Size: 6 kb
File Type: py

Download File


ambientshadowbaker.py
File Size: 6 kb
File Type: py

Download File


Here is a shader for testing:

Unity Shader:

ambientalphaclip.shader
File Size: 21 kb
File Type: shader

Download File


Plant Vertex Color Generator

This is a handy little tool I wrote to generate the vertex colors for a tree with vertex animation. Painting these colors isn’t much fun and can be a bit time consuming to get right. Hopefully this will allow me to create more vertex animated plants in a shorter time frame. Here’s a video of the tool and shader in action: You can see the tree’s vertex colors on the left in Unity, before and after generation in maya

I am hoping to add support for specific channels to be regenerated instead of the whole thing and some support for other foliage types. One thing to note if you try it out is that it currently is very specific in how it expects the branch models to be made. Here is an image of the expected branch:

Simply put, it’s pivot must be at 0,0,0 and it must face down the world X at 0 rotation. You are free to duplicate and rotate this obviously, but we want all the leaves to have an origin point like this so the generator doesn’t get confused.

Source Code:

baseuiwindow.py
File Size: 9 kb
File Type: py

Download File


plantvertexcolorgenerator.py
File Size: 4 kb
File Type: py

Download File


Also uploading the shader so you can test the effect yourself.

Unity Shader:

phongnormalclipvertexanim.shader
File Size: 43 kb
File Type: shader

Download File


baseUIWindow

This may not be interesting to everyone but for some people it might be helpful. It came up in conversation yesterday how annoying Maya UI building can be. PyQt makes this a bit easier I hear, but i would like to avoid recompiling for different versions of Maya if possible. I just need something quick that gets me my buttons with as little fuss as possible. So i made a custom UI class.

The class is fairly straightforward. It manages UI tasks through functions and splits the button placement into a separate overridable function addUIElements(). From here you simply call functions to create a few UI elements. For now the class supports lists, textfields, and buttons, but i’ll be adding more in the future. Each element can be created with a single function call, allowing you to create complex setups with very little code. 

The demo class and demo extension class create these 2 windows respectively: 

Note that the extension class only requires 25 lines to make all the needed changes for the additional buttons as well as declaring a  new function to list the objects in the fields. This should hopefully allow me to iterate on my tool faster rather than being forced to address the minutia of the UI.

Update 7-23 : Updated to support radioButtons, Int fields, and Float fields. Also added optional flags to tweak elements in a non default manner, such as a text field without buttons.

Update 7-24 : Minor update to support spaces in UI elements better

Source Code:

baseuiwindow.py
File Size: 9 kb
File Type: py

Download File


Heightmap Baking

In order to bake flowmaps for my last project i used a flowmap generator based in Unity. I only have Unity Free at the moment, so in order to get flowmaps my only options were to use a static heightmap for the generator. Since i wanted to quickly iterate on the scene and have constantly updated heightmaps, I wrote a simple heightmap baker for Maya. It bakes heightmap data to vertex colors, allowing you to export maps to your preferred image format.

I’ve extended it a bit here and hopefully it can be used for other purposes in the future, such as matching terrain to kitbashed areas. Often i find heightmap painting rather  restricting, so being able to just kitbash an area and then have the terrain be updated “auto-magically” is pretty cool. Im just uploading as is to get this section kicked off but please let me know any potential improvements you would like to see.

Source Code:

heightbaker.py
File Size: 17 kb
File Type: py

Download File