ios - GLSL 着色器错误 "Constructor calls may not have precision"

标签 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;

}

);

最佳答案

问题出在用于随机生成的方法中。我在 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/

相关文章:

ios - 为什么在 Collection View 中显示奇怪的线条?

ios - 在间隔不为 1 的 NSTimer 上显示每秒获取更新

ios - 第二次显示 MapKit 失败并显示 EXC_BAD_ACCESS

android - 在android中将字节数组转换为位图有什么错误? (字节数组是从 c/c++ 服务器发送的,android 是客户端)

android opengl渲染垃圾

c++ - 运行 QT Creator 时 OpenGL 的问题

opengl - fwidth glsl 函数实际用于什么?

c++ - 标识符 "in"未定义

math - 在 GL ES 中将片段着色器渐变结果从黑色转换为透明

ios - collectionView 中的约束