x


Replacement Shader Tags: How to Specify Them?

I've been looking around through the documentation for using "replacement shaders" and I can't seem to find any documentation on how the value of the tags are specified on the given game objects.

For example, a lot of tutorials I see use

camera.SetReplacementShader(replacementShader, "RenderType");

The shader in the material used have a bunch of sub shaders which define different behavior depending on the "RenderType" such as opaque, transparent, tree geometry. My question is where in the world are these tag values specified (opaque, transparent, tree, etc.)? I don't see them anywhere on the game objects in the examples at all.

So, how are these tag values specified? How do I make my own? What if I wanted to specify my own tag similar to a render pass, i.e. "render to texture" pass and then a "normal" pass which have different shader behavior?

I just want to do a very simple example first to see how this all works. My example just has a plane and 2 cameras. One camera renders the plane (all geometry really) from the view of one camera and renders this to a texture. The shader on the other camera then renders the texture made from the first camera. I know this example is dumb, but I will eventually make a shadow mapping algorithm out of it (without using built in shadows in Unity) so just bear with me.

more ▼

asked Mar 29 '12 at 06:26 PM

EncodedNybble gravatar image

EncodedNybble
0 1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The tag values are specified in the actual shader, like so:

SubShader { Tags { "RenderType"="TransparentCutout" }

The default Unity shaders already have them specified too.

PS: thanks for pointing out the "RenderType" parameter - I always tried it by putting in tag values, which obviously doesn't work. Thanks!

more ▼

answered Jul 21 '12 at 11:25 AM

Orion gravatar image

Orion
1 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x273
x269

asked: Mar 29 '12 at 06:26 PM

Seen: 657 times

Last Updated: Jul 21 '12 at 11:25 AM