   VERY basic HLSL shader
  hi guys,I started reading about shaders for a while and I've understood the very basics about them. I've also found some good examples/tutorials about "complex" shaders (bump map, lighting, phong, etc), but even if I can load (from .fx files) them (the pointer is != NULL, the file is loaded and compiled) using ID3DXEffect I can't see any result running my demo. I'd like some very BASIC (and useless) 2D shader (i.e changing the window background to some color) and some tips on how load/use it correctly.For example, taken from http://www.facewound.com/tutorials/shader1/sampler2D g_samSrcColor;float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0{    float4 Color;   Color = tex2D( g_samSrcColor, Tex.xy)*3;    return Color;}technique PostProcess{    pass p1    {   VertexShader = null;   PixelShader = compile ps_2_0 MyShader();    }}I can load and apply it but still nothing will happen.Can you help me?dav   
  What if you just output a direct color instead of looking up the texture?  This would eliminate any issues with the texture itself and make sure that you are sending your geometry in correctly.If you still don't get the shape that you expected out, then take a frame capture with PIX and analyze the frame.  You will be able to see the geometry being put into the pipeline for each draw call, and you should be able to figure out what is happening based on the pre and post vertex shader images of the geometry.   ;  thanks for the reply :)" What if you just output a direct color instead of looking up the texture? This would eliminate any issues with the texture itself and make sure that you are sending your geometry in correctly."my point is that I really don't know how to make shader, I've read a lot but never been able to load one. I'd like to have a running full screen shader OR a sprite shader (since I have ONLY 2d rendering routines right now for my project) and just play a lot with it, seeing the results. I just want some kind of... "base" shader and some tips on how load it. Right now I put it in a ID3DXEffect and call some ->Begin, ->BeginPass, etc, but since no tutorial about shaders teaches how to handle them with code, I guess I'm doing something terribly wrong.I need a master :)"then take a frame capture with PIX and analyze the frame" what is PIX? never heard about it before :)thanks for any reply!   ;  Take a look at my site, it has more than enough samples to show you how shaders work.http://applicachia.com/   ;  PIX is a great tool that comes with the directx sdk, you really should try it.Under Windows XP, All Programs > Microsoft DirectX SDK > DirectX Utilities > Pix for Windows.PIX on MSDN;//Set shader variablesTweenEffect->SetTechnique( "Tween" );TweenEffect->SetMatrix( "worldViewProj", &(WorldMatrix * View * Proj) );TweenEffect->SetMatrix( "world", &(WorldMatrix) );TweenEffect->SetFloat( "tweenFactor", TweenAmount );TweenEffect->SetTexture( "modelTexture", ModelTexture );UINT iPass, cPasses;TweenEffect->Begin(&cPasses, 0);for (iPass = 0; iPass < cPasses; iPass++){TweenEffect->BeginPass(iPass); ...TweenEffect->EndPass();}this was really interesting. you are passing to the shader some values which arefloat4x4 worldViewProj : WORLDVIEWPROJ;float4x4 world;float tweenFactor;texture modelTexture;in the shader (.fx) file.But I have three main questions:1) does ANY shader need a world matrix? I have NO one since my demo is totally 2d. If shaders need it, can I use a fake identity matrix to make it happy?2) you can "use" a shader and then draw primitives, so these primitives will have the shader effect on them, but what if I want a shader to apply to the entire screen? (make its color negative, add diffuse glow, etc)? Shall I pass something in this case too? If yes, what? I tried D3DDevice->GetRenderTarget() and similar methods but nothing worked.3) Should I use the "for" cicle to one-pass shaders too?These are some really nasty (and silly I think) question for me :PI need you help, masters :)   ;  1) You could try messing with the matrices that get sent into the shader and see what happens.  I haven't done 2d stuff for a very long time but I think that if you are doing 2d, you may not even need to send in the worldViewProj if the 2d matrix is already in screen space.2) The process of applying a shader to the entire scene is known as Post-Processing (there is an example on my site).  Basically what you do is render the entire scene into a texture, then render the texture to the screen with the shader applied to it.3) No the for loop isn't really needed there when it's just one loop, I just left it in there to match the other samples I wrote.   ;  thanks for the wonderful reply.I've downloaded your post-processing example. I can't actually load the .fx in there in my demo (don't know why still), so I'm still using the one I posted which is the only one I've found googling that I can load. Reading your code it seems I have to:a. render the scene in a textureb. apply the texture to some quadc  draw the quad while using the shaderI am able to set up some 3d graphics with FVF, making a quad etc... but is this really necessary? there is no other way to avoid/bypass using 3d geometry to apply shaders? If not, maybe I should switch to something different, such as apply a shader to a single texture, better to a sprite texture (something like http://www.gamedev.net/community/forums/topic.asp?topic_id=537928).It's not I can't manage such basic 3d concepts, but I'm looking for something more low-level to start with, avoiding vertex shaders for now, focusing on pixel ones. I mean... draw a sprite and make it totally RED. Is that possible?I'm so annoying, don't be hard on me pls :)dav