-
Notifications
You must be signed in to change notification settings - Fork 12
Workaround for URP's 2D Renderer RenderPasses #44
Comments
Updated the code snippet for 9.0.0-preview.35. |
So I'm having some difficulty with 9.0.0-preview.35 since the render pass is likely going to be a mismatched sample. The renderpass will still work, but it's not ideal for it to continuously throw an error every frame due to mismatched sampling. I'll need to look at some updated examples. Highly recommended to stick with version 9.0.0-preview.14. |
https://issuetracker.unity3d.com/issues/urp-unreleased-version-profiler-spams-errors-when-enabled-in-playmode Okay this seems like the culprit. |
Hi, is there a workaround for this these days? |
Which version of URP are you on? I believe I have to update the snippet if you are on URP 10. |
Yes, i'm at version 10.2 |
Kk, here's the snippet for version 10: In Renderer2D.cs in the same function: Setup(ScriptableRenderContext context, ref RenderingData renderingData)
{
...
for (int i = 0; i < rendererFeatures.Count; i++)
{
if (rendererFeatures[i].isActive)
{
rendererFeatures[i].AddRenderPasses(this, ref renderingData);
}
}
} |
@psuong |
Let me check - I wouldn't know from the top of my head. Have you also checked the Unity forums? One of their engineers might be able to respond with more specific details. |
Hi!, Yes I did post the same issue on the Unity forum but Im still waiting for an anwser. |
What do you need the layer filtering for regarding UGUIDOTS? I'm curious to see what the use case is. |
Im trying to reproduce this field of view exemple which is working fine with the forward Renderer. See exemple in here : https://youtu.be/CSeUMTaNFYk?t=1148 But I cant do it with the URP 2D Renderer since its missing Layer Filtering and Renderer Feature. |
This looks like a general feature request for URP's 2D workflow more than a feature for UGUIDOTS. As for layering support in UGUIDOTS per canvas, I will need to look at how UGUI handles this feature, before migrating it to a DOTS compatible way. I don't know when I can support this, but feel free to fork this repository to contribute if you would like to work on this feature. |
Its not my field of expertise, so I hope that Unity will come with an update of the URP 2D renderer. |
One unity developer told me that renderer features for 2d renderer was already in development, so I expect it to be available in ~2months |
Amazing ! Thanks for your reply ! |
Ok so first of all thanks for this! This workaround works perfectly for me, but the only issue I am having now, and I think many here will have or did have, is that the changes I make to the 2DRenderer script will be reset when I reopen the project because all of the Unity packages get imported again or something along those lines. I did a lot of looking around for some solutions, and it seems like there are 3 main solutions: 1.) Copy the package onto your machine, and then import from disk inside of the package manager. The main issue with this though, is that if I am working in a team and I need my team members to pull the project, they will not be able to get the 2DRenderer script with my changes because it is only stored locally on my machine, so this is a no go for me. 2.) Create a github repo with the package in it, give all of my team members access to that repo, and then import the package via a git URL in the package manager. I have not tried this, but I am scared this one might not work for my needs either because the versioning system we are using is Unity Collab, not github. 3.) This one is the most attractive one to me: creating my own rendering script that basically contains the same exact code as 2DRenderer, but it is called something like Custom2DRenderer, and this script contains the code snippet mentioned here. Like 2DRenderer, it extends from ScriptableRenderer, but since it will be in my Assets folder, then the changes I make to it should not get erased and all of my team members should still get this updated script as a result. This is the current method I have been trying, writing up this script for it: https://github.com/DiegoAvena/Custom2DRenderer/blob/master/Custom2DRenderer.cs Unfortunately, I have so far been unable to make my own version of 2DRenderer with these required changes due to errors like: Line10 Render2DLightingPass** is inaccessible due to its protection level Line 26 Renderer2DData does not contain a definition for postProcessData and no accessible extension method postProcessData accepting a first argument of type Renderer2DData could be found (are you missing a using directive or assembly reference?) And a ton more errors. These errors confuse me though because again, all of the code in this class is basically a copy and paste from 2DRenderer, which does not get these errors. Has anyone here been able to write their own version of Renderer2D? |
This looks like a general issue, please keep this relevant to UGUIDOTS. What is it that you are trying to do with the 2DRenderer that allows you to utilize UGUIDOTS? |
Sorry, I came across this after looking for solutions to allowing for custom post processing effects to be used in conjunction with URP while using the Renderer2D, and this method did work out for me except that my changes kept getting overriden since it required me to edit a Unity package script. I have since figured out another way of doing custom post processing effects with URP and the Renderer2D, so disregard this (feel free to delete these comments as they might be irrelevant now that you point it out...). |
For some reason, Unity keeps telling me |
No idea, the Orthographic Render Pass in UGUIDOTS doesn't manipulate cameraColorTargets at all. It just plays back a command buffer to draw a mesh. I also have not been updating and maintaining UGUIDOTS in well over a year to explore different UI solutions that fit Unity DOTS. That said, URP 12+ supports Scriptable Render Passes in 2D, so I'm closing this issue. |
With Unity's 2D URP out in preview, I thought I'd highlight a way to inject scriptable render features into their 2DRenderer. Unity will support it down the line, but if anyone is intending to use this for their 2D needs, you can do the following:
Setup(ScriptableRenderContext ctx, ref RenderingData renderingData)
function.For URP version 10 see the comment below
This will allow you to initialize all render passes
Click on a ScriptableObject instance for the 2D Renderer and switch the inspector from normal -> debug view by right clicking the inspector tab.
On your
FowardRenderer
asset, click the drop down menu and drag theOrthographic Render Feature
scriptable into theRenderer Features
field.Once Unity officially supports custom render passes in the 2D Renderer I'll close this issue, but this should be a decent workaround for the time being. :)
The text was updated successfully, but these errors were encountered: