Custom Render Pass - 'surfaceData' not completely initialized error

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.

1 Like

I have fixed it.
This line was missing:
ZERO_INITIALIZE(SurfaceData, surfaceData);

5 Likes

please add more detail,I have the same problem.Where to put the line of “ZERO_INITIALIZE”?

Inside the shader used in DrawRenderersCustomPass:

........   
void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 viewDirection, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
........
              
   // Write back the data to the output structures
   ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
   ZERO_INITIALIZE(SurfaceData, surfaceData);
   surfaceData.color = _Color.rgb;
}
........
1 Like

Thanks,I sloved by using correct unity version.That’s weird!!!