Unity-Technologies / UniversalRenderingExamples

This project contains a collection of Custom Renderer examples. This will be updated as we refine the feature and add more options.
2.03k stars 412 forks source link

'CameraData.renderer' is inaccessible due to its protection level #39

Open skyburchard opened 3 years ago

skyburchard commented 3 years ago

I added KawaseBlur render feature to my project from the 3DCharacterUI project and unity complains:

'CameraData.renderer' is inaccessible due to its protection level

It seems as though the renderer is no longer accessible from "renderingData.cameraData" in the execute method of ScriptableRenderPass. It must be marked protected at some point in development. Is there a new way to access the renderer, or even better the "cameraColorTarget" from this Execute function? I am using Unity 2019.4.1.1f1 / UniversalRP 7.3.1

skyburchard commented 3 years ago

i figured out a solution. posting here for anyone who has the same issue.

bodardr commented 3 years ago

Thank you soooo much! I've been looking for this! Made my day :) I jumped to conclusions too fast. Sadly, this did not work for me :(. Luckily, I found a solution. To get the cameraColorTarget, you can instantiate a RenderTargetIdentifier with the _CameraColorTexture address (or _AfterPostProcessTexture if you need it) and this will give you access to the color target.

thickiran commented 3 years ago

~Thank you soooo much! I've been looking for this! Made my day :)~ I jumped to conclusions too fast. Sadly, this did not work for me :(. Luckily, I found a solution. To get the cameraColorTarget, you can instantiate a RenderTargetIdentifier with the _CameraColorTexture address (or _AfterPostProcessTexture if you need it) and this will give you access to the color target.

i have failed to do this, can you explain in detail

bodardr commented 3 years ago

In KawaseBlur.cs, line 64, the cameraColorTexture normally references the now internal renderer.

Instead, you can replace it by this : cameraColorTexture = new RenderTargetIdentifier("_CameraColorTexture");

In the Frame Debugger, you can see the _CameraColorTexture in action notably in the Copy Color Pass. If you want the full post-processed screeen, you can dig up the _AfterPostProcess texture as well.

Capture

Once you have a RenderTargetIdentifier, you can use Blit on the command buffer as a source or destination texture. Happy Post-Processing ;)

thickiran commented 3 years ago

In KawaseBlur.cs, line 64, the cameraColorTexture normally references the now internal renderer.

Instead, you can replace it by this : cameraColorTexture = new RenderTargetIdentifier("_CameraColorTexture");

In the Frame Debugger, you can see the _CameraColorTexture in action notably in the Copy Color Pass. If you want the full post-processed screeen, you can dig up the _AfterPostProcess texture as well.

Capture

Once you have a RenderTargetIdentifier, you can use Blit on the command buffer as a source or destination texture. Happy Post-Processing ;)

this solved the problem cheers mate