Posted: 05 Apr 2012, 20:52
This is a walkthrough on generating and setting up a car shadow for the upcoming v1.2 April release. Following these steps, a custom shadow could be added to your car in under 5 minutes. We will use Blender's plug-in support to automatically get most work done, so a basic understanding of this tool is recommended. If you'd prefer to use another tool, the general steps would still apply although the "5 minute" promise does not hold. Get the Re-Volt plug-in for Blender 2.62 from here before proceeding.
NOTE: If your car is a stock car repaint, you'd rather want to use one of the default shadow presets than generating your own. In that case, you can skip the first 3 steps and go directly to Step 4.
Step 1: Generating the shadow
In Blender, press 'A' to select all objects and remove them using 'Delete' key. Go to 'File -> Import -> Re-Volt' and open the "Parameters.txt" file of your car. This will import the entire car into Blender. All objects should be selected by default (note that shadow will be generated only for the selected objects).
Select the "Object Data" pane in the Properties Window (the triangle icon right pane). See the picture below to locate it.
You'll find the Car Shadow Maker option by scrolling down to the end of this pane (see below picture). Use the 'Create Shadow Polygon' option which would, by default, create a 64x64 texture with a 4 pixel margin (more on this later). Then use the 'Soft Shadow' option, and finally 'Bake Shadow'. This would generate the required shadow map. There is one more option in the Car Shadow Maker panel called 'Get SHADOWTABLE' which you'll use later.
Step 2: Retrieving the shadow texture
To retrieve the generated shadow texture, press 'Shift + F10' in Blender to open the UV / Image Editor. Use the "Browse Image" option (highlighted in the picture below) and select the "shadow.bmp" texture from the popup list.
You'll notice that the shadow is black on a white background, while Re-Volt requires white shadow on black background. You could invert the colours right in Blender, or you could do it later in your image editor. For now, press 'F3' to save the image - the default format is PNG and it can be changed if required.
Step 3: Processing the shadow texture
Now that you have your shadow texture, a little bit of post-processing is required to get it in Re-Volt format. So open up the texture in your favorite image editor such as GIMP.
The first step is obviously to invert the colors to get a white shadow on a black background. As mentioned earlier, this can be done directly in Blender but most car designers would feel more convenient using their own image editor. In GIMP, this can be achieved through 'Colors -> Invert' menu option.
The second step is to apply a little bit of blurring to take care of any aliasing and noise in the texture. A 2-pixel blur should be more than enough for our purpose. In GIMP, use 'Filter -> Blur -> Gaussian Blur' menu option and set both the Horizontal and Vertial Blur Radius to 2px.
And then you're done. Be sure to save the result as BMP. In GIMP you can just use 'File -> Save As' and directly change the file name from "shadow.png" to "shadow.bmp". Picture below shows the original shadow generated by Blender and the final one for use with Re-Volt.
Step 4: Setting up the shadow
This is the last part of the walkthrough. Now you're going to update your car's Parameters.txt file with the following entries to finally add the shadow.
Set the TSHADOW parameter to the path of your shadow texture. This works the same way as setting the TPAGE and TCARBOX parameters.
If you've NOT generated a custom shadow (i.e., if you plan to use one of the stock car shadows), you should set TSHADOW to "NONE" (or just remove that line), and use the SHADOWINDEX parameter instead. After SHADOWINDEX, set a number from 0 to 27 for one of the stock shadows found in "cars\misc\Shadow.bmp" in your Re-Volt directory.
Then you need to position the shadow under the car by setting the offset and height values. Fortunately, Blender's Re-Volt plug-in automatically gets these values for you. Go back into Blender and press the 'Get SHADOWTABLE' option in the Car Shadow Maker panel (you'd remember this from Step 1). This option not only calculates the values for you, but also copies the required Parameters entry into clipboard, ready for use. So just paste it inside your Parameters.txt file below the TSHADOW line.
In case you're not using Blender, here's a little more info to help you find these values. The first 4 numbers are the Left, Right, Front and Back edges of the shadow, relative to the model center. You don't have to worry about COM offsets, they are taken into account by the game. The last value is the shadow height, again relative to the model center. A value close to the bottom of the car would do.
Click here to see final result in Re-Volt, on Stealth XB by hi-ban.
NOTE: If your car is a stock car repaint, you'd rather want to use one of the default shadow presets than generating your own. In that case, you can skip the first 3 steps and go directly to Step 4.
Step 1: Generating the shadow
In Blender, press 'A' to select all objects and remove them using 'Delete' key. Go to 'File -> Import -> Re-Volt' and open the "Parameters.txt" file of your car. This will import the entire car into Blender. All objects should be selected by default (note that shadow will be generated only for the selected objects).
Select the "Object Data" pane in the Properties Window (the triangle icon right pane). See the picture below to locate it.
You'll find the Car Shadow Maker option by scrolling down to the end of this pane (see below picture). Use the 'Create Shadow Polygon' option which would, by default, create a 64x64 texture with a 4 pixel margin (more on this later). Then use the 'Soft Shadow' option, and finally 'Bake Shadow'. This would generate the required shadow map. There is one more option in the Car Shadow Maker panel called 'Get SHADOWTABLE' which you'll use later.
Step 2: Retrieving the shadow texture
To retrieve the generated shadow texture, press 'Shift + F10' in Blender to open the UV / Image Editor. Use the "Browse Image" option (highlighted in the picture below) and select the "shadow.bmp" texture from the popup list.
You'll notice that the shadow is black on a white background, while Re-Volt requires white shadow on black background. You could invert the colours right in Blender, or you could do it later in your image editor. For now, press 'F3' to save the image - the default format is PNG and it can be changed if required.
Step 3: Processing the shadow texture
Now that you have your shadow texture, a little bit of post-processing is required to get it in Re-Volt format. So open up the texture in your favorite image editor such as GIMP.
The first step is obviously to invert the colors to get a white shadow on a black background. As mentioned earlier, this can be done directly in Blender but most car designers would feel more convenient using their own image editor. In GIMP, this can be achieved through 'Colors -> Invert' menu option.
The second step is to apply a little bit of blurring to take care of any aliasing and noise in the texture. A 2-pixel blur should be more than enough for our purpose. In GIMP, use 'Filter -> Blur -> Gaussian Blur' menu option and set both the Horizontal and Vertial Blur Radius to 2px.
And then you're done. Be sure to save the result as BMP. In GIMP you can just use 'File -> Save As' and directly change the file name from "shadow.png" to "shadow.bmp". Picture below shows the original shadow generated by Blender and the final one for use with Re-Volt.
Step 4: Setting up the shadow
This is the last part of the walkthrough. Now you're going to update your car's Parameters.txt file with the following entries to finally add the shadow.
Set the TSHADOW parameter to the path of your shadow texture. This works the same way as setting the TPAGE and TCARBOX parameters.
Code: Select all
;)TSHADOW "cars\stealthxb\shadow.bmp"
Code: Select all
;)SHADOWINDEX 0;for RC Bandit shadow
Code: Select all
;)SHADOWTABLE -39.3 39.4 66.7 -68.2 -5.0
Click here to see final result in Re-Volt, on Stealth XB by hi-ban.