Introduction of Render Graph in the Universal Render Pipeline (URP)

Hi, thanks a lot for the insight

I tried the change and not get the same result unfortunately

This is with the Temporal AA as i had it, it hides the artifacts correctly

This is the artifacts without using the temporal AA

This is what i get if i dont do the 3 blits and do the direct assignment instead

This is the code in the pass i use to do the copy of the textures

	Pass //2 BLIT BACKGROUND
			{
				Name "ColorBlitPasss"
				HLSLPROGRAM
				#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
				//#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
				#include "BlitTAA.hlsl"//v0.2
				#pragma vertex Vert
				#pragma fragment Frag
				//
				float4 Frag(VaryingsB input) : SV_Target0
				{
					// this is needed so we account XR platform differences in how they handle texture arrays
					UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
					// sample the texture using the SAMPLE_TEXTURE2D_X_LOD
					float2 uv = input.texcoord.xy;
					half4 color = SAMPLE_TEXTURE2D_X_LOD(_BlitTexture, sampler_LinearRepeat, uv, _BlitMipLevel);
					// Inverts the sampled color
					//return half4(1, 1, 1, 1) - color;
					return color;
				}
				ENDHLSL
			}

Note that this code below worked in the pre-RenderGraph system

//Ping pong
RenderTexture temp2 = temp;
temp = temp1;
temp1 = temp2;

Hm, the native TAA or STP doesnā€™t help here?

It actually does, but there is a few cases where does not work or need to control the event it goes into. The issue is with the jitter that may conflict with other temporal AA implementations that are per module.

The Temporal AA i use is also much more stable then STP, so is more ideal, is same as the Unity Temporal on camera and little better

After some testing i realized that the system works even if use only the below blit alone than all three

Not sure why as it deviates from the non graph version, but seem to work and largely resolve the performance loss issue as well

   passName = "SAVE TEMP";
                using (var builder = renderGraph.AddRasterRenderPass<PassData>(passName, out var passData))
                {
                    //passData.src = resourceData.activeColorTexture; //SOURCE TEXTURE//
                    passData.src = resourceData.activeColorTexture;
                    desc.msaaSamples = 1; desc.depthBufferBits = 0;
                    //builder.UseTexture(passData.src, IBaseRenderGraphBuilder.AccessFlags.Read);
                   // builder.UseTexture(_handleTAA2, AccessFlags.Read);
                    builder.SetRenderAttachment(_handleTAA, 0, AccessFlags.Write);
                   // builder.AllowPassCulling(false);
                    passData.BlitMaterial = m_BlitMaterial;
                  //  builder.AllowGlobalStateModification(true);
                    builder.SetRenderFunc((PassData data, RasterGraphContext context) =>
                        ExecuteBlitPass(data, context, 1, passData.src));
                }

I have now managed to get it all working fully native in RenderGraph and seems can be super fast after all the fixes :slight_smile:

Many thanks for the help and insight on the random write methods through RenderGraph, it is very appreciated.

6 Likes

This is great to hear! Thanks that you kept pushing and for the feedback. It is encouraging that this thread could help and that the transition has positive results.

Have a good week everyone!

1 Like

Congratulations @nasos_333! Glad to hear that you managed to make it work in the end :slight_smile:

1 Like

I have to say i was surprised by how it all worked directly after realized what had to do to incorporate the 3D texture rendering into the RenderGraph, it is really very powerful and much easier as well because of no need to handle the texture clearing.

And is same performant or more now that perfected all work, which is amazing :slight_smile:

Thanks again for the guidance on this, really helped a lot find the right way to go about addressing the issue :slight_smile:

4 Likes

Iā€™m trying to understand how rendergraph works by readingcodes From URP Samples(like DLC in packages),something weird happened.
In rendergraph sample - FramebufferFetch which shows how to get activeColorTexture B channel and copy it backļ¼Œto introduce how fetch works.
first step works wellļ¼Œbut in copypass ļ¼Œthe _UnityFBInput0 might changed to depth texture but not our resultsā€¦
I try to change copy pass to Blitpass ļ¼Œexcept for losing fetch, it works fine.(Better to write another fetchPass like sample does,but Isnā€™t that what copypass does?).
The same problem occurred with sample-copyRenderFeature, which use addcopypass,sometimes it will change to depth,Sometimes works wellā€¦
my version is 6000.23 and use urp template project.


how copypass actually worksļ¼Ÿdepth texture is error fallback?
Itā€™s really frustrating to have an error in the sample(because Iā€™m wondering if Iā€™ve got something wrong until I find out why)

what graphics api are you using? there is currently an issue with the framebuffer fetch fallback on directX. On graphics APIs that FBF is not natively supported, we automatically handle that using a regular texture sample but there are some issues with that currently. Does it work if you switch to vulkan? the fix should land this week, and can be available in patch release in a few weeks.

Iā€™m using default DX11, unity6-0.23, URP17.0.3ļ¼ŒURP template project, PC-RPAsset, RTX2060.The code is FrameBufferFetchRenderFeature in RenderGraph of URPSample

After taking your advice I switched graphics APIs to DX12 and vulkan also wrongļ¼ŒIt doesnā€™t look like the graphics API is causing the problem.
I tried to tweak some settings and found some issues-
The first is that in RPAsset if you set Opaque DownSampling to none (or just turn off the OpaqueTexture setting) the effect is correct.
Then I tried to modify the injection queue for the pass which original code was BeforeRenderingTransparent (450 in enum)
Environmentļ¼š DX11 DX12 vulkan cause same error(not your guys fault lol), PCAsset

First, the Fallback with the red Depth is not affected by the pipeline turning off the DepthTexture.
At 300-399, regardless of whether OpaqueTexture is on or not, the Scene view is correct, and the Game view (MainCamera) is still Depth.
At 450-499, the effect is correct with OpaqueTexture off, but error when it is on,in both Scene and Game.
Itā€™s working fine at other ranges.

I noticed that when I turn on OpaqueTexture there is an extra CopyColor Pass, is the problem related to this pass? If itā€™s not related to the graphics API, could it be a problem somewhere in the code? Hope this helps.
Anyway, I can get it working correctly now, thanks for the suggestion~. :slight_smile:

ah missed that you were using a depthTexture. Framebuffer fetch (that is used in the copyPass) doesnā€™t work with a depth format. In most cases the depth copy is a color format, but not always (for example when using a prepass). You need to use BlitPass instead.