const char GRPSHADERLIBRARY::VertexShaderDOT[] =
"precision mediump float; \n"
"attribute vec3 a_position; \n"
"attribute vec3 a_normal; \n"
"attribute vec2 a_texCoord; \n"
"uniform sampler2D s_texture; \n"
"uniform mat4 MVPMat; \n"
"uniform mat4 Model; \n"
"uniform mat4 ModelView; \n"
"uniform mat4 iMVPMat; \n"
"varying vec4 v_position; \n"
"varying vec4 v_normal; \n"
"varying vec2 v_texCoord; \n"
"uniform vec3 lightPosition; \n"
"uniform float lightStrength;\n"
"varying vec4 vLight;\n"
"void main() \n"
" { \n"
"v_position = (ModelView * vec4(a_position,1.0));\n"
"vLight = normalize(MVPMat * vec4(lightPosition,1.0)); \n"
"v_texCoord = a_texCoord;\n"
"v_normal = normalize(iMVPMat*vec4(a_normal,1.0));\n"
"gl_Position = MVPMat * vec4(a_position,1.0);\n"
" } \n";
//---------------------- fragment
const char GRPSHADERLIBRARY::TextureShaderLightTextureDOT[] =
"precision mediump float; \n"
"varying vec4 v_position;\n"
"varying vec2 v_texCoord; \n"
"varying vec4 v_normal; \n"
"uniform sampler2D s_texture; \n"
"const vec3 lightPos = vec3(1.0, 1.0, 1.0);\n"
"varying vec4 vLight;\n"
"void main() {\n"
" vec4 N = v_normal;\n"
" vec4 nN = normalize(N);\n"
" vec4 nLight = normalize(vLight-v_position);\n"
" float lambert = dot(nN,nLight); \n"
" lambert = clamp (lambert,0.0,1.0);\n"
// Multiply the color by the diffuse illumination level to get final output color.
"vec4 color = vec4(texture2D(s_texture,v_texCoord).rgb,1.0);\n"
"gl_FragColor = vec4((color.r*lambert),(color.g*lambert),(color.b*lambert),1.0); \n"// Pass the color directly through the pipeline.
"gl_FragColor.a = 1.0; \n"
"}\n";