SHADER blending method for grass/sand/dirt

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

  1. Mitja Bonca

    Mitja Bonca Active Member

    Joined:
    Nov 18, 2014
    Messages:
    107
    Likes Received:
    35
    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 Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,491
    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 Active Member

    Joined:
    Nov 18, 2014
    Messages:
    107
    Likes Received:
    35
    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 Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,491
    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 Active Member

    Joined:
    Nov 18, 2014
    Messages:
    107
    Likes Received:
    35
    Location:
    Slovenia
    Will do so, thx. And will let you know about my progress.
     
  6. Gunnar333

    Gunnar333 Well-Known Member

    Joined:
    Aug 5, 2017
    Messages:
    321
    Likes Received:
    618
    Location:
    Germany
    Here is how I did the road - grass transition.

    [​IMG]

    I have attached the dds texture and preview images

    alpha.jpg diffuse.jpg

    You can see that the texture fades from street shadow over dirt to transparent.

    The asphalt_to_grass object is just a single side plane that sits about an inch above the "normal" grass object but the edge/vertexes at the asphalt side are connected to the road object.

    screenshot.jpg
     

    Attached Files:

    Cristian Capellino and luchian like this.
  7. RacingSounds

    RacingSounds New Member

    Joined:
    Jun 3, 2020
    Messages:
    3
    Likes Received:
    0
    Hi guys, maybe a dumb question but I've been at this for much too long. I've created a single plane on the grass/sand edge and Ive managed to find a nice looking blend, however somehow it keeps showing up horizontally instead of vertically along the grass/sand edge. I have tried several things, but somehow I can't figure it out. If needed I could post a pic of it! Thanks in advance if anyone has a thought on this

    Edit: I fixed it by redoing the UV mapping.

    Now I run into this problem where instead of a nice transition I get gravel on either side. I'm using the fresnel_nm shader, and some kunos materials just to test things out. Does anyone know how this can be fixed?
    [​IMG]
    [​IMG]
     
    Last edited: Jun 3, 2020
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice