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 just want to load a simple *.fx file into my project to make a (pixel shader) effect.

But whenever I try to compile my project, I get the following error in visual studio Error List:

Errors compiling ..
ID3DXEffectCompiler: There were no techniques
ID3DXEffectCompiler: Compilation failed

I already searched on google and found many people with the same problem. And I realized that it was a problem of encoding. With the return lines unrecognized '\ n' .

I tried to copy and paste to notepad and save as with ASCII or UTF8 encoding. But the result is always the same.

Do you have an idea please ? Thanks a looot :-)

Here is my [.fx] file :

sampler BaseTexture : register(s0);
sampler MaskTexture : register(s1) 
    addressU = Clamp;
    addressV = Clamp;

//All of these variables are pixel values
//Feel free to replace with float2 variables
float MaskLocationX;
float MaskLocationY;
float MaskWidth;
float MaskHeight;
float BaseTextureLocationX;  //This is where your texture is to be drawn
float BaseTextureLocationY;  //texCoord is different, it is the current pixel
float BaseTextureWidth;
float BaseTextureHeight;

float4 main(float2 texCoord : TEXCOORD0) : COLOR0
    //We need to calculate where in terms of percentage to sample from the MaskTexture
    float maskPixelX = texCoord.x * BaseTextureWidth + BaseTextureLocationX;
    float maskPixelY = texCoord.y * BaseTextureHeight + BaseTextureLocationY;
    float2 maskCoord = float2((maskPixelX - MaskLocationX) / MaskWidth, (maskPixelY - MaskLocationY) / MaskHeight);
    float4 bitMask = tex2D(MaskTexture, maskCoord);

    float4 tex = tex2D(BaseTexture, texCoord);

    //It is a good idea to avoid conditional statements in a pixel shader if you can use math instead.
    return tex * (bitMask.a);
    //Alternate calculation to invert the mask, you could make this a parameter too if you wanted
    //return tex * (1.0 - bitMask.a);
share|improve this question
I'd say your problem is perfectly explained by the error message. There are no techniques in your file. You just have a pixel shader. How about adding a vertex shader, and a technique to bind them together? Check this article for more information. – Panda Pajama Oct 17 '13 at 7:49
Yes it was exactly that !! thank you so much it's work fine , Do you can put this on a answer please ? So i can close this post directly after – Mehdi Bugnard Oct 17 '13 at 8:29
up vote 2 down vote accepted

I'd say your problem is perfectly explained by the error message. There are no techniques in your file. You just have a pixel shader.

An effect contains one or more techniques, each one described by one or more passes, each one implemented by a vertex shader and a pixel shader.

Your file only contains a pixel shader, and that's what the compiler is complaining about. If you use an effect file, you should have at least one pixel shader, one vertex shader, and a technique with at least one pass that makes use of your shaders.

You can find more information on how to write an effects file at the official documentation.

share|improve this answer

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.