AddATex is the material we use for additive glows. Example uses include glows around bulbs, glows around headlights and glows on surfaces (from streetlights).
As this effect is additive, these effects are visible both day or night, but are more effective and more visible at night. For our example, we'll consider a streetlight.
Here you can see the streetlight asset with a night time node. This node will simply switch on (become visible) at night time.
If you examine the 3DSMax wireframe view, you can see that there are two glows contained in this asset, one upper glow centred around the bulb and one lower glow on the floor itself. Both of these glows use the AddATex material but with slightly differing properties.
The bulb glow needs to always face the camera, so that it gives the effect of a simple lens flare. This will need to have the 'VIEW FACING' flag ticked in the material.
The floor glow needs to be static and remain in position, and therefore should use the default 'NOT VIEWER FACING' flag.
Our two AddATex materials are detailed below. The material on the left is for the bulb glow and the material on the right is for the floor glow. Notice the viewer facing flags in the materials.
Also note that as these materials use alpha, the Z-Buffer mode is set to 'TEST ONLY' in both. This ensures the materials render correctly.
Example textures :
Friday, 29 January 2010
Thursday, 28 January 2010
Shaders and kuju materials - 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.
Saturday, 16 January 2010
Shaders and kuju materials - Train_Light_map _with_Diffuse. 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.
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.
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)
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.
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.
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.
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.
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)
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 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',
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.
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:
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)
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.
This is a fairly long tutorial and I may have missed a step or two, please leave comments or requests for me to change.
Thanks
d