DirectX 11 Frank Luna

Started by
8 comments, last by Oberon_Command 9 years ago
Hello.
I have a problem I have a book by Frank Luna.
When trying to debug it gives me such error error X3000: Illegal character in shader file
Please help!
Advertisement

This is probably due to the encoding of your shader file. Make sure they're ASCII; you don't want a byte-order mark at the start, the compiler won't handle it well.

The error says there's an illegal character at Line 1 Col 1. It may be an "invisible" character due to text encoding.

Try: delete the line and retype it.

ninja'd ph34r.png

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I rewrote from scratch and the problem persists

Yeah, I'm still using VS 2010 Express and creating a new text file produces one with a BOM-char. Probably applies to newer VS, too. I usually copy a working shader file from somewhere and use "Add Existing" in the Solution Explorer. If you already got some shader files added, you can use Copy-Paste in the Solution Explorer .

Edit: Disregard, Oberon_Command has a saner solution. Never occured to me :P

The problem might be an IDE setting, then. Try opening the file in a hex editor and looking at the first two bytes to make sure they aren't 0xFE 0xFF. If they are, open the file in Visual Studio again and go to File -> Advanced Save Options to change the encoding to US-ASCII. If that option isn't present, or if that doesn't work, try going File -> Save As, then instead of clicking on the "Save" button itself, click on the drop-down arrow beside it and select "Save with Encoding." That should allow you to change the encoding of the file.

I use a hex editor and do not have these characters

Were there any other strange characters there? Did you try the "Save with Encoding" idea? If that doesn't work, you could try recreating the file from scratch in Notepad or some other text editor.

Maybe make sure your line endings use the Windows convention instead of the UNIX convention, and that you have a newline at the end of the file?

This code:
cbuffer cbPerObject
{
float4x4 gWorldViewProj;
};
struct VertexIn
{
float3 PosL : POSITION;
float4 Color : COLOR;
};
struct VertexOut
{
float4 PosH : SV_POSITION;
float4 Color : COLOR;
};
VertexOut VS(VertexIn vin)
{
VertexOut vout;
// Transform to homogeneous clip space.
vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj);
// Just pass vertex color into the pixel shader.
vout.Color = vin.Color;
return vout;
}
float4 PS(VertexOut pin) : SV_Target
{
return pin.Color;
}
technique11 ColorTech
{
pass P0
{
SetVertexShader(CompileShader(vs_5_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_5_0, PS()));
}
}
Could you send me a working church color.fx file

No. There's nothing I can do on my end that you cannot do yourself. Both of us have Visual Studio. Both of us have access to Notepad, hex editors and other text editors. I'm not going to fix the problem for you when you can fix it yourself and learn something by doing so. If you already tried everything I suggested, and it didn't work, then I am out of ideas (some of which came from google searching the error message, which I assume you did yourself before posting) and therefore can't fix it for you anyway.

This topic is closed to new replies.

Advertisement