Shader "TrainLightMapWithDiffuse. fx"

Dieses Kuju-Material ist das am häufigsten in RailWorks verwendete.

Es ist jedoch etwas komplizierter als die meisten, da der Benutzer einen zweiten Mapping-Kanal und eine Light-Map-Textur erstellen muss.
Um dieses Material zu besprechen, werde ich ein einfaches Holzschuppen-Objekt verwenden, um die verwendeten Methoden zu veranschaulichen.

 
 
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 gibt es eine Reihe von Möglichkeiten, Wasseranlagen in Ihrer Strecke zu erstellen.
  1. Flüsse - Hier wird ein Fluss-Loft empfohlen. Dieses Asset würde die WaterCubeMap.fx verwenden.
  2. Seen und Meere - Das In-Game (Editor-Modus) Wasser-Decal wird empfohlen, da es die effizienteste Art ist, eine große Wasserfläche zu erstellen.
  3. Szenerie - Manchmal wird ein sehr kleiner, lokalisierter Wassereffekt auf einer unregelmäßig geformten Szenerie benötigt. In diesem Fall kann der Shader "WaterScenery.fx" verwendet werden.
Mit dem WaterScenery.fx-Shader kann der Autor ein Szenerie-Asset erstellen und die WaterScenery.fx einem beliebigen Polygon zuweisen. Damit liegt die Form der Wasseroberfläche in der Hand des Autors. Dieses Asset kann wie gewohnt über das IGS-Format exportiert werden und in einem 'Scenery Blueprint' referenziert werden.

Beispielanwendungen:

Wassertröge, Schwimmbäder, runde Teiche, offene Wassertürme usw.

Wichtige Hinweise:

Dies ist ein Vertex-Shader (d.h. die Positionen der Vertices der Oberfläche werden physikalisch bewegt) und ist daher rechnungsintensiv im Rendering. Es wird daher empfohlen, seine Verwendung auf ein Minimum zu beschränken.
 
Beachten Sie, dass die Oberfläche des unten gezeigten Wassers nicht mehr flach ist, wie bei den anderen Wassershadern.



Wie unten zu sehen ist, ist der Shader ein Triple-Pass-Shader mit 3 Textur-Slots. Alle Textur-Slots MÜSSEN eine Referenz auf eine Textur enthalten. In Slot 1 geben wir die Normal-Map-Textur an, zusammen mit den fünf UV-Argumenten und dem Spiegelungswert. In den beiden Slots 2 und 3 geben wir die Textur für die Wasseroberfläche an.
Die folgenden UV-Argumente sollten für Slot 1 des Shaders eingestellt werden.
  • UV-Argument 1 : Specular-Komponente (Glanz, Werte zwischen 0 und 64)
  • UV-Argument 2 : 'Wobble'-Faktor (Wellen, Werte zwischen 0 und 1)
  • UV-Argument 3 : Bewegungsgeschwindigkeit (0,02 ist ein guter Wert)
  • UV-Argument 4 : Oszillationshöhe (0,02 ist ein guter Wert)
  • UV-Argument 5 : Oszillationsskala (6 ist ein guter Wert)
 
Nachfolgend finden Sie Beispieltexturen, in denen die Alphakanäle, sofern vorhanden, angezeigt werden.

 

Shader "TrainGlass.fx"

Der Shader TrainGlass.fx in RailWorks sollte immer dann verwendet werden, wenn ein lichtdurchlässiges Glasmaterial benötigt wird. z.B. Fenster an Schienenfahrzeugen oder an Gebäuden.

Mit dem Glas-Shader kann der Autor die folgenden Eigenschaften steuern:

  1. Textur - Glasoberfläche und Material, Farbe, Kratzer etc.
  2. Transluzenz - Wie durchsichtig das Glas ist
  3. Specular - Die Größe des "glänzenden" Glanzpunktes
  4. Environment Map - Die Intensität der Environment Map (der vorgetäuschten Reflexion) bei Tag- und Nachtbeleuchtung.

Anwendungsbeispiel:

Transparente Fenster an Schienenfahrzeugen und Gebäuden

Interessanter Punkt:

Es muss nur eine einzige Textur vom Autor erstellt werden, obwohl es zwei Textur-Slots in diesem Material gibt. Beide Textur-Slots MÜSSEN eine Textur-Referenz enthalten. Dieselbe Textur kann in beiden Textur-Slots referenziert werden (oder auf sie zeigen).

Der zweite Textur-Slot existiert einfach, um dem Spielcode zu ermöglichen, ein zweites Umgebungs-Rendering (Fake-Reflection-Map) im Spiel auszuführen.

Hier wird der Shader "TrainGlass.fx" auf 3 Assets (A, B und C) angewendet, die alle unterschiedliche Parameter verwenden:

TrainGlass.fx-Shader bei Tageslicht betrachtet:


TrainGlass.fx-Shader in der Nachtansicht:



Hier haben wir die 3 Materialien, die für die Assets A, B und C verwendet werden.
Alle verwenden denselben Shader (TrainGlass.fx), verwenden aber unterschiedliche Parameter.
 

Die Parameter des sogenannten "Phong Lighting" sind unten hervorgehoben:



Die wichtigen Parameter sind die UV-Argumente (nur für Slot 1) und die Specular Power:
  • UV-Argument 1: Hier wird die "Dichtigkeit" des Phong-Highlights angegeben. Halten Sie diesen Wert zwischen 0 und 64, wobei 64 der "dichteste" Wert ist.
  • UV-Argument 2: Hier wird die Intensität der Reflexion (bei Tag) angegeben
  • UV-Argument 3: Hier wird die Intensität der Reflexion (bei Nacht) angegeben
  • Specular Power: Dies gibt die Helligkeit (oder Intensität) des Phong-Lichts an. Halten Sie diesen Wert zwischen 0-8, wobei 8 am hellsten ist

Beispieltextur (verwendet für die obigen Beispiele) mit RGB und Intensität des Alphakanals:


 

Shader "TexDiff"

Beim guten alten Tex-Diff handelt es sich um den Standard-Shader, den Sie verwenden sollten, wenn Sie zum ersten Mal versuchen, etwas im Spiel anzuzeigen.

Warum?

Da es keine zusätzliche Arbeit beim Einrichten erfordert, ist es der schnellste Shader, um herauszufinden, ob etwas mit Ihrem Modell oder Ihrer Textur nicht stimmt.

Beschreibung:

Objekte mit diesem Shader werden mit diffusem Licht inklusive Sonne oder künstliche Leuchten beleuchtet und werfen Schatten.

Beispielanwendung:

Kleine Allerweltsobjekte ohne Reflektion, ohne Glanz.

Wichtige Hinweise:

  • Dies ist ein 2-seitiges Material. allerdings werden die Polygone im Spiel nur von einer Seite richtig beleuchtet.
  • Die damit versehenen Objekte wirken aufgrund des fehlenden Glanzes "flach" und teilweise unwirklich.
  • Seien Sie auch vorsichtig, wenn Sie 2 Oberflächen nahe beieinander legen, wenn Sie dieses Material verwenden, da das Material zweiseitig ist und obwohl Polynormale voneinander weg zeigen, erhalten Sie Z-Fights, was dazu führt, dass die Oberflächen beim Kampf flackern, wenn sie angezeigt werden .
  • Es gibt viele alte Schaltflächen und Werte in allen Kuju-Shadern, von denen viele im Train Simulator nicht (mehr) funktionieren, selbst das Team hat nicht alle Optionen untersucht!

Einstellungsmöglichkeiten:

Das Bild zeigt einen Ausschnitt aus 3Dmax. Im Programm "Blender" sehen die Einstellungsmöglichkeiten aber ähnlich aus. Wichtig sind due 3 markierten Optionen.

 

1 - Mip LOD Bias

Wikipedia:

Die Buchstaben MIP sind ein Akronym des lateinischen Ausdrucks multum in parvo, was "viel in wenig" bedeutet - also sinngemäss eine Art der Kompression darstellt. In der Computergrafik sind Mipmaps (auch MIP-Maps) vorberechnete, optimierte Sequenzen von Bildern, von denen jedes eine progressiv niedriger aufgelöste Darstellung des vorherigen ist. Die Höhe und Breite jedes Bildes bzw. jeder Ebene in der Mipmap ist um den Faktor zwei kleiner als die vorherige Ebene. Mipmaps müssen nicht unbedingt quadratisch sein. Sie sind dazu gedacht, die Rendering-Geschwindigkeit zu erhöhen und Aliasing-Artefakte zu reduzieren. Ein hochauflösendes Mipmap-Bild wird für Samples mit hoher Dichte verwendet, z. B. für Objekte in der Nähe der Kamera; Bilder mit niedrigerer Auflösung werden verwendet, wenn das Objekt weiter entfernt erscheint.
Die Einstellung im Feld Mip LOD Bias wird verwendet, um die Distanzen beim Mipping zu vergrössern oder zu reduzieren. Wenn Sie das Ausblenden von Texturen (für Zifferblätter in Führerständen, Logos, Text auf der Seite von Zügen usw.) verzögern möchten, muss ein Minuswert verwendet werden. Dies bedeutet, dass die Textur länger schärfer bleibt, je weiter Sie wegziehen. -2 verwendet das Team für die meisten Zifferblätter im Führerstand.
  • Normalerweise belassen wir dies bei 0.
  • Negative Werte erhöhen die Distanz für scharfe Bilder
  • Positive Werte reduzieren die Distanz

 

2 - Transparency

NONE oder TRANS, spricht für sich selbst. Wenn Ihre Textur 24 Bit (3x 8 Bit RGB) hat, lassen Sie dies standardmässig auf NONE.
Nachfolgend sehen Sie eine Beispieltextur und ihren Alphakanal.

Textur - Diffuse Textur
Textur - Diffuse Textur


Textur - Alpha Kanal


Texdiff - ohne Transparenz


Texdiff - mit Transparenz

Wenn Sie einen Alphakanal in Ihrer Textur haben und diese als 32-Bit gespeichert ist und Sie möchten, dass der Alphakanal verwendet wird, ändern Sie diesen auf TRANS.(Schwarz ist transparent und Weiß ist einfarbig im Alphakanal)

3 - Beleuchtungsmaterial

Diese Einstellungen werden vom Team nicht oft verwendet, aber Sie können die Diffusfarbe, Umgebungsfarbe und Emissionsfarbe ändern.
 
Dies ist nützlich, wenn Sie eine Graustufentextur erstellen und sie mit einer dieser Methoden einfärben.
Erstellen Sie z. B. 1 Autotextur und erstellen Sie viele farbige Versionen mit dieser Methode. Eine gute Möglichkeit, die Anzahl der Texturen gering zu halten.
 
Specular und Specular Power werden in diesem Material nicht verwendet.