Search Unity

Shader apply the outline just to a part of the object

Discussion in 'Shaders' started by salvolannister, May 1, 2020.

  1. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50

    Attached Files:

  2. Wayward_Studios

    Wayward_Studios

    Joined:
    Dec 15, 2018
    Posts:
    23
    It is happening because how the ouline effect works is by scaling the object and inverting the culling, for this effect the second render of the object still needs to write into the z-buffer meaning it still gets depth sorted and objects in front of it still overlay the outline. I would suggest combining the object in a modelling software or just give both materials the outline shader. If you want the outline to eb drawn above all other objects you would probably need to switch to a different method or use the zwriting and rende rorder to draw it always on top.
     
  3. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    Wayward_Studios thank you for the reply. The object is already one, I used Blender to create different UV mapping and that's why It comes with two materials.
    I would like to understand how can I pass two materials to the shader, I wonder if I have to change something in the OutlineFiller pragma vert function but I am a noob with shaders.
    With switching to another method you mean changing completely the shader?
     
  4. Wayward_Studios

    Wayward_Studios

    Joined:
    Dec 15, 2018
    Posts:
    23
    So you want both objects to have the outline, then try adding the same shader to the other material, i don't know if i'm completely missing the problem here.
    With an alternative method i mean prost processing outlines and stuff like that, there are many ways you can draw outlines for different usecases.
     
  5. salvolannister

    salvolannister

    Joined:
    Jan 3, 2019
    Posts:
    50
    The object is one and it has two materials with different textures, what the script of this asset does is to add two more materials Outline fill and Outline Mask that has corresponding shaders called in the same way.
     

    Attached Files: