Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re-use splatted textures shader in a .material file?
#1
Question 
I'd like to use some of the same textures that I have alpha splatted on to my terrain for some .mesh files in the same terrain.

Is it possible to call the shader that the alpha splatting uses via a .material file?

I hope my question is clear enough, I don't really understand the programming side of things to investigate myself, but what I mean is that in my .otc file I have a line:
Code:
4, mud.dds, mud_norm.dds, NS98_landuse_map.png, R, 1

This gets splatted on to my terrain wherever I have red on the landuse_map.

If I assign mud.dds to a .mesh file via the .material file it won't look the same as it will lack the normal and parallax passes.

I want to re-use the same shader for mud.dds that the material in the .otc file uses, on a .mesh, using the .material file. Is this possible?

Or an alternative way of putting it;

If I put this into a .material file
Code:
material MyTexName1 : tracks/basicwater

Then I can get a .mesh to be textured with the same water as used in the terrain.

Can I do the same for the textures splatted by R, G, B and A channels as defined in the .otc?
Reply
#2
(01-30-2017, 10:00 PM)rents1977 Wrote: I'd like to use some of the same textures that I have alpha splatted on to my terrain for some .mesh files in the same terrain.

Is it possible to call the shader that the alpha splatting uses via a .material file?

I hope my question is clear enough, I don't really understand the programming side of things to investigate myself, but what I mean is that in my .otc file I have a line:
Code:
4, mud.dds, mud_norm.dds, NS98_landuse_map.png, R, 1

This gets splatted on to my terrain wherever I have red on the landuse_map.

If I assign mud.dds to a .mesh file via the .material file it won't look the same as it will lack the normal and parallax passes.

I want to re-use the same shader for mud.dds that the material in the .otc file uses, on a .mesh, using the .material file. Is this possible?

Or an alternative way of putting it;

If I put this into a .material file
Code:
material MyTexName1 : tracks/basicwater

Then I can get a .mesh to be textured with the same water as used in the terrain.

Can I do the same for the textures splatted by R, G, B and A channels as defined in the .otc?

To your first question. You cannot call the built-in terrain shaders. You can however use alpha splatting on a mesh.

This old tutorial from DeGa and Fat-Alfie should help you with that. I should be able to answer any questions you may have about this.
 https://xror.avrintech.net/rorwikibackup..._Splatting

A creative way to make mixing meshes with alpha splatting and an ogre 1.8 terrain work is to use diffuse textures with an opacity of 1 (out of 255).
This will give you essentially zero specular lighting on the terrain.

To your second question. I have not been able to get RoR's water materials to work on custom meshes myself since it appears RoR injects shaders into some materials during runtime.

A good reference for anything material script related is the ogre manual.
http://www.ogre3d.org/docs/manual/manual...C_Contents

To your third question. No, you cannot use individual channels from a RGB/RGBA image other than alpha for blending 2. However you can replace  

blend_diffuse_alpha

from the texture unit for the detail texture from the alpha splat material script 1 with 

blend_diffuse_color

To use grayscale images to control alpha splatting.

This however will warrant changing your pass' scene blending from 

scene_blend alpha_blend

to 

scene_blend colour_blend

Overall, I hope this helped answer your questions.
[-] The following 2 users say Thank You to derbymutt for this post:
  • Michael10055, rents1977
Reply
#3
Thanks for getting back to me Smile I'll take some time to digest this and make sure I follow it all correctly.

Re the water, you are right, I misunderstood what I did, as well as giving the alias I actually just copied the shader:
Code:
material NS98CoolTower : tracks/basicwater
{
    receive_shadows off
    technique
    {
        pass
        {
           ambient 0.5 0.5 0.5
           //specular 0.5 0.5 1.0 10.0
           scene_blend modulate
           // double-sided
           cull_hardware none
           cull_software none
           depth_write off
           texture_unit
           {
              texture water.dds
              scroll_anim .01 .01
           }
         }
        pass
        {
           ambient 0.3 0.3 0.3
           specular 0.5 0.5 1.0 10.0
           scene_blend add
           // double-sided
           cull_hardware none
           cull_software none
           depth_write off
           texture_unit
           {
              texture water.dds
              scroll_anim -.01 -.01
           }
         }
    }
}

The danger of doing too many experiments back to back!
But, the above .material file gets the animated RoR water texture on to any .mesh object assigned material NS98CoolTower, I can show this with screenshots if required?


I had hoped the terrain had used something similar to this: https://xror.avrintech.net/rorwikibackup..._Splatting behind the scenes, because then I should be able to call the alias RGBMap1 or RGBMap2 to apply terrain textures to meshes, IF my understanding of Ogre texture aliases is correct?

Basically I'm just going by this: http://www.ogre3d.org/docs/manual/manual_26.html
Reply
#4
(01-31-2017, 01:49 PM)rents1977 Wrote: I had hoped the terrain had used something similar to this: https://xror.avrintech.net/rorwikibackup..._Splatting behind the scenes, because then I should be able to call the alias RGBMap1 or RGBMap2 to apply terrain textures to meshes, IF my understanding of Ogre texture aliases is correct?

Basically I'm just going by this: http://www.ogre3d.org/docs/manual/manual_26.html

From my experience using material scripts, a texture_alias is on a per-material basis.
I'll run through a simple scenario here to explain.
Code:
I create a material script A. This features the following attributes:
material A
{
     pass APass
     {
          texture_unit ATex
          {
               texture_alias ATexture
          }
     }
}

I then create a second material B, which references material A as it's super with the attributes:
material B : A
{
     set_texture_alias ATexture image.jpg
}
Material A by itself will not render anything since it only contains a texture_alias. This means you need to use it as a super in another material and set it's texture_alias to an image.

Every material created with A as it's super will be independent of each other.

If material A had a hard-coded texture built into it, then all child materials would also have that hard-coded texture. You use texture_alias to create a "shell" material to be re-used multiple times.

This means in order to be able to clone the terrain's materials, you would have to set the final child material for the terrain material as the super for your material.

If this helps, I setup this system using alpha splatting and super materials to create a more universal material system for submesh mods (which has not been used yet sadly)
https://github.com/RigsOfRods/rigs-of-rods/pull/969

I hope I answered your question.

Terms used defined:
Super -- (in the context of this message) the "parent" or referenced item which defines the structure or basis of referencing content.
Child -- (in the context of this message) a script or object that uses a referenced item to configure or define the structure it follows.


References:
http://www.ogre3d.org/docs/manual/manual...re-Aliases
[-] The following 1 user says Thank You to derbymutt for this post:
  • rents1977
Reply
#5
Great thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)