I did try this originally but the final shader was a complete mess of interspersed declarations of functions constants and structs. If this isn't a problem I can easilly change it back .