Portals
Portals copied to clipboard
Converting the shaders from BRP to URP?
Does anyone know how to convert the Portal.shader and the Slice.shader in order to make it work with the Universal Render Pipeline? I'm new to everything, and basically I'm not being able to make either of this work.
Hope that someone has faced this issue and will be willing to share the acquired knowledge.
Does anyone know how to convert the Portal.shader and the Slice.shader in order to make it work with the Universal Render Pipeline? I'm new to everything, and basically I'm not being able to make either of this work.
Hope that someone has faced this issue and will be willing to share the acquired knowledge.
The portal shader works fine with URP. To get the portals working in URP you need to enable Post Processing on both Portal Cameras scripts.
Then code changes:
-
In PortalTravelers change line 56 from
foreach (var mat in renderer.materials)
toforeach (var mat in renderer.sharedMaterials)
. -
In MainCamera change line 11 from
void OnPreCull
tovoid LateUpdate
I'm still working on the slice shader but I've heard Brackeys has a working slide shader for HDRP/URP.
EDIT: I have noticed an odd visual glitch, if you walk through the portal backwards there is a screen flicker.
EDIT So, I've enabled post-processing on all cameras, and I'm actually being able to see through the portals, but now the portals inexplicably became vertical stripes (like they're able to get the height right, but not the width for any reason that is far from my comprehension) Do you know anything about it @jeffries7? -> https://drive.google.com/file/d/12XMdVidhfvOXO34zb5QXxUaYUfpEyrUx/view?usp=sharing
Oh my, is it really just that? I'm on it right now
EDIT: I've changed the line you said to change but it doesn't work: the portal now displays the skybox but not really the world on the other side of the portal. This in URP. In BRP it works just fine even with those edited lines
EDIT II: I forgot to enable post processing on both Portal and Cameras' scripts, and I don't know how to do it
How do you enable Post Processing on scripts?
I hope this helps with enabling post processing. You'll need to do it on both cameras.
I have yet another problem, in the portal script, portalcam.render() doesn't work anymore, it gives an error. I tried changing it according to this site but couldn't make it work... https://teofilobd.github.io/unity/shaders/urp/graphics/2020/05/18/From-Built-in-to-URP.html
Any thoughts?
EDIT: I moved the onPreCull function body to be called on RenderPipelineManager.beginCameraRendering
I have yet another problem, in the portal script, portalcam.render() doesn't work anymore, it gives an error. I tried changing it according to this site but couldn't make it work... https://teofilobd.github.io/unity/shaders/urp/graphics/2020/05/18/From-Built-in-to-URP.html
Any thoughts?
EDIT: I moved the onPreCull function body to be called on RenderPipelineManager.beginCameraRendering
I've not had any issues with Render()
within Portal.cs
.
The only changes I've made I listed above. Could possibly be your pipeline render settings, if you've changed any of those? I only tested with a default project.
@jeffries7 I did not, I did however figured out a way, I had to change portalcam.render to UniversalRenderPipeline.RenderSingleCamera(context, portalcam); and now it works flawlessly
@joaoachando but what is "context"? To me it says that there's no such thing as context
@FuranTheAwakened On the portal.cs change to public void Render (ScriptableRenderContext context) and send the context in the MainCamera script where you call the .Render function. The contex is received as a ScriptableRenderContext in the RenderPipelineManager.beginCameraRendering
Thank you @joaoachando I can't actually get what you mean by saying "and send the context in the MainCamera script where you call the.."
Now there's another problem: https://drive.google.com/file/d/12XMdVidhfvOXO34zb5QXxUaYUfpEyrUx/view?usp=sharing
@FuranTheAwakened you need to change the main camera script up a bit. "RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;" in start and instead of an onPreCull function you want to put all the portal logic in "void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera)". The other issue looks like you forgot to delete your history on the model.
Hello everyone, I have a problem. The exposure on my RenderTexture is kinda darker and hasn't got the right exposure(it is darker). I am using 'new RenderTexture (Screen.width, Screen.height, 0, RenderTextureFormat.DefaultHDR, RenderTextureReadWrite.Linear);' for the RenderTexture. Thanks in advance.
https://user-images.githubusercontent.com/72048877/146648481-d7ce324e-c99c-4651-999d-243194dc3808.mp4
Fixed it by disabling post processing on portal cameras.
Did everyone else also manage to fix the problem with the render texture being to dark? I am using URP and cannot disable post processing because it stops rendering scene objects... I am also using post processing on the main camera.
Edit: I managed to fix it but I'm still left with weird shadows and flickering...
Hi, this was nearly two years ago but the project where this system works with URP is on my Github Page(https://github.com/trauty/Why). I don't know if new Unity versions break it. Hopefully I could be of help.
Hi, this was nearly two years ago but the project where this system works with URP is on my Github Page(https://github.com/trauty/Why). I don't know if new Unity versions break it. Hopefully I could be of help.
Hey, I tired to clone your project but I'm running low on space and was able to clone it but there were many errors. I instead took a look at your code and the fix is identical to what I did, so I'm not sure it would fix my problem. I am using many lights and post processing effects which may be the source of the flicker and weird shadows. I've spent way to long trying to get it working so I appreciate your help but will probably not continue further... Thanks anyway!
Does anyone know how to convert the Portal.shader and the Slice.shader in order to make it work with the Universal Render Pipeline? I'm new to everything, and basically I'm not being able to make either of this work. Hope that someone has faced this issue and will be willing to share the acquired knowledge.
The portal shader works fine with URP. To get the portals working in URP you need to enable Post Processing on both Portal Cameras scripts.
Then code changes:
* In PortalTravelers change line 56 from `foreach (var mat in renderer.materials)` to `foreach (var mat in renderer.sharedMaterials)`. * In MainCamera change line 11 from `void OnPreCull` to `void LateUpdate`
I'm still working on the slice shader but I've heard Brackeys has a working slide shader for HDRP/URP.
EDIT: I have noticed an odd visual glitch, if you walk through the portal backwards there is a screen flicker.
I want to add the portals in unity urp 2022, the portal shader works but I have the same odd visual glitch, do you know how to fix it? (I do not need the slice shader)
I fix the bug by remove the screen space ambient occlusion of the URP renderer asset