GLSL Shader Error "Constructor calls may not have precision"
glsl, ios, opengl-es
Solution
The problem was in a method used for random generation. I removed the "high" before the vec2() construction. (Sigh)
highp float rand(highp vec2 co)
{
return fract(sin(dot(co.xy ,highp vec2(12.9898,78.233))) * 43758.5453);
}
Problem
GLSL Shader Error ERROR: 0:1: '(' : syntax error: Constructor calls may not have precision I'm seeing this error with Xcode 6 on an iOS 8 app based on GLPaint demo... (works fine in iOS7) I also noticed they no longer use the "STRINGIFY" thing in version 1.13 of GLPaint demo. .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; } ); ```