Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Converting Quick Outline to ECS

Discussion in 'Graphics for ECS' started by Kemorno, Mar 9, 2024.

  1. Kemorno

    Kemorno

    Joined:
    Apr 5, 2017
    Posts:
    20
    Hi! So i'm making an RTS game using ECS, and outlines are a big part of every RTS. I chose Quick Outline as my solution but it does not work natively on ECS Graphics. With that i changed the code of the
    Outline Fill.shader
    to fit the DOTS Instancing standards.
    But on the
    Outline Mask.shader
    theres no CGPROGRAM so i dont see how i could enable DOTS Instancing for it...
    From what i know, DOTS Instancing needs at least one property declared, but i can't really declare the property _ZTest before its use...
    source code: https://github.com/chrisnolet/Quick...kOutline/Resources/Shaders/OutlineMask.shader

    i'll copy the source code here for QoL:

    Code (CSharp):
    1. //
    2. //  OutlineMask.shader
    3. //  QuickOutline
    4. //
    5. //  Created by Chris Nolet on 2/21/18.
    6. //  Copyright © 2018 Chris Nolet. All rights reserved.
    7. //
    8.  
    9. Shader "Custom/Outline Mask" {
    10.   Properties {
    11.     [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 0
    12.   }
    13.  
    14.   SubShader {
    15.     Tags {
    16.       "Queue" = "Transparent+100"
    17.       "RenderType" = "Transparent"
    18.     }
    19.  
    20.     Pass {
    21.       Name "Mask"
    22.       Cull Off
    23.       ZTest [_ZTest]
    24.       ZWrite Off
    25.       ColorMask 0
    26.  
    27.       Stencil {
    28.         Ref 1
    29.         Pass Replace
    30.       }
    31.     }
    32.   }
    33. }