Using Maya's Convert to File Texture Tool for Real Time Game Environments

Advanced Uses of the Tool

As a game developer, one of the potential downsides to this process is texture space. You never have enough, you can never spare enough, and this tool seems to spend it like there is no tomorrow. To prevent this, we are going to use a Layered Texture node with multiple UV sets. With this in place, we will see how it enhances the possibilities for controlling what is displayed on your objects.

I'll use a projection mapping on the right wall in the scene, covering the whole face, and call this UV set "Shadow." Then I'll apply a simple white Lambert shading group to it and apply the Convert to File Texture tool.

Then I will apply another projection mapping on the same wall, with "making new UVset" checked, and call this set "Checker." The next step is to set up the layered texture node on a Lambert shading group. Remember to give the textures names similar to the UV sets so it's less confusing.


Figure 5. Nothing beats a good old "Before and After."

 

With the two textures in place in the node, I set the blending mode of the shadow texture to "Multiply."

Figure 6. The two textures used on the wall.

 

Now I need to apply the right texture to the right UV set. After applying the shader with the layered texture node to the wall, I open the UV Relationship Editor and, with the object selected, connect each UV set to the relevant output color channel of the shader.

Now we should be able to see the two textures nicely blended on the wall. If not, make sure you have the files in the right order and change it within the layered texture node attribute editor with the right mouse button. Don't forget to also modify the blend mode.

We can now control the way the UVs on our main texture behave without disturbing our shadow rendering. To do that, right-click on the object and select the right UV set in the menu, then modify the UVs in the texture window. We can also select which set we want to work with on the selected object in the texture window in Image>UVset.

Figure 7. How having a coherent naming system comes handy.

 

Having total control of the two separate textures and UV sets opens a new and exciting toolbox for game developers. With this setup, we can control the texture space used for the object and its shadow. With different filtering and blur in Photoshop or our 3D game engine, we can get away with a relatively small texture for the shadow of a large object, and keep the main texture its same size with full details and tiling across the whole length, with the shadow nicely breaking the pattern. Keeping with the idea of controlling the size of VRAM we are using, we can use a paletted version of the shadow map to 8-bit or even 4-bit if the size or quality of the shadow allows it, and keep the main texture in its 24-bit glory. This type of texture could sustain a level of compression relatively high and not jeopardize the overall look.

Figure 8. Layered Texture node.

I can also modify the contrast or color of the shadow map by changing its texture attributes in Photoshop without having to reprocess the render. I could have different lights set up for different times of the day, or different light positions and colors in the same level for a different mood later in the game; I would just have to swap the shadow files around.

Alpha Shadows

Now for the plane displaying a number 4 in the scene. Notice that the number is not made of geometry but is a simple texture with an alpha channel on the small plane on the left. The only way in software rendering to get a shadow out of this object would be to use raytracing. As raytracing does not produce shadow maps, it is not usable with the Convert Texture Tool, so we have to fake it.

We will use the same number 4 texture for the color channel of the spotlight, invert it in the Texture Effect check box, and set the intensity to -1. If we render the scene now, we can see that the spotlight is projecting a black "4" on any objects within the beam. But if the light is blocked by an object (that is, the small plane we want the shadow for) it will stop there and the effect will not be completed. We are just projecting a texture. Link the light with the Relationship editor to any of the objects in the scene except the small plane -- this will force the light to go straight to the ground plane and display the texture there.

Because the spotlight is projecting a texture, it will be picked up by the Convert to File Texture tool when we process the ground texture. We can use this to project a foliage shadow on the trunk of a tree and its surroundings, or a chicken-wire fence, or any kind of object that is better described with an alpha channel than geometry in your environment.

Other effects can be achieved with a spotlight with a positive intensity. Set up a spotlight with a texture in the color channel (in this case a multi-colored letter "M" on a black background) and the tool will pick it up on the ground texture as well.

Figure 9. The converted ground texture.

 

This can be of great effect for logo projection in a dance club or a shop wall, or can produce a nice fake of light going through stained glass in a temple. But this setup only works if we render the texture with the light applied to it. A Multiply blend of strong colored textures gives an odd result, but it can be experimented with for additional strange, alien effects.

________________________________________________________

Workflow on a Complex Scene