Blitting broken from 5.5 to 5.6 ?

Hi all,

I got a renderToTexture that i blit on a camera for my fog of war, it is a pretty simple process, and everything worked very well until i updated my unity yesterday from 5.5 ( dont remember wich version) to latest 5.6.1p1.

Now the blitting dont work at all, i can’t find what i need to change as i don’t know what changed in unity in the blitting.
Could someone tell me what changed in unity that broke my blitting, please ?
Or if nothing changed, has someone faced the same problem ?

thanks,

It would mean every Unity post-processes are broken. I’m using 5.6.0f, I’m not aware of p1 modifications but your issue isn’t in your shader instead ?

Right, that would mean every single image effect shader would be broken. You should use the frame debugger to try to investigate what’s not working. Also, a lot of people avoid upgrading between major versions because small things like this break. There’s no way to tell how or why they break, they just… break.

I am upgrading to 5.6.1f1 right now. Then i will check the shader, but again, did you hear about something that has changed in the shaders ?

No succes.

Seems like it is the shader, strangely it worked well before.

How would you guys, do this:

1 - I got a camera 1 rendering my game scene.
2 - I got a camera 2 rendering a character( for example).
3 - I want only the character to be rendered over the camera 1 image, wouthout his background.

Can’t make this simple thing anymore. Any hint ?

Thanks

  • Select camera 2
  • Change Clear Flags to depth only
  • Be sure the the Depth value of camera 2 is above camera 1.
  • Test without any target textures, camera 2 should render over camera 1 without the background.

@Fabian-Haquin
Thanks, it works great.
Next step (where the problem is): I used blitter because i needed the rendering of camera 2 ( initialy my FoW) to be blurred and have 50% opacity.

I am struggling, on that since i updated, if you find you help me a lot !

Looks like the shader has no effect at all on the blitting …

Ok, found a workaround, and made an example project to explain.
In the package you will find a simple scene that shows the “bugs”.

  • but, it uses 3 cameras, is it possible to use 2 ?
  • if i disable the 3rd camera named “Camera” the effect dont work ? is this a bug ?
  • doing this way i can’t use any other effect on the main camera, is it a bug too ?

3087600–232693–BlittingTest.unitypackage (50.7 KB)

Nobody on that ?
It is maybe harder than I tought.
I thought someone would be able to explain me what is going on.
Someone from the team maybe @Aras ?

in FowBlitter.cs

replace

    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(fowRenderTexture, destination);
    }

by

    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(fowRenderTexture, source, material);
        Graphics.Blit(source, destination);
    }

and delete your third camera.

You were ignoring what have been renderer before and copied fowRendererTexture ONLY to the screen.

It’s probably better that Main Camera have a higher Depth than CameraRenderer otherwise it will always blit the previous frame and not the current frame of your CameraRenderer

@Fabian-Haquin
First of all, thank you very much, the effect now works as i expected, i was struggling around this one so long, you saved me.

Now i got a few questions for information purpose if you dont mind:

  • Is the second blit doing the same as the removed third camera ?

  • I wanted to optimize the rendering, is blitting twice lighter than using the 3rd camera ?

  • I swaped the depth of the now two cameras, the result is the same, why is that ?

- Is the second blit doing the same as the removed third camera ?
I don’t know why it somehow worked with a third camera, maybe dark magic, maybe the third camera clear some stuff
- I wanted to optimize the rendering, is blitting twice lighter than using the 3rd camera ?
Yes, Blit cost nearly nothing, it copy a texture in another one completely GPU side and a gpu is built to do that very very well.
But it work only with RenderTexture as destination and you can’t access the pixels of a rendertexture in C#, that’s because it’s stored on the GPU and accessing GPU memory result in a bottleneck. The only way to modify a RenderTexture aside a blit is by using a Compute Shader.
- I swaped the depth of the now two cameras, the result is the same, why is that ?
You may notice a difference if you move the camera but it will depend of the framerate and it’s probably not noticeable above 60 FPS, try to enable triple VSync buffering for science.