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 been looking for any examples for a long time, I cant get anything to work (from the examples). I have tried using vertex/pixel shaders, effects files, but they never have any effect on the rendering. I am using seemingly simple shaders (adding a value to the red color, or removing a color entirely). This has led me to believe that the code setting up/rendering the shader is not working correctly. Almost every example is for non sprite based rendering, but I dont know if that matters (I cant find any info on that).

A lot of forum posts/answers point to sites that no longer exist.

I want to get a proof of concept simple shader that does anything in particular, to the entire rendered screen.

The technology I am using is C++ Directx 9 Sprite interface. Any help/links in the right direction is appreciated.

Thanks in advanced!

share|improve this question

closed as unclear what you're asking by Byte56 Sep 15 '14 at 14:48

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Please narrow the scope of the question and specify exactly what your problem is. "Can't get anything to work" is very unclear. Just asking for examples isn't likely to help you if you "can't get anything to work". –  Byte56 Sep 15 '14 at 14:49
1  
The Direct3D 9 Sprite interface is implemented in D3DX9, which is deprecated and ancient at this point. Hence why it is difficult to find help with it. You should consider looking at DirectX Tool Kit for Direct3D 11 which includes the full source for a SpriteBatch class. –  Chuck Walbourn Sep 15 '14 at 19:33

1 Answer 1

This is the shader I use to push my pre-built HUD texture to the full display window. I compile it using the VS_4_0 and PS_4_0 profiles which I'm not sure will work right with DX9. The mesh I use with this shader is a simple quad ranging from (-1,-1,0) to (1,1,0) (note the zeros for Z -- there is no depth involved... the -1 to 1 range maps to the corners of the screen, and (0,0) is in the middle). If you do have a problem compiling for DX9 (VS3/PS3), the problem will most likely be with the SV_POSITION and SV_TARGET semantics. This shader is also meant to be used with alpha blending configured, but there is no reason It cant be used without blending.

struct VS_IN
{
    float4 pos : POSITION;
    float2 tex : TEXCOORD;
};

struct PS_IN
{
    float4 pos : SV_POSITION;
    float2 tex : TEXCOORD;
};

Texture2D picture;
SamplerState pictureSampler;

PS_IN VS(VS_IN input)
{
    PS_IN output = (PS_IN)0;

    output.pos = input.pos;
    output.tex = input.tex;

    return output;
}

float4 PS(PS_IN input) : SV_Target
{
    return picture.Sample(pictureSampler, input.tex);
}
share|improve this answer
    
DirectX 9 cannot use Shader Model 4.0, 4.1, 5.0, or the Feature Level 9.x profiles. –  Chuck Walbourn Sep 15 '14 at 19:31
    
That shader is simple enough to redo for 3.x just by getting rid of the 4.x+ semantics –  Ascendion Sep 16 '14 at 18:27

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