1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SHADER blending method for grass/sand/dirt

Discussion in 'Tracks' started by Mitja Bonca, Nov 29, 2014.

  1. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    But how to select some colors, which needs to be transparent, which have almost the same shade as the colors I need to show (not transparent)?
    Good example would be the mixed part of sand and grass which is just beside the tarmac?

    Example image:
    [​IMG]

    You can see some examples of tarmac and grass and whats in between, the mix of grass and sand.
    So lets say the starting image has part of tarmac and sand or brown soil. So what I need is to create half of sand or soil trandparent, but in not repetative way. How to make it so?
     
    Last edited: Nov 29, 2014
  2. luchian

    luchian Administrator ACM Racing Team ACM Club Driver

    Joined:
    Jun 3, 2014
    Likes Received:
    516
    Oh, ok. I was referring earlier to the specific skid marks example :).

    Back to you question, there are definitely more ways to do this, but here is one of them:
    The alpha acts like a mask, white=no transparency, black=full transparency. So in your texture, you will need to mask out the parts you wish to be transparent. Let's look at an example, from a conversion I am making.
    tex_diff.jpg tex_alpha.jpg

    First image, is how the diffuse texture looks like. On the 2nd image you can see its alpha channel, with all the areas that will be masked out.
    In-game, there is one mesh for the grass, one mesh for the sand. At this point there is no blending between them, as you can see bellow:
    grass2sand_noblend.jpg

    Now, if I add a supplementary mesh with a width defined by my previous "blend" texture (the one with the alpha), and use a shader like ksPerPixelAT, this is what I will get:
    grass2sand_blend.jpg

    So, what you actually see, is 3 meshes: 1 for sand top, 1 for grass bottom, 1 for belnding middle. I made an approximate division graph :).
    grass2sand_blend_div.jpg

    NOTE: again, this is just one way to do it.
     
    liquido and Mitja Bonca like this.
  3. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    This is exactly what I wanted to know, and a bit more, maybe I wasn`t clear enough.
    The main thing is how to create an alpha channel from this left image of yours for example? Do you do an additional image and then paste it into alpha channel of the diffuse image, or what you do?
    Because if only selecting with magic wand tool is not enough from a diffuse image.
     
  4. luchian

    luchian Administrator ACM Racing Team ACM Club Driver

    Joined:
    Jun 3, 2014
    Likes Received:
    516
    Just paint by hand in the alpha layer. As what you are looking to do is a "blending" zone, there is no correct or wrong shape :). Just paint in full white in the middle, as seen in image - this will assure it covers correctly and fully the border between your 2 other textures. Then add some gradually scattered brush strokes (use any brushes you have in PS) to obtain something similar to what you see in the example.
     
    PseT likes this.
  5. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    Will do so, thx. And will let you know about my progress.