1. vertex shader 和 fragment shader 通过varying变量传递数据,
如下代码在编译fragment shader时候会提示编译错误
vertex shader
|
Fragment shader
|
varying vec4 v_color;
attribute vec3 v_Position;
attribute vec4 f_Color;
void main(void)
{
gl_Position = vec4(v_Position, 1.0);
v_color = f_Color;
}"
|
varying vec4 v_color;
void main(void)
{
gl_FragColor = v_color;
};
|
在fragment shader中加入精度控制,就不会出现编译错误!任何一个精度控制都可以解决编译错误(不解!)
vertex shader |
Fragment shader |
varying vec4 v_color; attribute vec3 v_Position; attribute vec4 f_Color; void main(void) { gl_Position = vec4(v_Position, 1.0); v_color = f_Color; }" |
varying (lowp/mediump/highp) vec4 v_color;
void main(void)
{
gl_FragColor = v_color;
};
|