Shader "SubtractATexDiff"

 
SubtrackATexDiff is the material we use for soft shadows under rolling stock.
This object should be exported in the same 3DSmax file as the asset you want it under. (However you could also set it up as child object also)
 
 
First of all I made a box roughly the size of the wagon or asset you want the shadow to sit under.
I deleted all the polygons except the top one and then reset x form/and position and transform on pivot. I then placed this at 0/0/0 in the world. Remember that 0 height in Max is the top of the rails in RailWorks for rolling stock.
So with that in mind I dropped the shadow object down a few centimetres so that the shadow would be above the sleepers but below the rail height.
 
I have my object a name 1_0300_softshade, so after 300M the shadow would not be drawn.

 
I selected the Kuju Material SubtractATexDiff, set the alpha to Test Only (1) then selected my texture.
 
Below is an example of a 24Bit shadow texture. (no alpha channel is needed)
The darker the grey the less it shadows, black is invisible and white is solid black shadow (I know it seems wrong)

 
Export your 3DSMax scene and view the effects in the Asset Editor.

 

Shader "TrainLightMapWithDiffuse. fx"

This kuju material is the most common one used in RailWorks.

However, it is a little more complicated than most as it needs the user to create a second mapping channel and a light map texture.
To help discuss this material I will be using a simple wooden shed object to help illustrate the methods used.
 
 
 
Above is an image of a texdiff material, the object looks flat and unlit.
 
Above is a Train Light Map With Diffuse, you can see the shadows make a huge difference.
 
Before I start, I just want to point out that there is no right or wrong way to go about getting the best results, this is just the way I do it.
Before I make a 3D model I tend to make most of the texture first. The reason I do this is that I constrain myself to what is important. Laying the ground rules before you start helps focus to what’s important.
While making the texture you also want to give some consideration to winter textures, if a material is used on a roof and you want to do a winter version with snow on then you best not use that section of the texture for a wall surface.
 
 
 
Save this texture in the correct folder structure something like this:
C:\Program Files (x86)\Steam\steamapps\common\railworks\Source\RSderek\WearValleyRailway\Scenery\Misc\Textures The Max/IGS and XML files will all be saved in the Misc folder, and all textures saved in the texture folder.
 
Ok, once you have made your object, select Polygon option in the modify panel and then select all the faces in the object and assign ID1 (1)
Also make sure all the faces in your object have a smoothing group. This can be done by pressing auto smooth in the same panel (2)
 
 
Save max.
 
Open up the Material Editor, this can be done by pressing ‘M’ or selecting the icon from the top tools bar.
In the Editor, click the Standard button, the select Kuju Material.
In the Shader Configuration section click the black triangle next to the TexDiff option. This will open out the list of Kuju Materials. Move the slider down and select ‘TrainLightMapWithDiffuse.fx’

In Slot 1 click ‘None’ , then select bitmap at the top of the list in the new window, click ok and then find your texture in the explorer window, once selected the windows will be closed and you will be back in the material editor.

Now click on show standard map in viewport button (the little isometric blue and white chequered square)

You have your model, material and texture, now you need to map the texture to the object.

There are many ways to unwrap, and I use different options for different , For this simple object I am going to flatten unwrap then move the mapping coordinates around till I have each face mapped as I want it. (Indepth mapping of objects will be covered in a different post, however there are many tutorials for doing this on the net)
Select the polygon selection button in the modifier list, select all the polygons in your object then click the little black triangle next to the words Modifier list, this shows all the modifiers you can then apply to your object. Scroll down and select Unwrap UVW, then click 'edit' in this new panel.
 
 
This brings up a new mapping window.
 
It will be a mass of green and white lines depending on how you have modelled your object.
But be cool, we will make order from this chaos.
In the bottom tool bar select Face-Sub object mode',
 
 
 
Draw a selection box around all your messy lines in the window.( you may have to zoom out in the window to select them all)
In the top tool bar in the mapping window click the ‘Mapping’ button then select the flatten mapping. Another smaller window opens up. Leave the Face angle threshold at 45, however change the spacing to 0.002. (this packs the coordinates closer together) Then click OK.
 
 
You now have all your polygons mapped out in a square.
This is great but now you want to reuse sections of your texture a number of times, I moved my coordinates around to layer up the mapping on certain sections of my model. (Indepth mapping of objects will be covered in a different post, however there are many tutorials for doing this on the net)
This is how my final mapping coordinates look against my texture:
 
 
Close the mapping window and then right click on the Unwrap UVW (It should be highlighted in yellow) and select ‘collapse all’ You can leave the UVW in the stack if you wish but it serves no real purpose in this tutorial, remember to collapse the stack before export.
Save max.
OK, Diffuse side done now for the Light map.
Once again select the polygon selection button in the modifier list, click the little black triangle next to the words Modifier list and scroll down to select Unwrap UVW.
(Depending on your version of max the process is slightly different. I am using Max2009)
 
 


Change the map channel to 2. (1) then click Edit (2) This brings up a new mapping window as before.
In the bottom tool bar select Face-Sub object mode, draw a selection box around all your messy lines in the window.( you may have to zoom out in the window to select them all)
In the top tool bar in the mapping window click the ‘Mapping’ button then select the flatten mapping. Another smaller window opens up. Leave the Face angle threshold at 45, however change the spacing to 0.002. (This packs the coordinates closer together) Then click OK. You will now have all your faces tightly mapped into a square. You can fine tune these mapping coordinates if you wish but I seldom do, but I will if I do not feel I am getting the best out of my space. Before doing this I suggest lots of mapping practise.

Close the mapping window and then right click on the Unwrap UVW (It should be highlighted in yellow) and select ‘collapse all’

OK, we now have an object with 2 mapping channels awaiting the second texture.
Save max.

We now need a light map, this is how we make it.

As you have just saved the max file we now need to make the lighting setup, Save the same current scene under a different name, something like ‘Shed_light.max’
 

Select your object, in this case I select my shed and I assign a default material (1)
Select your object then assign the material (2)
Untick the yellow lock from diffuse and ambient (3)
Darken the Ambient colour (4)
All other values leave alone.
(These values are not hard rules and I suggest experimenting with different values to see the effects.)

In the top view create a box 100Mx100Mx-20M make sure this box is centred under your object. This we will use as our ground plan so that the light will not shine up through the floor. Assign the same default texture to this box. (also make sure the box is flush to the base of your object)
 

In the modifier panel click on the light icon (1), select Standard (2) and select sky light (3)
Then click on the screen, this will create a light. In the right hand view port make sure the light is above the floor plane and your object. (It is not important to be exact about placing your light except to make sure it is not inside an object)

Select the light and in the modifier panel make sure the skylight is white (click the colour swatch and slide the value to white)
Press F10 to open up the Render Setup window. In the advanced Lighting set up select Light Tracer.
These values can all be changed and experimented with. To begin with use the setting from the image below.
 
 

At this point you can set up a camera and render as usual to have a peek at what the object looks like, if you are not happy with the results change the values in the Advanced set up.
Select your object to render.
Once happy, Press 0 (Zero) this will bring up the Render to texture window.
 
 


Click the select path where you want to save the texture (1)
Scroll down and set 3 in your padding (2) this bleeds around the coordinates to reduce mip issues
Mapping Channel set to 2 (3)
Scroll down and click the ‘Add’ button Select Complete map (4)
Scroll down to select your map size, for this small shed I will choose 256/256, however 128/128 would be fine, (for larger objects choose a larger map size). (5)
Scroll down and click Render and then OK. (6)
It may take a little while depending on the number of polys in your object.

Once done, find your texture on your desk top and save and convert it into a .ace in the same folder as your diffuse texture. (Choose a suitable name, I normally save the file as the same as the diffuse but with and _SM at the end, it helps me keep track)
Save this max file then reopen your original max file.

Open up the Material Editor and in the kuju material select slot 2, click ‘None’ , then select bitmap at the top of the list in the new window, click ok and then find your shadow map texture in the explorer window, once selected the windows will be closed and you will be back in the material editor.
Close the Material Editor, make sure your object is named correctly and export as an IGS as usual.

Shader "WaterCubemap.fx"

 
In Railworks there are a number of ways of creating water assets in your route.

(1) Rivers - Here a river loft is recommended. This asset would use the WaterCubeMap.fx

(2) Lakes and Seas - The in-game (editor mode) water decal is recommended as it is the most efficient way to create a large expanse of water.

(3) Scenery - Sometimes a very small localised water effect is required on a scenery asset that is irregular in shape. In this case, the WaterScenery.fx shader can be used.

Using the WaterScenery.fx shader, the author can create a scenery asset and assign the WaterScenery.fx to any polygon. Therefore the shape of the water surface is under the control of the author. This asset can be exported as usual via a the IGS format and be referenced in a 'Scenery Blueprint'.

Example Use
Water troughs, swimming pools, circular ponds, open water towers etc.

Points of Interest
This is a vertex shader (meaning the positions of the vertices of the surface are physically moved) is therefore expensive to render. It is therefore recommended to keep its use down to a minimum.

Notice that the surface of the water shown below is no longer flat as seen in the other water shaders.



As can be seen below, the shader is a triple pass shader with 3 texture slots. All texture slots MUST contain a reference to a texture. In slot 1, we specify the normal map texture, along with the five UV arguments and specular value. In both slots 2 and 3 we specify the texture for the water surface.



The following UV arguments should be setup for slot 1 of the shader.

UV argument 1 : Specular component (values between 0 and 64)
UV argument 2 : 'Wobble' factor (values between 0 and 1)
UV argument 3 : Movement speed (0.02 is a good value)
UV argument 4 : Oscillation height (0.02 is a good value)
UV argument 5 : Oscillation scale (6 is a good value)

Below are example textures showing the alpha channels where applicable.
 

Shader "TrainGlass.fx"

The TrainGlass.fx shader in RailWorks should be used whenever a translucent glass material is required. e.g. Windows on rolling stock.

Using the glass shader the author can control the following properties:
  1. Texture - Whats on the glass, colour, scratches etc
  2. Translucency - How see-through the glass is
  3. Specular - The size of the 'shiny' highlight phong
  4. Environment Map - The intensity of the environment map (the faked reflection) in both day and night lighting conditions.

Example Use:
Windows on Rolling Stock

Point of Interest:
Only a single texture needs to be created by the author, even though there are two texture slots in this material. Both texture slots MUST contain a texture reference. The same texture can be referenced (or pointed to) in both texture slots. This second texture slot simply exists to allow the game code to carry out a second environment pass (fake reflection map) in the game.

Here we have the TrainGlass.fx shader applied to 3 assets (A,B and C), all using different parameters.

TrainGlass.fx shader viewed in the daytime.


TrainGlass.fx shader viewed in the nighttime.


Here we have the 3 materials used for the assets A, B and C. All use the same shader (TrainGlass.fx) but use different parameters. The parameters are highlighted below.



The important parameters are the UV arguments (for Slot 1 only), and the Specular Power.

UV argument 1 : This specifies the 'tightness' of the phong highlight. Keep this value somewhere between 0-64 with 64 being the 'tightest'.

UV argument 2 : This specifies the intensity of the reflection (day-time)

UV argument 3 : This specifies the intensity of the reflection (night-time).

Specular Power : This specifies how brightness (or intensity) of the phong highlight. Keep this between 0-8 with 8 being brightest.

Example texture (used for the examples above) showing RGB and intensity of alpha channel.