Monday, 9 April 2012

TrainLightBumpSpecMask

I have seen a few people confused on new shaders, also seen one person post up how it does not work when it is clear he has his material set up wrong.
So, here I am to teach those who want to get their learn on.

TrainLightBumpSpecMask

Use this shader on scenery objects that require normal maps, specular maps and ambient occlusion maps.


Ambient occlusion
In basic terms, when creating these assets, think of an ambient occlusion map as a shadow-map. Light areas of the map are unaffected and dark areas of the map represent the shadowy areas (under gutters or in crevices).
The Shader
Use this shader on foreground buildings. Group assets that are built specifically for use as a background object should not use this material.

Slot 1 is the diffuse texture. (1st mapping channel)

Slot 2 is the normal map (24bit) with specular map (8bit) in the alpha channel. (1st mapping channel)
Slot 3 is the Ambient Occlusion map. (second map channel (shadow/lightbake))

Generally, make slot 1 and slot 2 share the same UV channel 1, and the Ambient Occlusion map have a second UV mapping channel 2. This allows for the same flexibility as when using the old shadow-map technique on the old legacy assets.

Example
Trackside Buildings


One thing to understand about this material and Trainlightmap with Diffuse, surfaces that point upwards the shadow bake gets washed out by the sun because it is a light.

If the same shadow/light map was applied to a vertical surface in stead of a horizontal one the shadow is more pronounced. (see image 3)

Shining a torch in a shadowed baked area now gets lit up, you would not expect to see a soft shadow that was generated from a global light would you?


Example of the occlusion map.

Once you have your materials set up correctly you can see how it looks.





This is a great shader to use on stations or any other track side buildings. Buildings away from the track really do not need this material.

regards

Derek

9 comments:

  1. Excellent, thanks! Learning about other RW3 shaders would be great too.

    ReplyDelete
  2. Maybe there is already and I missed it, but I'd love to see a tutorial on how best to apply textures and materials to rolling stock. I'm building a high-poly steam locomotive in 3DCrafter, and for now I'm using temporary materials that use TrainBumpSpecEnvMask.fx and TrainSpecEnvMask.fx shaders, but I'm not very happy with the way they look. Before I go about texturing the model properly, I'd like to have a better idea of how to do it. Any pointers in that direction would be very gratefully received. Incidentally, 3DC doesn't (not yet anyway) do shadow baking, which might be one reason why my texturing doesn't look as good as what is released by the professionals.

    ReplyDelete
  3. I worked out how to do it properly (it wasn't a problem of the materials, but rather how I was applying them to the surfaces), although because 3DCrafter doesn't do shadow baking, I have to paint shadows onto the diffuse textures myself, which is very laborious.

    ReplyDelete
  4. Just a question, i used this shader but even though i've set an alpha channel in the normal map, it seems the specular value isn't take into account. Does Specular value really works with this shader ? Or am i doing something wrong ?

    ReplyDelete
  5. You need to set the UV arguments in the material. I will update blog.

    d

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hellow, Derek! I'am a Train Simulator 2013 user from Russia.
    I have a question about TrainPostDPPObjectDiffuse.fx
    On the figures links on wich are in this message below is the same object, but in left side of picture it uses the TexDiff.fx shader and on the right side of picture it uses TrainPostDPPObjectDiffuse.fx shader. I use a very cost-effective graphics card settings 8x FSAA + MSAA, because at the higher my FPS drops. Thin objects such as the catenary details have very bad look to the TexDiff.fx shader with these graphics card settings. So I, like other users and developers from railunion.net, very suitable TrainPostDPPObjectDiffuse.fx shader that I use in order to improve the image and save resources graphics card. But, as seen in the picture, using the shader objects are not covered by third-party sources of light that look very bad and spoils the experience of playing at night. And the use of TexDiff.fx shader makes objects bad looking at day. In the following screenshots you can see, that catenary objects wich use TrainPostDPPObjectDiffuse.fx shader look good at day. I beg you, correct the shader so that it is covered by external light sources. You just be sure to let me know if this shader corrected in the near future, such as the twenty-sixth of September 2013 or the latest patches, or the work will be postponed to a back burner.I just need to know to wait for me until you fix the shader, or should I look for other ways to work around this problem, for example to buy a more powerful graphics card and use TexDiff.fx shader on my catenary with higher graphics card settings. Building my route catenary suspended because of this.

    http://fotki.yandex.ru/users/mmtyurin/view/769131/?page=10 fig.1
    http://fotki.yandex.ru/users/mmtyurin/view/769133/?page=10 fig.2
    http://fotki.yandex.ru/users/mmtyurin/view/769132/?page=10 fig.3

    With best regards from russian users of Train Simulator 2013, Michael.

    ReplyDelete
  8. I'm sorry. I've just noticed that that pictures are in my private album. So I post it again, but now you can see the pictures. Sorry
    http://fotki.yandex.ru/users/mmtyurin/view/771223?page=3
    http://fotki.yandex.ru/users/mmtyurin/view/771224?page=3
    http://fotki.yandex.ru/users/mmtyurin/view/771225?page=3
    Near the lower right corner of the image there is an option with a choice of size. You can view the image in its original size.

    ReplyDelete
  9. Hi Derek

    A bit late, but any chance you could update the uv information on this? i still cant get the spec to work :(

    thanks

    ReplyDelete