Fixing RenderTextureDescriptor warning

Hi,

I’m having an issue using a temporary render texture as output of a camera.
It’s working fine, however it’s giving me this warning that I don’t know how to fix

In the render graph API, the output Render Texture must have a depth buffer. When you select a Render Texture in any camera’s Output Texture property, the Depth Stencil Format property of the texture must be set to a value other than None.
UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,UnityEngine.Object,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)

The RenderTextureDescriptor looks like this:

        RenderTextureDescriptor texDesc = new RenderTextureDescriptor();
        texDesc.width = 1024;
        texDesc.height = 1024;
        texDesc.colorFormat = RenderTextureFormat.ARGBHalf;
        texDesc.dimension = TextureDimension.Tex2D;
        texDesc.autoGenerateMips = false;
        texDesc.depthBufferBits = 0;
        texDesc.msaaSamples = 1;
        texDesc.volumeDepth = 2;

I tried:

  • setting the depthBufferBits to 16
  • adding texDesc.graphicsFormat = GraphicsFormat.R16G16B16A16_SNorm ( or other formats )
  • adding texDesc.depthStencilFormat = GraphicsFormat.D16_UNorm (or other formats)

But all of this results in this error and the script stops working.

AssertionException: Assertion failure. Value was False
Expected: True
UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at :0)
UnityEngine.Assertions.Assert.IsTrue (System.Boolean condition, System.String message) (at :0)
UnityEngine.Assertions.Assert.IsTrue (System.Boolean condition) (at :0)
UnityEngine.Rendering.Universal.RenderingUtils.ReAllocateHandleIfNeeded (UnityEngine.Rendering.RTHandle& handle, UnityEngine.RenderTextureDescriptor& descriptor, UnityEngine.FilterMode filterMode, UnityEngine.TextureWrapMode wrapMode, System.Int32 anisoLevel, System.Single mipMapBias, System.String name) (at ./Library/PackageCache/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs:824)
FluidSimulation.Simulate (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at Assets/FluidSimulation/Scripts/FluidSimulation.cs:137)
FluidSimulation.OnBeginCameraRendering (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at Assets/FluidSimulation/Scripts/FluidSimulation.cs:120)
UnityEngine.Rendering.RenderPipelineManager.BeginCameraRendering (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at :0)
UnityEngine.Rendering.RenderPipeline.BeginCameraRendering (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at :0)
UnityEngine.Rendering.Universal.UniversalRenderPipeline+CameraRenderingScope…ctor (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) (at ./Library/PackageCache/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs:361)
UnityEngine.Rendering.Universal.UniversalRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, System.Collections.Generic.List1[T] cameras) (at ./Library/PackageCache/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs:473) UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, System.Collections.Generic.List1[T] cameras) (at :0)
UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipelineAsset, System.IntPtr loopPtr, UnityEngine.Object renderRequest, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

What am I supposed to do to fix that warning?

Thanks!

Also tried the “Render Requests” workflow, getting same issue

https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@17.0/manual/User-Render-Requests.html

tex2d needs volumeDepth=1
what does the assert say exactly?
what exact Unity (patch) version are you using?

Hi,

yes, I actually set the volumeDepth to 1, was just trying things out.
the line that the asset refers in my code is just the function call where I to my things, but it happens simply as soon as I assign a temporary render target (with depthStencilFormat set) to a camera’s output.

basically that:

void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)
{
...
RenderingUtils.ReAllocateHandleIfNeeded(ref _CaptureHandle, texDesc, FilterMode.Bilinear, name: "Capture");
_DynamicEffectsCamera.targetTexture = _CaptureHandle;
...
}

Setting the temp render texture on the camera’s output without setting the depthStencilFormat works but create a warning every frame.

I’m using Unity 6.0.29

Thanks!