Selecting shader based on video card

Hello, I’m trying to optimize some shaders that I would like to use depending on video card model.

For example:
Nvidia 8500 – use simple shader (diffuse)
Nvidia 9500 – use medium shader (cubemap + diffuse)
Nvidia 265 and up – use compelx shader (cubemap + rim light)

How can I determine what video card is in the machine, and select the shader to use depending on that?


While you can get specific makes and models of graphics card using SystemInfo.graphicsDeviceVendorID, SystemInfo.graphicsDeviceID, and SystemInfo.graphicsDeviceName, those are more typically used to exclude certain cards if an effect or shader doesn’t work on them. In general, what you ought to do is first attempt to put a fallback pass in your shader. Typically this just involves adding Fallback "Diffuse" after closing your SubShader. If you’re not comfortable mucking about with shaders, you should check against the card’s capabilities (also found in the SystemInfo class) rather than the card’s specific identifiers. Properties like graphicsDeviceVersion and graphicsShaderLevel should be particularly useful, but familiarize yourself with the documentation for the entire class (it’s not overly complex).