Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.