Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Forward+ Crashing Unity Editor (2022.3.4)

Discussion in 'Graphics for ECS' started by porrith_decoy, Sep 14, 2023.

  1. porrith_decoy

    porrith_decoy

    Joined:
    Mar 27, 2023
    Posts:
    2
    Hi

    I'm trying to write a custom lit shader for Forward+ Rendering for Entities Graphics. Currently when I try to implement the light loop using the macros for FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK


    #if USE_FORWARD_PLUS
    for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex)
    {
    FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK

    Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
    #ifdef _LIGHT_LAYERS
    if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
    #endif
    {
    lightingData.additionalLightsColor += CalculateBlinnPhong(light, inputData, surfaceData);
    }
    }
    #endif


    I crash the Editor (2022.3.4).


    Code (CSharp):
    1. ========== OUTPUTTING STACK TRACE ==================
    2.  
    3. 0x00007FF7BEEEDB2B (Unity) GfxDeviceD3D12Base::DrawBuffersCommon
    4. 0x00007FF7BEEECEBE (Unity) GfxDeviceD3D12Base::DrawBufferRanges
    5. 0x00007FF7BEEED140 (Unity) GfxDeviceD3D12Base::DrawBuffers
    6. 0x00007FF7C05242A2 (Unity) GfxDeviceWorker::RunCommand
    7. 0x00007FF7C0526CDB (Unity) GfxDeviceWorker::RunExt
    8. 0x00007FF7C0526DF8 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
    9. 0x00007FF7BEB69AF7 (Unity) Thread::RunThreadWrapper
    10. 0x00007FF9D479257D (KERNEL32) BaseThreadInitThunk
    11. 0x00007FF9D5CEAA68 (ntdll) RtlUserThreadStart
    12.  
    13. ========== END OF STACKTRACE ===========
    The default SimpleLit shader works fine with Forward+ Rendering and after reading the Entities Graphics docs, I'm not sure what I'm doing incorrectly when trying to implement a shader for Forward+ Rendering path.

    All properties have the UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT macro also.

    If I comment out lightingData.additionalLightsColor += CalculateBlinnPhong(light, inputData, surfaceData); the object is clickable in the hierarchy, but doesn't take the input from the point lights (which makes sense because I'm not doing any lighting calculation in the loop).

    However - I need to do the lighting calculation and make sure the object is clickable in the GameObject hierarchy. How can I solve this crash within the Editor & create a custom lit shader?
     
    Last edited: Sep 14, 2023
  2. porrith_decoy

    porrith_decoy

    Joined:
    Mar 27, 2023
    Posts:
    2
    Closing this - it was something silly. Did not see that the loop was infinite.