Effect compiles and works in FX Composer, but not in engine

Started by
2 comments, last by kubera 12 years, 1 month ago
I wrote a pretty simple box blur shader, which compiles and works just fine in FX Composer, but is failing to CreateFromFile in my engine.
Any ideas?

Edit: Using Direct3D9


if(D3DXCreateEffectFromFile(d3dDevice, effectFiles.c_str(), 0, 0, D3DXSHADER_DEBUG, 0, &loadEffect->effect, 0) != D3D_OK)
ErrorMessenger::ReportMessage("Failed to create effect from file!", __FILE__, __LINE__);



//PPBlur.fx is an effect containing different ways to achieve a blur on the scene handed to it using a Full Screen Quad for post processing.

float blurIntensity = 1.0f;

float texelSizeU;
float texelSizeV;

texture scene;

sampler Scene =
sampler_state
{
Texture = <scene>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

void vsBoxBlur(float4 iPos : POSITION0,
float2 iUV : TEXCOORD0,
out float4 oPos : POSITION0,
out float2 oUV : TEXCOORD0)
{
oPos = iPos;
oUV = iUV;
}

void psBoxBlur(float2 iUV : TEXCOORD0,
out float4 oColor : COLOR0)
{
texelSizeU *= blurIntensity;
texelSizeV *= blurIntensity;

float4 avgColor = float4(0.0f, 0.0f, 0.0f, 1.0f);

//Row above
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y - texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x, iUV.y - texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y - texelSizeV));

//Row at
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y));
avgColor += tex2D(Scene, iUV);
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y));

//Row below
avgColor += tex2D(Scene, float2(iUV.x - texelSizeU, iUV.y + texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x, iUV.y + texelSizeV));
avgColor += tex2D(Scene, float2(iUV.x + texelSizeU, iUV.y + texelSizeV));

avgColor /= 9;

oColor = avgColor;
}

technique BoxBlur
{
pass p0
{
VertexShader = compile vs_3_0 vsBoxBlur();
PixelShader = compile ps_3_0 psBoxBlur();
}
}
Advertisement

  1. You would check: __out LPD3DXBUFFER *ppCompilationErrors
  2. You would consider using macro SUCCEEDED( x )
  3. Please, check the result of function


I hope, it would help smile.png
I have looked into the compilation error buffer, but I dont understand how you get an error message out of it. It is just a d3dxbuffer, nothing human readable as far as an error goes.
MessageBoxA( 0, (char * ) mErrBuffer-&gt;GetBufferPointer(), "Shader Error", 0 );
You would call it only in case of error.

This topic is closed to new replies.

Advertisement