Material instructions changes between preview and applied.

I have a material that I am trying to optimize a bit.

First off, I wrote a material shader and I saw that the base pass shader (fragment shader) had 5 instructions. Then, after I hit apply it jumps up to 28 instructions.

Why does it jump like that?

Then I tried using custom UVs, but they have no affect on the material when applied.
What am I doing wrong? The custom UV 0 and 1 automatically become U and V respectively, I think.

Here is my material:

http://puu.sh/qs20V/8a2ad7f0c8.jpg

What coordinate index would that be then?

index 0 = default U

index 1 = default V

index 2 = custom UV0

index 3 = Custom UV1

Because I have been changing the number and it has not produced any sensible results.

Int he documentation the examples did not use a textureCoordinate node.

Custom UVs are two floats each so Customized UV0 will replace the first UV channel (I believe) and Customized UV1 will be set to the 2nd UV channel. However after setting them, you need to actually use them in the pixel shader. So drop in a Texture Coordinate node and set the appropriate channel, then plug it in when you need to actually use the coordinates.

This will ensure that the calculations for the UV’s are done in the vertex shader, then interpolated across to the pixel shader for you to use.

Index 0 = Default UV (Coordinate channel 0)

Index 1 = Coordinate channel 1

They are both float2’s so you have to feed it a float2 for the values to get set correctly. in your node graph above, your only feeding each a single float.

For Coordinate channel 0, it will automatically be used for texture samples, if you do not define the texture coordinate node to use a different channel. But any custom nodes that might be requiring access to texture coordinates, you’ll have to feed them urself.