Convert shaders in dali-demo to use shader compilation tool
[platform/core/uifw/dali-demo.git] / examples / deferred-shading / shaders / deferred-shading-prepass.vert
1 #version 300 es
2
3 precision mediump float;
4
5 // DALI uniforms
6 uniform mat4 uMvpMatrix;
7 uniform mat3 uNormalMatrix;
8 uniform vec3 uSize;
9
10 uniform vec3 uDepth_InvDepth_Near;
11
12 #define DEPTH uDepth_InvDepth_Near.x
13 #define INV_DEPTH uDepth_InvDepth_Near.y
14 #define NEAR uDepth_InvDepth_Near.z
15
16 in vec3 aPosition;
17 in vec3 aNormal;
18
19 out vec4 vPosition;
20 out vec3 vNormal;
21
22 vec4 Map(vec4 v) // projection space -> texture
23 {
24   return vec4(v.xyz / (2.f * v.w) + vec3(.5f), (v.w - NEAR) * INV_DEPTH);
25 }
26
27 void main()
28 {
29   vec4 position = uMvpMatrix * vec4(aPosition * uSize, 1.f);
30   vPosition = Map(position);
31   gl_Position = position;
32
33   vNormal = normalize(uNormalMatrix * aNormal);
34 }