Raster Based Color Bleed Baking
This Project was intended to provide a way to bake lighting and color bleeding to simple meshes for games Using a method inspired by Pixar's Point Based Color Bleeding Paper here. This method uses a cube raster process to calculate lighting simular to the method descibed in Pixar's paper. Instead of using points to capture light information this method bakes the lighting directly to the mesh textrue. A cube is rasterized for every visible pixel on the texture of each mesh in a scene. Cuda is used in the rasterization process to meet the large demands of this method.
There are two main parts to this process, lighting and color bleeding. In the first part light meshes are rendered to the cube in color multiplied by an emision value set in the scene file. Other meshes are rendered black to oclude lights forming shadows. After this first part a second pass is made ignoring lights and rendering meshes using their light baked textures multiplied by a set emision value.
The cube raster process is performed on one pixel at a time and consists of three steps. The first step in the process consists of creating five translation matrices for five sides of the cube. The bottom of the cube is not needed. The translations are alined to the normal at the pixel to be baked to. These matrices are then put into global memory for Cuda. The next two steps are done on the gpu with Cuda. The second step translates and clips all of the triangles in the scene for each of the five faces of the cube and stores them in global memory for the next step. In the last step another Cuda call is made to rasterize the triangles to shared memory. In this step the color values in shared memory are multiplied by a distribution and added to form one color to bake to the single pixel in the texture.
This process can take a considerble amount of time but there is room for improvement. It may be posible to combine both Cuda calls into one and call many at once to get large chunks of the texture done.
This image shows the textures that make up a simple baked scene.
This image shows the two passes made by the baking program. In the first pass lights are rendered in full color but other meshes are drawn black creating shadows. In the second pass the lights are ignored and the other meshes are drawn in color providing the color bleeding.