Shader Replacement Problems .. :/

Hello!

I’m working on a bloom shader, where you bloom the screen based on a specific texture (not a treshold).

I have the blurring and blooming part working fine, but I just can’t get replacement shaders to work. I either only get the backdrop, or it looks like the replacement shader is not used.

I understood I can simply set
camera.SetReplacementShader(shader, null); and it will render all objects in the scene with the specified shader?
I tested this with a superbasic scene, just trying to replace the default shader with one that just draws red. But no success.

Do I need to setup a new camera to render the replacement shader, or can I use the existing one.

Any input would be greatly appreciated.

Thanks a lot.

You may need to include a game object in your scene with your custom shader assigned. I handle writing the shaders on the art side and I remember the programmer/developer having a simular issue with a custom shader I wrote. He said unity just saw the shader as an unused asset and didn’t include it in the build until he put a cube in one of the scenes with the shader assigned. Maybe you have the same issue

Hi Hjeldnes

Same problem here.

Here’s an article that includes a shader and code that demonstrates SetSceneViewShaderReplace actually not failing. Caveat is that only the shader provided works–if I use any other shader, even a shader that provably works, SetSceneViewShaderReplace will not accept it.
http://blogs.unity3d.com/2013/03/15/4-1-graphics-features/

The Unity code for shader replacement seems almost completely broken, or is so esoteric and finicky that no one understands why it doesn’t work (you “just get the backdrop”, meaning nothing is drawing). The documentation is nonexistent.

Some things in the Unity engine are just awful and because it’s closed-source you are completely shafted. It’s like a bike with training wheels permanently attached. And you can’t even fix it. This feature would be trivial using an open source game engine. Anyway at least you have that article that shows one feeble path in. Good luck

Thanks a lot guys! It really helps with a proper sample. :slight_smile: And I will try to include the game object in scene as well. I just put the task on hold, but I guess now I can give it another go.

kjetil