static const char *vert_str =
"precision mediump float; \n"
"attribute vec3 g_vPosition; \n"
"uniform highp mat4 g_matModelView; \n"
"uniform highp mat4 g_matProj; \n"
"uniform vec2 g_viscar; \n"
"varying vec2 v_iscar; \n"
"void main(){ \n"
" **vec3 g_vgragePosition = g_vPosition**; \n" //假如需要对传入的顶点操作,不能直接对g_vPosition进行操作,需要定义一个新的变量对变量进行操作
" if(sqrt(g_vgragePosition.x + (g_vgragePosition.y - 6685.0) * g_vgragePosition.z) ) > 2.0*7154.0){ \n" //常数的精度需要是浮点数,不能是整数
" g_vgragePosition.x = 0.0; \n"
" g_vgragePosition.y = 0.0; \n"
" g_vgragePosition.z = 0.0;} \n"
" **vec4 vPostion = vec4(g_vgragePosition, 1.0);** \n"
//" vec4 vPostion = vec4(g_vPosition, 1.0); \n"
" vec4 vPositionES = g_matModelView * vPostion; \n"
" gl_Position = g_matProj * vPositionES; \n"
" v_iscar = g_viscar; \n"
"} \n";
OpenGL着色器语法写法注意
最新推荐文章于 2023-07-02 20:46:15 发布