GLSL 着色器错误
错误: 0:1: '(' : 语法错误: 构造函数调用可能没有精度
我在基于 GLPaint 演示的 iOS 8 应用程序上看到 Xcode 6 出现此错误......(在 iOS7 中工作正常)
我还注意到他们不再使用 GLPaint 演示的 1.13 版中的“STRINGIFY”。
.vsh
static const char* BaseVS = STRINGIFY
(
attribute highp vec4 inVertex;
uniform highp mat4 MVP;
uniform highp float pointSize;
uniform highp vec4 vertexColor;
uniform highp float brushRotation;
varying highp vec4 color;
void main()
{
gl_Position = MVP * inVertex;
gl_PointSize = pointSize;
color = vertexColor;
}
);
.fsh
static const char* BaseFS = STRINGIFY
(
uniform sampler2D texture;
uniform sampler2D normalMap;
uniform highp float brushRotation;
varying highp vec4 color;
varying highp vec3 normal;
varying highp vec3 lightDir;
varying highp vec3 eyeVec;
precision highp float;
void main (void)
{
highp float vRotation = (brushRotation/180.0)*3.14;;
highp float mid = 0.5;
highp vec2 rotated = vec2(cos(vRotation) * (gl_PointCoord.x - mid) + sin(vRotation) * (gl_PointCoord.y - mid) + mid,
cos(vRotation) * (gl_PointCoord.y - mid) - sin(vRotation) * (gl_PointCoord.x - mid) + mid);
highp vec4 rotatedTexture = texture2D( texture, rotated);
gl_FragColor = color * rotatedTexture;
}
);
最佳答案
问题在于用于随机生成的方法。我在 vec2() 构造之前删除了“高”。 (叹)
highp float rand(highp vec2 co)
{
return fract(sin(dot(co.xy ,highp vec2(12.9898,78.233))) * 43758.5453);
}
关于ios - GLSL 着色器错误 "Constructor calls may not have precision",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24768559/