Search Unity

Question transparency for textures?

Discussion in 'World Building' started by Bluelattice5555, Jun 26, 2022.

  1. Bluelattice5555

    Bluelattice5555

    Joined:
    May 8, 2020
    Posts:
    34
    If I have grass as one texture that serves as the base, then a second texture that has flowers with wide spacing and alpha in-between them, there doesn't seem to be a way to actually have the alpha of the flower texture display correctly. Instead, the alpha channel just gets painted as white.

    I have tried: Opacity as Density, moving some of the sliders below in various ways, using a black & white image to better specify the alpha areas and use that as the Mask Map texture for the flower layer, and made aaabbbssooolutely sure my flowers png was indeed exporting the alpha channel.

    Am I going about this the wrong way? I read some other posts about this and a custom shader was posted in one of the threads, but I couldn't get that to work unfortunately, and I think it may have just been for painting pure transparency anyway.

    I am slowly gravitating toward just using my own shader for this, which I have already tested and know it works, but I currently would not be able to integrate it into the texture painting tools Terrain Tools comes with. I would have to do it all manually, which I would love to avoid if possible.

    I am open to ideas. Thanks.
     
  2. Bluelattice5555

    Bluelattice5555

    Joined:
    May 8, 2020
    Posts:
    34
    So, for anyone searching in the future, I have finally figured out a workable solution.

    • Make sure Opacity as Density is checked. This is in the panel where you paint the texture, under Layers, Layer Properties, Diffuse. Make sure you have the appropriate layer selected.
    • Set your brush strength to 1% (or 0.01 in the panel).

    At 100% strength, you get a ton of white on the alpha. At 10% it's faded, but still there. At 6%, it's hardly noticeable, but you'll get white outlining around your opaque parts of your texture. 1% is just right. You'd think it would only show the opaque part of your texture at 1% opacity, but that doesn't seem to be how it works. Strength essentially becomes a measure of how opaque your alpha channel is. I guess that's what "opacity as density" means. I had no clue what to make of "density" when I first saw this option, but this solves the problem.

    This has taken me hours to figure out. I looked up and tried like three different custom shaders people had written, had my nose in shader code, which I am unfamiliar with, tried to see if I could understand how the shaders were mapping the splatmaps to textures, and just everything. The answer was so simple though. Sheesh.
     
  3. Bluelattice5555

    Bluelattice5555

    Joined:
    May 8, 2020
    Posts:
    34
    Right, so I've run into another problem with this. As you can see here: https://imgur.com/a/2aQdJ78 this all works fine if your transparent image is mostly opaque, but fails if you have any sort of gradient in transparency. Any way around this?

    As shown in the image I linked, I can get this to work fine in a custom shader where the RGB's and Opacities are blended using Overwrite and Overlay, but Terrain Tools just displays the gradient circle as one big fat solid opaque circle.