|
Hi 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?
(comments are locked)
|
|
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:
...etc 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
(comments are locked)
|
|
For more on Unity, ShaderLab, Cg, GLSL and HLSL - please read: Unity Answers - Can I use HLSL or GLSL shaders in Unity? And, of course, the docs.
(comments are locked)
|
