+8
Fixed
cptSwing 4 months ago • updated by Joachim Holmér (Developer) 2 months ago 2

Heya,

I've built a Post-shader which takes a rendertexture rendered by a second camera, and overlays this texture (rendering only a certain layer) on the Main camera's Scene Color, after some blurring etc. Now, after having gotten it to work, the Scene Color node renders nothing but black.
What went wrong? I am using Unity 5.6.0f3 and Shader Forge v1.36.



(for shits and giggles I used the Scene UV's as a substitute, and it works)

My main camera is using the classic Graphics.Blit(source, destination, effect); line OnRenderImage.

Answer

Answer
Fixed

When making post effect shaders, you should be using a Texture2D node with an internal name of _MainTex, which will contain the colors previously rendered on the screen. Incidentally, this is *much* more optimized as well. I should really fix the post effect preset to reflect this :)



Though, I'm actually not sure why SceneColor doesn't work, but it is probably something you wouldn't want to use in a post shader regardless.



I've got the same + console error saying 

GL.End requires material.SetPass before!

on Unity 5.6

Answer
Fixed

When making post effect shaders, you should be using a Texture2D node with an internal name of _MainTex, which will contain the colors previously rendered on the screen. Incidentally, this is *much* more optimized as well. I should really fix the post effect preset to reflect this :)



Though, I'm actually not sure why SceneColor doesn't work, but it is probably something you wouldn't want to use in a post shader regardless.