I see some people have already experimented with the new shader stuff in Unity 4.0. Does anyone know whether we can now use a 65,000 instruction limit ?
By “use the limit”, you mean “surpass the limit”, or “stay under the limit”? (you could always stay under the limit… ;))
65 thousand instructions are the limit of shader model 3.0, which is the largest you can reach by using DirectX 9 technology.
With Unity 4.0 you can use DirectX 11, and thus shader model 4.0 or 5.0, with significantly higher limits.
Thank you, that’s what I was wondering. In Unity 3.4, the limit was only a few hundred instructions.
I don’t think so.
By default we compile shaders to shader model 2.0 (limit is 64 instructions in pixel shader IIRC), to make them run on widest range of hardware. You can compile into shader model 3.0 (#pragma target 3.0, and #pragma glsl), with SM3.0 limits. On DX11, you get SM4.0 5.0 limits.
All this isn’t really Unity version specific, has been like that for quite a while (well except DX11, which just shipped).
I was using “#pragma target 3.0” and yet I always ran into a 512 instruction limit even though my computer has pixel shader 4.0 capability.
That’s because shader model 3.0 has a 512 instruction slots limit: http://en.wikipedia.org/wiki/High_Level_Shader_Language
It can execute more instructions in the result (if some of the instructions are loops), but the actual “instruction slots” is 512.
But again, this isn’t really Unity version, or even Unity, specific. We compile shaders using standard shader compilers (Cg/HLSL), into standard shader models, and it’s the limitations of the compilers shader models that you run into.