Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

HDRP Layered Shader: Help me understand the poor documentation

Discussion in 'Shaders' started by Automoda, Jan 17, 2019.

  1. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    154
    https://github.com/Unity-Technologies/ScriptableRenderPipeline/wiki/LayeredMaterial

    Can anyone provide some insight here? I'm researching the Layered/Lit shader because I'm planning on adapting some awesome photogrammetry assets I've been creating to the Unity HDRP format. I need to know everything about this shader in order to make the best product I can and also ensure it is 'plug and play' ready. Unity seems to want to spend lots of time and money programming features, but wont spend 2 sentences explaining it. I've done what I can researching this on my own and I am left with some unsolved questions.

    For me, the github images in the link above are all broken. That doesn't help.

    Main Layer Influence [x] <-- This does nothing
    It even has a texture map that does nothing whether I try a noisy texture, black, or white when tested with a 3 layer shader. No visual change in the layering blends in color, normal, or smoothness when tested. What am I to make of this?



    (Regarding the extra layers 1,2&3 in the Layered/Lit shader quoted from the link at top)
    ----------------------- snip ---------------
    It is the same setting than the main layer except for Layering options



    Use Opacity map as Density map: Base color alpha channel is used as opacity threshold instead of standard opacity. *Me: What is a Density map? The Base layer's alpha does what now?

    The vertex color modulates the threshold. The effect depends if the vertex color mode is set to multiply or to add (See: 2-4 Inputs - Vertex color mode). *Me: The link says "Access Denied"

    0= full opacity, 1= full density. *Me: Density is a term I've never heard before in Unity shaders. What?

    Example with multiply mode (mask value is 1 by default): *Me: I like how by "1" they mean "255" in texture space. Regardless, I see the word "multiply mode" nowhere in the shader controls.

    *Me: Would be nice if any of my browsers could see it

    BaseColor influence: Variance of the current layer is add to main layer. *Me: What are they talking about? There's nothing in the shader options mentioning this or the other influences below. Perhaps it refers to the missing image?

    Normal influence: main layer Normal map is added.

    Heightmap influence: main layer Height map is added.

    -------------------- /snip -------------------
    I tried 2 versions of the color texture, one with no alpha, and one with a noisy gray-scale. No visual change.

    So in short, what is a density map and how does it apply to the layer blending, and why doesn't the "main layer influence" button do anything at all for my tests?

    I propose we rename this shader the "Magnet Shader" to honor the old meme "Magnets; How do they work?!"
     
    laurent-h likes this.
  2. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    41
    I can't get it to work corretly as well.

    How it looks :


    How the vertex colors are:

    So it does blend somehow, but It doesn't seem to respect the height map information at all. I'd like to fill the crevices first, like every other heigh-blending solution does:

     
  3. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    41
    Hey, I just had a chat the Documentation Team Lead, because I requested permission to that google document. So, the images are now no longer missing and the link to the google document is gone, because that was not intended.
    Maybe the images help to understand how the layered material works.
     
    Last edited: Feb 21, 2019
    Automoda likes this.
  4. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    41
    I got a bit further.



    https://imgur.com/a/ZAryaDz

    However I don't understand why I need a LayerMask Texture, If I just want to use height blend and vertex colors.
    Also it doesn't feel like it's really filling the crevices first, it's transparent then. When I paint more, it gets more opaque in the crevices, but already leaks to the stones surface. So maybe it's my height map, but I think it's just acting weird.
     
  5. Automoda

    Automoda

    Joined:
    Apr 27, 2017
    Posts:
    154
    Yeah I agree with the confusion. How does height interact with the mask?
     
  6. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    41
    I don't know. It doesn't work without the influence thing, but if you set vertex color to "additive" it will allow you to paint some things in. But the height of the heightmaps seems to be used for the parallax stuff, but not for real layer-blending..
     
  7. laurent-h

    laurent-h

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    74
    Lex4art and racarate like this.
  8. Sebastienl

    Sebastienl

    Unity Technologies

    Joined:
    Oct 2, 2015
    Posts:
    1
    The main layer influence is an option to allow a modification of layers 1, 2, 3 by the main layer. It is pretty useful to break the tile effect on generic material.

    We used it a lot with photogrammetry assets in Fontainebleau. With this option the repetitiveness of tileable materials is not visible.
    You can check it on this demo https://github.com/Unity-Technologies/FontainebleauDemo

    Basically the influence is done on all the surface but if you want to cancel the influence on some parts you can use the main influence mask in the layering option of the main layer.

    To see something with the influence, you have to set the other layers (1, 2, 3). In the layering options 3 influence handles appear to set the strength of the base color, the normal and the heightmap. The base color of the main layer is overlaid to the base color of the layer, the normal is blended and height is added.

    You can find a sample in the document link by Laurenth just above.
     
  9. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    880
    thank's
     
unityunity