The Data Flow of the Pixel Shader - Node to Shader
The nodes for the pixel shader:
The code for the Pixel Shader node. It goes further on in a similar manner, with if-else cases checking if the data should be sampled or not and setting the texture indices and rgba pick choices.
The output of the Sample Image node, and the input for the sample pins on the Pixel Shader node, are Vector2:s. The first value representing the index of the texture to sample and the second value representing the rgba pick choice.
This data is then set on an individual model instance and built into more compact data packs before being sent to the GPU.
This is how the data was packed. Albedo got special treatment since its raw input is a Vector3 while the others' raw input is one float. So first comes the raw input followed by one float where the first digit is the texture to sample from, the second digit is the rgba pick choice and the third digit is 1 or 0 depending if we should sample or take the raw input.
These are the data packs on the CPU (left) and GPU (right).
This is how the new pixel shader looked. The only difference really being the Evaluate-functions.
This is the function evaluating the albedo data pack on the shader side.
These are some helper functions for unpacking the individual digits of the data pack.
And finally, this is the function that does the sampling, after checking which texture to sample and what data to gather from it. It goes on further in a similar manner, checking the texture index in two more