Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to change part of the mesh color in LWRP

Discussion in 'Shader Graph' started by jintaenate, Aug 21, 2019.

  1. jintaenate

    jintaenate

    Joined:
    Sep 12, 2018
    Posts:
    17
    I learning to generate hexmap in below link

    https://catlikecoding.com/unity/tutorials/hex-map/part-1/

    According to algorithm which come from site, part of the mesh was changed via shader when click part of mesh.

    And i follow his algorithm, but i want to use LWRP and shader graph.

    Do anyone know how to change part of the mesh color in LWRP
     
  2. Levi-Burton

    Levi-Burton

    Joined:
    Jul 9, 2012
    Posts:
    10
    I fixed this by creating a new shader graph unlit shader and adding a Vertex Color node, then connecting that node to the shader output. Then set your hex mesh material to use this new shader graph. The vertex colors from the scripts will then get passed through your new shader via the Vertex Color node.

    I've attached images of how to achieve this and the result. Note that my result is using blending as described later on in the tutorial, so yours will not have the blended effect on the edges if you are that early in the tutorial. But it will all just work, at least so far it has for me.
     

    Attached Files:

    Last edited: Aug 26, 2019
    jintaenate likes this.
  3. Levi-Burton

    Levi-Burton

    Joined:
    Jul 9, 2012
    Posts:
    10
    Wanted to add -- unlit doesn't work as soon as elevation is introduced, for obvious reasons. To fix this, use a PBR shader graph for your hex mesh material. Now your materials should be lit from the scene.
     

    Attached Files:

    Last edited: Aug 26, 2019
    jintaenate likes this.
  4. jintaenate

    jintaenate

    Joined:
    Sep 12, 2018
    Posts:
    17
    Oh Sorry to late answer, This is work for me well. Thanks you :)