Convert shaders in dali-demo to use shader compilation tool
[platform/core/uifw/dali-demo.git] / examples / renderer-stencil / shaders / render-stencil-textured.vert
1 // Shader for basic, per-vertex lighting with texture (vertex):
2
3 attribute mediump vec3  aPosition;
4 attribute highp   vec3  aNormal;
5 attribute highp   vec2  aTexCoord;
6
7 varying   mediump vec2  vTexCoord;
8 uniform   mediump mat4  uMvpMatrix;
9 uniform   mediump vec3  uSize;
10 uniform   mediump vec3  uObjectDimensions;
11 varying   mediump vec3  vIllumination;
12 uniform   mediump mat4  uModelView;
13 uniform   mediump mat4  uViewMatrix;
14 uniform   mediump mat3  uNormalMatrix;
15 uniform   mediump vec3  uLightPosition;
16
17 void main()
18 {
19   mediump vec4 vertexPosition = vec4( aPosition * uObjectDimensions, 1.0 );
20   vertexPosition = uMvpMatrix * vertexPosition;
21
22   vec4 mvVertexPosition = uModelView * vertexPosition;
23
24   vec3 vectorToLight = normalize( mat3( uViewMatrix ) * uLightPosition - mvVertexPosition.xyz );
25
26   vec3 normal = uNormalMatrix * aNormal;
27   float lightDiffuse = max( dot( vectorToLight, normal ), 0.0 );
28   vIllumination = vec3( lightDiffuse * 0.5 + 0.5 );
29
30   vTexCoord = aTexCoord;
31   gl_Position = vertexPosition;
32 }