Hello,
I'm trying to write my first cgfx shader for Maya, and I have a question about what the upper limit is for number of texture maps I can access.
I am using Maya 2012, and in Maya's help it says its cgfx shader plugin supports Cg version 3.0.015. I have a Quadro FX 3800 graphics card, and I can compile and successfully run my shader with vertex profile gp4vp and fragment profile gp4fp. Looking at those profile specs, it seems I should be able to access 32 textures. Also, just as a test, I have added 32 sampler2D objects to my shader, and it compiles fine. (That is, I added them as global variables, but am not actually accessing them in the shader program code.) When I add 33 sampler2D objects, I get a compiler error saying I've passed the limit of sampler2D objects.
However, when I am actually accessing the textures in the code (by calling tex2D), it seems like I can only access 16 textures. When I have 17 sampler2D objects, the shader is compiling just fine (there are no compiler errors when I load the cgfx file in Maya), but the last texture that I access has no effect on the program. For example, if I order my code so that the last tex2D call that occurs is getting my diffuse color, the color is just returned as black no matter what is in the actual texture map. Again, this seems to be happening when I add more than 16 textures.
Is there an upper texture limit for Maya cgfx shaders imposed by something other than the graphics card? Is this expected behavior, or am I just doing something wrong?
Thank you for your help.
Replies
Max has this limit also, and yes, it's generally annoying, but considering DCCP viewports aren't exactly stellar in performance with RT shaders, it can get abit messy.
If I may ask, is there a reason to go above the 15/16 limit? I'm curious, maybe you can save a couple of slots by putting maps in the Alpha's of your texture or different channels instead.
I am hoping to use every channel of all the texture maps I can get to drive different attributes in the shader.
Thanks again!
I could be wrong, but last time I checked up shaders for Maya was about a year ago, so take what I say with a hint of salt.