简体   繁体   English

着色器编译错误

[英]Shader Compiling Error

I am working on a project that has shaders hidden in the source code.我正在开发一个在源代码中隐藏了着色器的项目。 I received this error (at runtime):我收到此错误(在运行时):

Error compiling vertex shader:

Full VS shader source:

//precision highp float;

uniform vec2 uEyeToSourceUVScale;
uniform vec2 uEyeToSourceUVOffset;

attribute vec4 aPosition;         ///< [-1,+1],[-1,+1] over the entire framebuffer. Lerp factor in Pos.z. Vignette fade factorin Pos.w.
attribute vec2 aTanEyeAnglesR;   ///< The tangents of the horizontal and vertical eye angles for the red channel.
attribute vec2 aTanEyeAnglesG;   ///< The tangents of the horizontal and vertical eye angles for the green channel.
attribute vec2 aTanEyeAnglesB;   ///< The tangents of the horizontal and vertical eye angles for the blue channel.

varying vec4 vPosition; 
varying vec2 vTexCoordR; 
varying vec2 vTexCoordG; 
varying vec2 vTexCoordB; 

void main(void)
{
    vPosition = aPosition;
    vTexCoordR = aTanEyeAnglesR * uEyeToSourceUVScale + uEyeToSourceUVOffset;
    vTexCoordG = aTanEyeAnglesG * uEyeToSourceUVScale + uEyeToSourceUVOffset;
    vTexCoordB = aTanEyeAnglesB * uEyeToSourceUVScale + uEyeToSourceUVOffset;
    vTexCoordR.y = 1.0 - vTexCoordR.y;
    vTexCoordG.y = 1.0 - vTexCoordG.y;
    vTexCoordB.y = 1.0 - vTexCoordB.y;
    gl_Position = vec4(aPosition.xy, 0, 1);
}

Shader compilation failed.

I don't know how to approach solving this problem (no shader experience);我不知道如何解决这个问题(没有着色器经验); however, I know shader code is similar to C++ code and in that sense this looks very straightforwardly correct to me (unless I'm missing something).但是,我知道着色器代码类似于 C++ 代码,从这个意义上说,这对我来说看起来非常正确(除非我遗漏了一些东西)。

Is there something obviously wrong with this shader code?这个着色器代码有什么明显的问题吗?

The lack of a #version directive implies #version 110 .缺少#version指令意味着#version 110

gl_Position = vec4(aPosition.xy, 0, 1);
                                 ^  ^ int literals

#version 110 doesn't support automatic int -> float conversion. #version 110不支持自动int -> float转换。 Use float literals instead:改用float文字:

gl_Position = vec4(aPosition.xy, 0.0, 1.0);
                                 ^^^  ^^^ float literals

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM