Search Unity

Vertex Painting in HDRP

Discussion in 'Shaders' started by pidele14, Dec 12, 2018.

  1. pidele14

    pidele14

    Joined:
    Dec 12, 2018
    Posts:
    1
    Hey guys,
    the game I am currently working on contains a lot of stone tiles.
    Now I want to paint moss on some parts of the floor to make it look overgrown and less repitative.
    For our last project we used Polybrushs Vertex Paint, but the new project is based on the new HD Render Pipeline in Unity 2018.3, so I cant use it there.
    Is there another plug in or technique I could use to paint textures (with normal maps) onto existing ones?

    Thanks for you help!

    upload_2018-12-12_11-18-31.png
    This is what I want to archieve.

    upload_2018-12-12_11-19-32.png
    This is what our scene looks like and where I want to add some moss.
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    287
    You can still use PolyBrush vertex paint and the new HD Layered Lit shader (with vertex colors as layer mask) to achieve this.
     
  3. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    335
    Could you please describe how to do this in detail? I've tried to use poly brush on mesh with HDRP layered lit shader, but it does not work => error: "it doesn't look like any of the materials on this object support vertex colors!"
    (Unity 2018.3.0f2, PolyBrush 0.9.15)
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    287
    @MS80 I guess that's because polybrush doesn't know that the HDRP layered shader can use the vertex colors. It didn't prevent me from painting on an object, and it worked with the HDRP/Layered Lit shader.
    Just don't forget to enable vertex colors in the material:
    upload_2019-1-7_12-28-55.png
     
  5. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    335
    Thanks Remy. I've tried that, after your message I gave it a second shot and it worked!?
     
  6. ChaosResolution

    ChaosResolution

    Joined:
    Jan 22, 2013
    Posts:
    51
    Hi @Remy_Unity - does vertex colour also work with Pro Builder in the HDRP? I've tried using the HDRP layered shader but applying colours doesn't seem to be having any effect. I'm not sure if I'm missing a step in the setup of the material though.

    Is there anything else which should be done other than setting the Vertex Color Mode to Multiply?
     
  7. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    287
    Vertex color is vertex color, there is no other magic trick here. If your mesh has vertex colors and you apply a layered material that should use it, it should work.
     
  8. VirtualWorldArcade

    VirtualWorldArcade

    Joined:
    Jun 29, 2017
    Posts:
    4
    We could not use the HDRP/Layered Lit shader as posted above; it gave us issues when trying to paint colors by adding/multiplying it with the colors present on the layers of the shader.

    We got probuilder vertex colors palette and painter to work with HDRP pipeline. Using shadergraph 4.6.0 preview on Unity 2018.3.0f1, we replicated the original vertex color shader from probuilder that's based on the standard shader.


    The original probuilder shader for vertex color stuff for standard shader pipeline is here. It was our guideline for the PBR shader in shadergraph seen below.

    Code (CSharp):
    1. Shader "ProBuilder/Standard Vertex Color" {
    2.     Properties {
    3.         _Color ("Color", Color) = (1,1,1,1)
    4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    6.         _Metallic ("Metallic", Range(0,1)) = 0.0
    7.     }
    8.     SubShader {
    9.         Tags { "RenderType"="Opaque" }
    10.         LOD 200
    11.  
    12.         CGPROGRAM
    13.         // Physically based Standard lighting model, and enable shadows on all light types
    14.         #pragma surface surf Standard fullforwardshadows
    15.  
    16.         // Use shader model 3.0 target, to get nicer looking lighting
    17.         #pragma target 3.0
    18.  
    19.         sampler2D _MainTex;
    20.  
    21.         struct Input {
    22.             float2 uv_MainTex;
    23.             float4 vertexColor : COLOR;
    24.         };
    25.  
    26.         half _Glossiness;
    27.         half _Metallic;
    28.         fixed4 _Color;
    29.  
    30.         // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
    31.         // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
    32.         // #pragma instancing_options assumeuniformscaling
    33.         UNITY_INSTANCING_BUFFER_START(Props)
    34.             // put more per-instance properties here
    35.         UNITY_INSTANCING_BUFFER_END(Props)
    36.  
    37.         void surf (Input IN, inout SurfaceOutputStandard o) {
    38.             // Albedo comes from a texture tinted by color
    39.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color * IN.vertexColor;
    40.             o.Albedo = c.rgb;
    41.             // Metallic and smoothness come from slider variables
    42.             o.Metallic = _Metallic;
    43.             o.Smoothness = _Glossiness;
    44.             o.Alpha = c.a;
    45.         }
    46.         ENDCG
    47.     }
    48.     FallBack "Standard"
    49. }
    upload_2019-1-16_19-9-21.png

    Picture of the shader and probuilder in action in HDRP

    upload_2019-1-16_19-11-58.png
     
    Last edited: Jan 17, 2019
    Stexe likes this.
  9. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    287
    @VirtualWorldArcade The layered lit shader in hdrp uses the vertex color for the layer blending, not for the global albedo like in your example.
     
  10. VirtualWorldArcade

    VirtualWorldArcade

    Joined:
    Jun 29, 2017
    Posts:
    4
    @Remy_Unity Yes, this is true, which is unlike the original vertex color shader that probuilder uses by default.

    @ChaosResolution
    Until Probuilder updates the vertex color shader to support HDRP, the example shader graph can be used as a work around since it replicates the original shader.
     
  11. Stexe

    Stexe

    Joined:
    Feb 2, 2014
    Posts:
    72
    Yeah, been running into this issue.

    I can convert each ProBuilder Material to an HDRP shader manually by copying the corresponding values over, but when I'm dealing with a large number of ProBuilder Materials it becomes super time intensive... surprised they don't have an HDRP version of ProBuilder stuff... really frustrating when you're trying to use ProBuilder with the FPS Sample project to create levels and everything is pink and won't convert automatically due to ProBuilder technically using "custom shaders."
     
  12. DawgVinci

    DawgVinci

    Joined:
    Feb 11, 2019
    Posts:
    8
    That should do the job
     

    Attached Files: