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

Resolved Custom Render Pass - 'surfaceData' not completely initialized error

Discussion in 'High Definition Render Pipeline' started by tomekkie2, Jan 30, 2021.

  1. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    990
    I am trying to get to work these examples:

    https://github.com/alelievr/HDRP-Custom-Passes

    in Unity 2020.2.1f1 and HDRP 10.2.2.

    However I am getting this kind of errors on a number of DrawRenderers Custom Pass shaders:

    Shader error in '02_Selection/Objects': 'GetSurfaceAndBuiltinData': output parameter 'surfaceData' not completely initialized at line 75 (on d3d11)

    I have already searched forums, but could not find a fix anywhere.


     
    adamb70 likes this.
  2. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    990
    I have fixed it.
    This line was missing:
    ZERO_INITIALIZE(SurfaceData, surfaceData);
     
    yty, Xriuk, adamb70 and 2 others like this.
  3. wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    Joined:
    Feb 1, 2018
    Posts:
    33
    please add more detail,I have the same problem.Where to put the line of "ZERO_INITIALIZE"?
     
  4. tomekkie2

    tomekkie2

    Joined:
    Jul 6, 2012
    Posts:
    990
    Inside the shader used in DrawRenderersCustomPass:
    Code (shader):
    1.  
    2. ........  
    3. void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 viewDirection, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
    4. {
    5. ........
    6.              
    7.    // Write back the data to the output structures
    8.    ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
    9.    ZERO_INITIALIZE(SurfaceData, surfaceData);
    10.    surfaceData.color = _Color.rgb;
    11. }
    12. ........
    13.  
     
    id0 likes this.
  5. wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    wechat_os_Qy06eaOhICF9NcZoMWMLtv5cI

    Joined:
    Feb 1, 2018
    Posts:
    33
    Thanks,I sloved by using correct unity version.That's weird!!!