Search Unity

96 instructions limit on shader model 3 card?

Discussion in 'Shaders' started by cblarsen, Apr 19, 2008.

  1. cblarsen

    cblarsen

    Joined:
    Mar 10, 2007
    Posts:
    266
    I am trying to write (port) a Cg relief shader, also known as a "steep parallax" shader.

    This is going quite well, except that I am running into a 96 instructions limit (and a number of other limits, arithmetic instructions, dependent texture lookups, etc)

    but my graphics card is a Radeon X1900 XT, which I thought was shader model 3.0 compatible, so at least the 96 instructions limit shouldn't be there. Or?

    Going to sleep now. Hoping someone tells me to use a magic #define or something in the morning :)
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    At the moment Unity compiles shaders to shader model 2.0. Yeah, I know, we should add some option to compile them to SM3.0...
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    To SM2 ATI in that case?
    Because NVIDIA didn't have this "make SM2 worthless" restriction ... and the ATIs that Apple used with SM2 are all SM2a or SM2b aren't they?
    A possibility to define the shader version of the pass would be great :) (yes I know this comparision is crap but: Like TGEAs materials, which are the only good thing in that engine)
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    To raw, unextended, SM2.0 (aka "the thing that runs on Radeon 9550-RadeonX600, on Intel 915-945, and on some XGI/SiS/S3 cards"). GeForce FX is SM2.0a, and Radeon X700-X1200 is SM2.0b; both with some differences from raw SM2.0.

    Lifting instruction limit is quite easy to implement in Unity; the hard question is how to do SM3.0 equivalent in OpenGL (ARB vertex/fragment programs are not quite up to that level of functionality; and GLSL is still way too slow and way too unstable in real life).
     
  5. cblarsen

    cblarsen

    Joined:
    Mar 10, 2007
    Posts:
    266
    Thanks for the replies.

    Well, I'm new to this shader coding thing, so I don't really know what full SM3.0 compatibility would involve.
    The limitations I am running into are
    - max number of instructions per fragment program
    - max number of arithmetic instructions
    - max number of "texture indirections" per fragment program

    I have managed to some extent to hack my way around this:
    http://forum.unity3d.com/viewtopic.php?t=10927
    Which uses 12 passes.

    But to implement the full algorithm, I am going to have to use a rendertexture to transfer results of intermediate calculations between passes. I am guessing I can get down to 6-7 passes this way, but using such a big texture seems wasteful.