错误X3000:着色器文件中的非法字符 [英] error X3000: Illegal character in shader file

查看:362
本文介绍了错误X3000:着色器文件中的非法字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从SO粘贴了一行着色器代码,现在我的项目拒绝了。




  • 我删除了污染的行


  • 我已经按照

    解决方案

    这是一个编码问题。当我粘贴代码行时,它以某种方式使我的编译器将每个文本文件都视为UNICODE而不是ASCII。这引起了问题。

    解决方案是在Visual Studio中打开着色器文件,然后转到

    文件->另存为->使用编码保存,然后然后选择正确的格式并重建解决方案。




    I pasted a line of shader code from SO and now my project refuses to work.

    • I removed the tainted line of code.

    • I've re-written the shader multiple times from scratch using VS, Notepad and Notepad++ as suggested on the Unity forums.

    • I've used the hex editor view in Notepad++ to rule out the first two bytes aren't 0xFE 0xFF as suggested on this gamedev question.

    I really can't figure this one out. I'm grateful for any suggestions you might have.

    cbuffer CB_PER_FRAME : register(b0)
    {
        column_major float4x4 view;
        column_major float4x4 proj;
        float4 eyePosition;
    };
    
    struct VertexInput
    {
        float3 position : POSITION;
        float3 normal   : NORMAL;
        float2 texCoord : TEXCOORD;
    
        row_major float4x4 world : WORLD;
        float4 color : COLOR;
        uint instanceID : SV_InstanceID;
    };
    
    struct PixelInput
    {
        float4 position : SV_POSITION;
        float3 normal   : NORMAL;
        float2 texCoord : TEXCOORD;
        float4 color    : COLOR;
    };
    
    PixelInput VertexShaderMain( VertexInput vertexInput )
    {
        PixelInput pixelInput (PixelInput)0;
    
        pixelInput.position = mul( float4( pixelInput.position, 1.0f ), vertexInput.world );
        pixelInput.position = mul( pixelInput.position, view );
        pixelInput.position = mul( pixelInput.position, proj );
    
        pixelInput.normal = normalize( mul( pixelInput.normal, (float3x3)vertexInput.world ) );
        pixelInput.texCoord = vertexInput.color;
        pixelInput.color = vertexInput.color;
    
        return pixelInput;
    }
    
    float4 PixelShaderMain( PixelInput pixelInput ) : SV_Target
    {
        return pixelInput.color;
    }
    

    解决方案

    It was an encoding problem. When I pasted the line of code it somehow made my compiler treat every text file as UNICODE instead of ASCII. This caused the problem.
    The solution was opening the shader file in Visual Studio and go to
    File->Save as->Save with Encoding and then choose the correct format and rebuild the solution.

    这篇关于错误X3000:着色器文件中的非法字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆