Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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:
    13

    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:
    13
    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:
    13
    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:

unityunity