Unable to compile hlsl shaders after upgrading to Sharpdx 2.6.2

I have a C # project that uses SharpDX 2.5.0 and everything works fine. I have upgraded to the new stable release of SharpDX, 2.6.2. My project compiles fine but fails at runtime because it can't compile shaders. I am using this line of code:

var vertexShaderByteCode = ShaderBytecode.CompileFromFile(ShaderFileName, "Base_VS", "vs_4_0");

      

Whatever is the actual content of the shader file, it fails with the following error:

path/to/my/shader.hlsl(1,1): error X3000: Illegal character in shader file

      

I thought it had something to do with the UTF-8 encoding of the file, but trying different encodings didn't solve the problem. Has anyone else faced a similar issue or had a suggestion?

+3


source to share


2 answers


I finally found a solution. If anyone is facing the same situation, here is a workaround I found:



  • It was really a coding problem. For some reason, the format of my shader files is no longer compatible and for some reason, simply changing the encoding in Visual studio did not solve the problem. It seems that there was still an invisible character at the beginning of the file (BOM perhaps?).
  • Overwriting the file from scratch (from notepad) worked.
+3


source


This is old, but I answer anyway: The default encoding of new plain text text files is UTF-8 with BOM. This means that the first 3 characters of your file are: ï "¿
These characters are" illegal "



Source:
http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8

+5


source







All Articles