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

Ambient light isn't used during rendering with CommandBuffer.DrawMeshInstanced

Discussion in 'Universal Render Pipeline' started by BaalEvan, Aug 10, 2019.

  1. BaalEvan

    BaalEvan

    Joined:
    Aug 13, 2013
    Posts:
    1
    Hey!

    I'm working on a project where we're trying to use the new ScriptableRenderPipeline alongside with LWRP.

    I prepared CustomRenderFeature with CustomRenderPass which takes data from scene and render objects using CommandBuffer.DrawMeshInstanced, but Ambient Light rendering is skipped for this objects:

    Screen -> Unity_2019-08-10_01-11-31.png

    This is how looks like Execute Method from CustomRenderPass:
    Code (CSharp):
    1.  
    2.     public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    3.     {
    4.         //Skip if no data on Scene
    5.         if (CustomRendererData.instance == null) return;
    6.  
    7.         var commandBuffer = CommandBufferPool.Get(_profilerTag);
    8.  
    9.         using (new ProfilingSample(commandBuffer, _profilerTag, (CustomSampler) null))
    10.         {
    11.             context.ExecuteCommandBuffer(commandBuffer);
    12.             commandBuffer.Clear();
    13.            
    14.             // GetMatrix4x4 from Vector3 List from Inspector
    15.             var matrixes = CustomRendererData.instance.matrix;
    16.  
    17.             commandBuffer.DrawMeshInstanced(CustomRendererData.instance.mesh, CustomRendererData.instance.subMeshIndex, CustomRendererData.instance.material, CustomRendererData.instance.shaderPass, matrixes, matrixes.Length);
    18.  
    19.             context.ExecuteCommandBuffer(commandBuffer);
    20.  
    21.             CommandBufferPool.Release(commandBuffer);
    22.         }
    23.     }
    Any idea what should i do to add AmbientLight to renderPass?

    Also i added test project as Attached File (2019.3.0a11) but problem is also in older versions (2019.1.8f)


    Thanks!
     

    Attached Files:

  2. SgtOkiDoki

    SgtOkiDoki

    Joined:
    Sep 7, 2016
    Posts:
    12
    Is there any update to this? I am having same exact issue.
    upload_2020-5-4_23-56-0.png
     
  3. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
  4. ggzerosum

    ggzerosum

    Joined:
    Sep 26, 2017
    Posts:
    31
    Did You found solution? I got same problem now and stuck...
     
  5. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    154
    I have exactly the same problem.
    @KEngelstoft, could you help us?
    Is it possible to render an object with command buffer without ambient missing?