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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Enable debug symbols for Shader Graph

Discussion in 'Shader Graph' started by J_Moller, Aug 8, 2022.

  1. J_Moller

    J_Moller

    Joined:
    Jan 24, 2012
    Posts:
    7
    Hi,

    I am wondering is there a way to enable the debug symbols for shaders generated with shadergraph? You know like adding the "#pragma enable_d3d11_debug_symbols" to the shader file. The way I had to do it now was to copy the generated shader and add the pragma manually. Then change the material to use the debug shader. Which is a lot of steps just to debug it.

    If there is no setting to do this. Can I intercept the generated shader and from code automatically add the pragma?

    Thanks
    Möller
     
  2. J_Moller

    J_Moller

    Joined:
    Jan 24, 2012
    Posts:
    7
    I managed to figure out a hackish way to do this. I can add the "#pragma enable_d3d11_debug_symbols" in the common.hlsl include, so it gets added to the generated shader.

    Code (CSharp):
    1. #ifdef _DEBUG_SYMBOLS
    2.     #pragma enable_d3d11_debug_symbols
    3. #endif
    Then add a keyword called _DEBUG_SYMBOLS to the shader graph I want debug symbols on.
    upload_2022-8-8_16-50-15.png

    Need to add the code in two common.hlsl because the local one will be replaced with the default when Unity detects changes in the file.
    \Editor\2022.2.0b1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.render-pipelines.core\ShaderLibrary\Common.hlsl
    \Library\PackageCache\com.unity.render-pipelines.core@14.0.3\ShaderLibrary\Common.hlsl
     
    tom_i, Un1ess and julian-moschuering like this.
  3. Un1ess

    Un1ess

    Joined:
    Oct 10, 2021
    Posts:
    1
    Wow!Thanks for your solution!