简体   繁体   中英

OpenGL es 2, Shaders not compiling

I'm trying to make a very simple point light and I'm failing miserably. All I know is that my shaders doesn't compile correctly (I don't seem to get much error information). My shaders are:

Vertex Shader Code

"uniform mat4 u_MVPMatrix;"
+ "uniform mat4 u_MVMatrix;"
+ "attribute vec4 a_Position;"
+ "varying vec3 v_Position;"
+ "void main() {"
+ "v_Position = vec3(u_MVMatrix * a_Position);"
+ "gl_Position = uMVPMatrix * a_Position;" + "}";

Fragment Shader Code

"precision mediump float;"
+ "uniform vec3 u_LightPos;"
+ "varying vec3 v_Position;"
+ "uniform vec4 vColor;"
+ "void main() {"
+ "float distance = length(u_LightPos - v_Position);"
+ "distance = 1.0 / distance;"
+ "distance = clamp(distance, 0.0, 1.0);"
+ "gl_FragColor = vColor * distance;" + "}";

Can anyone see what I'm doing wrong? PS I know very little about the opengl es shader syntax so any help is appreciated.

  • uMVPMatrix should be u_MVMatrix

Try to get a compile log when compiling shaders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM