I have reviewed the Unity 6 Render Graph docs, and all the examples multiple times over. I have also created custom renderer features of my own.
However, there is something quite obtuse and unintuitive about the docs and I’m finding myself wasting many hours over the last week trying to do something quite basic with no luck at all.
I just want to render objects to a render texture without clearing the texture depth or color. Just like a camera would do in built in with clear off.
The docs for importing a texture read from a texture but don’t show how to write to one. So that was confusing x1. There also isn’t a simple example for using DrawRendererList confusing x2, but I figured that out on my own after way too many hours.
On a camera I can assign Render Texture, but there are no more clear flag options anymore. This texture will be read later by a Compute shader and/or post process. I just need to write a render texture without clearing… this should be a few lines of code and and afterthought - but here I am wrestling render features again.
RasterCommandBuffer is not compatible with CommandBuffer - so I can’t use CoreUtils.SetRenderTarget with it to set a target with clear flags. The upgrade docs talk about using ScriptableRenderer.SetRenderTarget, but it doesn’t exist anymore ( Unity - Manual: Upgrade to URP 17 (Unity 6 Preview) also its using the legacy syntax, not using the correct new format with RecordRenderGraph, etc)
I don’t see any methods providing clear flags options on any of the texture descriptor, RTHandle or TextureHandle classes either.
I’m just simply stuck, I’m losing sleep at this point so any help is greatly appreciated! What am I missing?
I’ve figured out that I can write to a render texture, the issue I have been having is related more to certain layers not working even though i have the camera cull mask set to “everything” and all layers enabled in my URP asset.
When I change the object to layers over a certain index they simply do not display.
I’ve got to the bottom of this finally. It seems to be a shortcoming of Render Graph’s CreateDrawingSettings → RendererListParams → CreateRendererList → Use RendererList → DrawRendererList chain. Starting with Create Drawing Settings.
A shader that uses Unity’s standard URP Unlit has no Light Mode, so when you use drawing using RenderingUtils.CreateDrawingSettings you must specify ShaderTagIDs. So if your object in the scene uses an unlit shader that wasn’t built custom to have a LightMode tag set, it cannot be replaced using CreateDrawingSettings (as of 6000.0.19f1). Creating your own unlit shader and setting a LightMode/Shader tag, you’ll be just fine - but using the built-in unlit shader or an unlit shader created with Shader Graph - which will have no LightMode tag - you cannot replace or redraw it in a renderer feature this way.
Hopefully this helps someone, because I just suspected I could use a simple unlit shader on a layer the normal camera could not see. Don’t make the same mistake or assume ShaderTagID.none works for replacing shaders with no tags.
Simply editing the generated shadergraph shader for a unlit shader and adding “LightMode”=“Unlit” then using “Unlit” is enough to make CreateDrawingSettings contain valid filters for the whole RenderList “chain of pain”.
We need:
- Alternate filter methods in RenderGraph for CreateDrawingSettings other than ShaderTagIDs so we can do this - perhaps even matching other types of tags, or a combination of layers+/rendering layers.
- Shader Graph support for light mode tags, which appears this was put on road map back in February
2 Likes