Do you have an example I can reproduce to see where it fails?
The faces almost never have a flat color, at best they have a soft gradient shading, and so that’s why you need to average a few samples to get a better result. The more samples the more accurate the result, and the first code currently does only get the color at the center of the face.
Also, note that the color of the backfaces will be wrong if you leave the code as it is now and remove the backface culling, as the color depends on the light and view angle. So in order to get the color of the backfaces you also need to change the viewing angle for those faces.
If you will use 2 or more fixed cameras, you can get the view vector from the camera direction.
However, the first code does not take into account the ambient and specular values, so it might produce wrong results as it is.
A sample scene would be useful to understand exactly what you want to do.
Regarding the second code, there is no way that I know to get the viewport image from a none active viewport, other than capturing the whole screen and cropping the viewport. I haven’t tried it, but I think with the SDK you can do it.
As far as learning MXS, this website, ScriptSpot and the MXS help are the best resources. It is also good to read things that are not of your interest, even if you don’t understand them. If you always eat apples you’ll never know how an orange tastes. If one day you decide to eat an orange, you may also one day invent the “apple & orange” juice.