Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 2252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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();
}
}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
MessageBoxA( 0, (char * ) mErrBuffer-&gt;GetBufferPointer(), "Shader Error", 0 );
You would call it only in case of error.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!