Can one access channels from a texture (photoshop R,G,B channels) within a shader using Unity Shader language or would this need to be done in GC/GLSL?
asked Nov 23 '09 at 04:06 PM
Yes, you can.
If 'theTexture' is defined as a Sampler2D, you can do this:
and then read the r, g, b or a values using:
Read more about "Texture Samplers" on the nvidia cg tutorial, here: http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter03.html
You can also use 'swizzles' to pull out custom combinations of components of the color array (or other 3 or 4 item vector), eg:
For more information on swizzling, read here (about one third the way down the page): http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter05.html
answered Nov 23 '09 at 04:30 PM
For more on Unity, ShaderLab, Cg, GLSL and HLSL - please read:
And, of course, the docs.
answered Nov 23 '09 at 07:42 PM