Sign in to follow this  

problem compiling .fx file!

Recommended Posts

Hi. When i call D3DXCreateEffectFromFile() it fails to compile the following HLSL code.. however when i set PixelShader=NULL; and comment out the OurFirstPixelShader() function it compiles... what could be the problem?? thanks in advance! struct VertexToPixel { float4 Position : POSITION; float2 TexCoords : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR; }; float4x4 xViewProjection; Texture xColoredTexture; sampler ColoredTextureSampler = sampler_state { texture = <xColoredTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;}; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.TexCoords = inTexCoords; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = tex2D(ColoredTextureSampler, PSIn.TexCoords); return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_1_1 SimplestVertexShader(); PixelShader = compile ps_1_1 OurFirstPixelShader(); } }

Share this post

Link to post
Share on other sites
First of all, try using [ source ] and [ / source ] (without the spaces) to add code to your posts, it will be more readable :)

that said, I don't see anything obviously wrong with your code ... You should try to check the documentation of D3DXCreateEffectFromFile. You'll notice the last parameter allow you to get the compilation error. It will give you a lot of information (the cause of the error, the line of the error, etc.)

For example, in my program, I have something like this :

ID3DXBuffer * pErrors = NULL;
ID3DXEffect * pEffect = NULL;
if (FAILED(D3DXCreateEffect(d3ddevice, fileName, NULL, NULL, 0, NULL, &pEffect, &pErrors)))
std::string msg;
if (pErrors) msg = (LPCSTR)pErrors->GetBufferPointer();
else msg = "Unknow Error while creating the effect";

MessageBox(NULL, msg.c_str(), "Shader::Init", MB_ICONERROR);


So that when the compilation fails, it displays a messagebox with the cause of the fail.

Share this post

Link to post
Share on other sites
Original post by rohith291991
i dunno what happened but it started working now!! all i did was change to retail dll in the control panel and change back to debug!! lol... thanks anyway!
Glad to hear you got it working again!

For future reference it will help your case a lot if you provide us with the debug runtime and HLSL compiler output in your initial post should you need help in the future [smile]


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this