Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Use SPIR-V decorator in Unity Shader

Discussion in 'Shaders' started by hfgciwcgs, Aug 13, 2023.

  1. hfgciwcgs

    hfgciwcgs

    Joined:
    Aug 10, 2023
    Posts:
    2
    I am using Vulkan in Unity, and I assuming the custom shaders are compiled to SPIR-V as an intermediate step. How can I go about using the FragSizeEXT SPIR-V decorator in the Unity shader to access the rectangular pixel footprint of a fragment invocation. The following screenshot was taken from Vulkan specification which describes FragSizeEXT.
    Screenshot 2023-08-13 at 8.40.45 AM.png
    The following can be done in GLSL to access the FragSize

    Code (CSharp):
    1. #version 450
    2. #extension GL_EXT_fragment_invocation_density : enable
    3. void main() {
    4.   ivec2 wh = gl_FragSizeEXT;
    5. }
    6.  
    I was wondering if there is any similar way to access the FragSizeEXT in the default HLSL/Cg setup in Unity while working with Vulkan.
     
    Last edited: Aug 14, 2023
  2. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    177
  3. hfgciwcgs

    hfgciwcgs

    Joined:
    Aug 10, 2023
    Posts:
    2