Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting the shaders from BRP to URP? #8

Open
ghost opened this issue Aug 28, 2020 · 17 comments
Open

Converting the shaders from BRP to URP? #8

ghost opened this issue Aug 28, 2020 · 17 comments

Comments

@ghost
Copy link

ghost commented Aug 28, 2020

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.

@jeffries7
Copy link

jeffries7 commented Sep 4, 2020

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.

@ghost
Copy link
Author

ghost commented Sep 6, 2020

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

@jeffries7
Copy link

jeffries7 commented Sep 16, 2020

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.

@joaoachando
Copy link

joaoachando commented Sep 18, 2020

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

@jeffries7
Copy link

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.

@joaoachando
Copy link

@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

@ghost
Copy link
Author

ghost commented Oct 30, 2020

@joaoachando but what is "context"? To me it says that there's no such thing as context

@joaoachando
Copy link

@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

@ghost
Copy link
Author

ghost commented Oct 30, 2020

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

@Trey-S
Copy link

Trey-S commented Feb 18, 2021

@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.

@trauty
Copy link

trauty commented Dec 18, 2021

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.

problem.mp4

@trauty
Copy link

trauty commented Dec 23, 2021

Fixed it by disabling post processing on portal cameras.

iamjcat added a commit to deus369/islandsthatfloat that referenced this issue Oct 3, 2022
I used Sebastian Lague's portal tutorial and reading this: SebLague/Portals#8
@ConstantinZpher
Copy link

ConstantinZpher commented Nov 1, 2023

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...

@trauty
Copy link

trauty commented Nov 1, 2023

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.

@ConstantinZpher
Copy link

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!

@Paul-1379
Copy link

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)

@Paul-1379
Copy link

I fix the bug by remove the screen space ambient occlusion of the URP renderer asset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants