android - Vertex Shader fails to compile. Can't find the mistake -
edit:
seems mistake was, not allowed compile shader in seperate thread? since i've been pushing object-loading threaded environment, error message came up. didn't think reason it.
my current vertex shader fails compile reason. error message i'm getting not existent, , can't find mistake.
uniform mat4 u_mvpmatrix; uniform mat4 u_mvmatrix; uniform vec3 u_camerapos; attribute vec4 a_position; attribute vec4 a_color; attribute vec3 a_normal; varying vec3 v_position; varying vec4 v_color; varying vec3 v_normal; varying vec3 v_cameraposition; varying vec4 v_ambient; void main() { v_position = vec3(u_mvmatrix * a_position); v_color = a_color; v_normal = vec3(u_mvmatrix * vec4(a_normal, 0.0)); //v_cameraposition = vec3(u_mvmatrix * vec4(u_camerapos, 0.0)); // taken out debug v_cameraposition = u_camerapos; gl_position = u_mvpmatrix * a_position; } the fragment shader 1 is:
precision mediump float; uniform vec3 u_lightpos; uniform vec4 u_light; uniform vec4 u_ambient; uniform vec3 u_lightdirection; uniform vec3 u_camerapos; varying vec4 v_ambient; varying vec3 v_position; varying vec4 v_color; varying vec3 v_normal; varying vec3 v_cameraposition; // entry point our fragment shader. void main() { float distance = length(u_lightpos - v_position); vec3 lightvector = normalize(u_lightpos - v_position); float diffuse = max(dot(v_normal, lightvector), 0.1); diffuse = diffuse * (1.0 / (1.0 + (0.25 * distance * distance))); // specular lighting removed due debugging gl_fragcolor = v_color * (u_ambient + (diffuse * u_light)); } "trying" error message:
log.d(tag, "compilation -> " + gles20.glgetshaderinfolog(ishader)); returns empty string method, as
log.e(tag, "vertex shader failed -> " + gles20.glgeterror()); is returning 0.
i developing opengl es 2.0 android, if there restrictions android unaware of?
thank help!
opengl contexts work per-thread correct. if want create background loading thread need not create new context in thread, make sure it's sharing resources (the third parameter in eglcreatecontext). aware sharing context resources might not work on (older) devices.
Comments
Post a Comment