GLSL着色器错误"构造函数调用可能没有精度"

时间:2014-07-15 21:31:56

标签: ios opengl-es glsl

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;

}

);

1 个答案:

答案 0 :(得分:3)

问题在于用于随机生成的方法。我删除了"高"在vec2()构造之前。 (叹气)

 highp float rand(highp vec2 co)
{
    return fract(sin(dot(co.xy ,highp vec2(12.9898,78.233))) * 43758.5453);
}