The scriptable render pipeline how to support GrabPass?

I am write a custom SRP, but the game view can not deal with GrabPass. How can I fix it?
The unity report the error:

Shader properties can't be added to this global property sheet. Trying to add _Refraction (type 3 count 1)
UnityEngine.Experimental.Rendering.ScriptableRenderContext:Submit()
Game.MobileRenderPipeline:Render(ScriptableRenderContext, Camera[ ]) (at Assets/Game/Scripts/Rendering/MobileRenderPipeline.cs:224)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

BTW, I test grab pass on LightWeightRenderPipeline, it report the same error:

Shader properties can't be added to this global property sheet. Trying to add _Refraction (type 3 count 1)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

And the LightWeightRenderPipeline seems has compile error for Unity 2018.1.0b9.

Stumbled upon this thread because I wanted to learn more after seeing:

[quote]
Limitations
Grabpass doesn’t exist anymore.
[/quote]

Source: https://blogs.unity3d.com/2018/03/16/the-high-definition-render-pipeline-focused-on-visual-quality/

Beyond that, this thread is the only mention I could find of Grabpass in relation to the HDRP.

I wonder if the intention is just for users to explicitly write to render targets and sample those in shaders instead? Can anyone clarify?

We are testing an alternative in GrabPass in LWRP that will expose the Camera color texture after rendering opaques. That should cover majority of cases I believe.

6 Likes

@phil_lira , I am working on my own SRP and try to render the opaque to a render texture when there has any object after camera culled with the material that require the opaque texture. How can I check this, I don't want to render the opaque texture when there have no any renderer in the cull set require the grabpass.

[quote=“watsonsong”, post:5, topic: 694601]
@phil_lira , I am working on my own SRP and try to render the opaque to a render texture when there has any object after camera culled with the material that require the opaque texture. How can I check this, I don’t want to render the opaque texture when there have no any renderer in the cull set require the grabpass.
[/quote]
This might help:

https://discussions.unity.com/t/696276

Talks about 2 other ways to do same as grabpass

@
[quote=“watsonsong”, post:5, topic: 694601]
@phil_lira , I am working on my own SRP and try to render the opaque to a render texture when there has any object after camera culled with the material that require the opaque texture. How can I check this, I don’t want to render the opaque texture when there have no any renderer in the cull set require the grabpass.
[/quote]

When issuing a DrawRenderers command you will pass in a FilterRenderingSettings in which you can configure a renderQueueRange. You can configure your special grabpass material with a specific renderQueue and filter with that. Upon calling DrawRenderers it will sweep through all renderers that survived culling and other things like this filter settings.

https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Experimental.Rendering.ScriptableRenderContext.DrawRenderers.html

https://docs.unity3d.com/2018.1/Documentation/ScriptReference/Experimental.Rendering.FilterRenderersSettings.html

[quote=“phil_lira”, post:4, topic: 694601]
We are testing an alternative in GrabPass in LWRP that will expose the Camera color texture after rendering opaques. That should cover majority of cases I believe.
[/quote]

Any update on this?

[quote=“Kronnect”, post:8, topic: 694601]
Any update on this?
[/quote]

We have it in the LWRP branch on the SRP git but as it was put in too late in the 2018.1 beta cycle it won’t be making it into the LW packages just yet. Also we haven’t fully tested it in all scenarios and want to make sure it works well. But so far it’s pretty good and much more efficient than the legacy grabpass, a bit more limiting as it doesn’t contain transparent objects but the performance improvements more than make up for that downside.

1 Like

Thanks! Keep up the good work.

So is it implemented as a global "GrabPass" texture available after opaque objects have been rendered? What's the uniform name?

[quote=“Andre_Mcgrail”, post:9, topic: 694601]
We have it in the LWRP branch on the SRP git but as it was put in too late in the 2018.1 beta cycle it won’t be making it into the LW packages just yet. Also we haven’t fully tested it in all scenarios and want to make sure it works well. But so far it’s pretty good and much more efficient than the legacy grabpass, a bit more limiting as it doesn’t contain transparent objects but the performance improvements more than make up for that downside.
[/quote]
Wait is legacy GrabPass contain transparent objects?

[quote=“Kronnect”, post:10, topic: 694601]
So is it implemented as a global “GrabPass” texture available after opaque objects have been rendered? What’s the uniform name?
[/quote]

This went through a few hefty discussions but to align it best with the current naming of _CameraDepthTexture we settled for _CameraOpaqueTexture

[quote=“Reanimate_L”, post:11, topic: 694601]
Wait is legacy GrabPass contain transparent objects?
[/quote]

The legacy GrabPass would get it at the specific point your shader needed it, so this is why it had the potential of being quite inefficient as you could end up with multiple ones created at different times in the frames rendering. The way LW pipe handles it is we just create the one after opaque objects are rendered since this covers the majority of use cases(heat distortion, frosted glass, water refractions etc) and guarantees theres only one render texture reserved and one Blit performed.

7 Likes

[quote=“Andre_Mcgrail”, post:12, topic: 694601]
This went through a few hefty discussions but to align it best with the current naming of _CameraDepthTexture we settled for _CameraOpaqueTexture

The legacy GrabPass would get it at the specific point your shader needed it, so this is why it had the potential of being quite inefficient as you could end up with multiple ones created at different times in the frames rendering. The way LW pipe handles it is we just create the one after opaque objects are rendered since this covers the majority of use cases(heat distortion, frosted glass, water refractions etc) and guarantees theres only one render texture reserved and one Blit performed.
[/quote]

Just a suggestion for this as we’ve already implemented this in our local branch of SRP, but the ability to choose the grab pass to be downsampled could be helpful for performance and straight-forward to implement.

[quote=“equalsequals”, post:13, topic: 694601]
Just a suggestion for this as we’ve already implemented this in our local branch of SRP, but the ability to choose the grab pass to be downsampled could be helpful for performance and straight-forward to implement.
[/quote]

We have already done this actually in our implementation, you will have the option of no downsampling, 2xBilinear filter, 4xBox filter, 4xBilinear filter.

5 Likes

[quote=“Andre_Mcgrail”, post:14, topic: 694601]
We have already done this actually in our implementation, you will have the option of no downsampling, 2xBilinear filter, 4xBox filter, 4xBilinear filter.
[/quote]
Hi,
will we see this soon?

[quote=“TimNedvyga”, post:15, topic: 694601]
Hi,
will we see this soon?
[/quote]

In the coming weeks, we are hoping to get something out for Unite Berlin, but no promises :slight_smile:

[quote=“Andre_Mcgrail”, post:12, topic: 694601]
This went through a few hefty discussions but to align it best with the current naming of _CameraDepthTexture we settled for _CameraOpaqueTexture
[/quote]

Hi Andre,
Can _CameraOpaqueTexture be accessed via shader graph?
Also I’m writing a shader using this (via lightweight render pipeline) and I’m finding the _CameraOpaqueTexture is only grabbing geometry. Is it possible to grab what the camera sees? Such as sprites and particles?
I am in a 2D project at the moment.

[quote=“Twin-Stick”, post:17, topic: 694601]
Hi Andre,
Can _CameraOpaqueTexture be accessed via shader graph?
Also I’m writing a shader using this (via lightweight render pipeline) and I’m finding the _CameraOpaqueTexture is only grabbing geometry. Is it possible to grab what the camera sees? Such as sprites and particles?
I am in a 2D project at the moment.
[/quote]

Currently not, we are trying to decide how to support Pipeline specific features in a clean way(since _CameraOpaqueTexture does not exist in HDRP, or any Custom RP anyone makes)

As the way the _CameraOpaqueTexture is created it will only capture things in the Opaque pass, this is done for speed and usability, unfortunately sprites are rendered in the transparent pass. In saying that we are adding some very very cool functionality to the pipeline right now, which will give you the ability to add your own pass very easily at any point of the rendering to do what you want, I’m also helping out with documentation so I will make sure there is a good use case sample which is something like this.

1 Like

I notice _CameraOpaqueTexture is in the 2.0.0-preview changelog on Github but the latest version in the package manager is 1.1.4.

  1. Any ETA on this being released to preview on the package manager?
  2. Is it reasonably safe to grab the github version for a project that is still in the prototype stage?
  3. Is this backwards compatible to 2018.1.x or do we need to be using 2018.2?

Hi Andybak. 2.0.x is already available and has been for some time. It requires 2018.2 though. If you use 2018.2 it will just showup there for you in package manager.

1 Like