Unity 5.x Shaders and Effects Cookbook by Alan Zucconi & Kenneth Lammers

Unity 5.x Shaders and Effects Cookbook by Alan Zucconi & Kenneth Lammers

Author:Alan Zucconi & Kenneth Lammers [Zucconi, Alan]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2016-02-25T23:00:00+00:00


There's more…

One can also access a fourth component from the vert color data. If you notice, the vertColor variable we declared in the Input struct is of the float4 type. This means that we are also passing the alpha value of the vertex colors. Knowing this, you can use it to your advantage for the purpose of storing a fourth vertex color to perform effects such as transparency or giving yourself one more mask to blend two textures. It's really up to you and your production to determine if you really need to use the fourth component, but it is worth mentioning here.

With Unity 5, we now have the ability to target shaders to DirectX 11. This is great, but it means that the compiling process for the shaders is now a bit pickier. This means that we need to include one more line of code to our shader to initialize the output of the vertex information properly. The following code shows what the vertex function code looks like, if you are using DirectX 11 in your shader:

void vert(inout appdata_full v, out Input o) { UNITY_INITIALIZE_OUTPUT(Input, o); o.vertColor = v.color; }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.