Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a couple of .fx files from a Shader-Based 2D Shadows example. I want to utilize the same kind of technique with XNA 4.0's Reach profile, which if I understand correctly needs to have HLSL 2.0 shaders. I am not familiar with shaders, so obviously I need to learn HLSL, but what I'm wondering right now is how to tell what shader code is 3.0 and what is 2.0, because I need to port those shaders to 2.0 and utilize them in my project. Can FX Composer be used to know such a thing?

A sub-question - Is it possible that they would not perform well when ported to 2.0? If I want to utilize a similar effect to what is presented in the link, do I need to bump my project up to the HiDef profile and use HLSL 3.0, or should I be able to get away with 2.0?

share|improve this question
up vote 3 down vote accepted

The main differences between SM 2.0 and 3.0 are the instruction/register limits and the presence of vertex texture fetch functions (for accessing texture data from the vertex shader). Wikipedia has some nice tables with the capabilities of the different shader models.

The shaders in your link do exactly what you are trying to achieve; some are compiled for SM 2.0 and the main one is for 3.0. You can see it clearly at the end of the FX files:

technique Distort
    pass P0
        VertexShader = compile vs_2_0 FullScreenVS();
        PixelShader  = compile ps_2_0 DistortPS();

technique DrawShadows
    pass P0
        VertexShader = compile vs_3_0 FullScreenVS();
        PixelShader  = compile ps_3_0 DrawShadowsPS();

Seeing that the DrawShadows functions are quite lenghty, and knowing that Catalin Zima is an experienced XNA programmer (and MVP too), I'd say that you can't just force the shader to an inferior SM, probably because it surpasses the instruction limit. So you would need to learn some HLSL and strip the shader of unwanted functionality to cram it into SM 2.0 limits.

share|improve this answer
Thanks for the pointers. This definitely gets me started. – Christopher Horenstein Nov 26 '10 at 18:29
Change the 3_0 to 2_0 and see what breaks :) – Jason Goemaat Jan 7 '11 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.