Activate/Enable a Shader

how would I simply toggle a shader on or off? Are their any precoded shaders that I could add to make an object semi-transparent?

I think you need to clarify what you want to do. Neither this question nor http://answers.unity3d.com/questions/44224 makes any sense to me, as it is. Perhaps if you explain the intent, instead of what theories you have about execution, we can help you.

2 Answers

2

Not sure what you mean by on/off. You can enable/disable the renderer, and it won't render. Or the entire object. Or you can replace the material with another one.

Most shaders have a Main Color, and that main color includes and alpha channel, so put that at like halfway. You can also use textures with alpha channels, I like PNG myself.

Why do you like PNG? Do you use Fireworks? I've found them useless from Photoshop, but okay from Illustrator. I ask about Fireworks, because I've heard that it gives you control of the PNG's alpha channel, unlike Photoshop, where you have to rely on layered transparency.

As opposed to Tiff or PSD or any of that. It's an open web standard, I like that. I use Paint Shop Pro which is much easier than Photoshop or Gimp and has very good transparency control.

Alpha does not necessarily equate to transparency. Does Paint Shop Pro allow you to create PNGs where the alpha has nothing to do with transparency? Photoshop doesn't. I also think it's a pain to not use PSDs directly.

Right, but generally, and in the cases I've seen it always is. I haven't played with other types of alpha. What else would it be used for in Unity? PSP allows for multiple alpha channels per image, I suppose you could use one for transparency and one for specular(?). I think PNG only allows one alpha. Most viewers assume it's for transparency. But you can author it for whatever you like of course.

I'm not sure I fully understand what you mean toggle shader. You can't just turn a shader off because that tells Unity how to render the object.

  1. You could simply disable the renderer. That would turn off the shader and more :).

  2. You could use a Camera.RenderWithShader() and Camera.SetReplacementShader() which are both described here.

  3. You could change materials or change the materials properties. `material.shader = Shader.Find("YourShader");`