Merge "Fix resource ready state" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / graphics / shaders / gltf-physically-based-shader.vert
1 in highp vec3 aPosition;
2 in mediump vec2 aTexCoord0;
3 in mediump vec2 aTexCoord1;
4 in lowp vec3 aNormal;
5 in lowp vec4 aTangent;
6 in lowp vec4 aVertexColor;
7
8 uniform mediump vec3 uSize;
9 uniform mediump mat4 uModelMatrix;
10 uniform mediump mat4 uViewMatrix;
11 uniform mediump mat4 uProjection;
12 uniform lowp int uLightType;
13 uniform mediump vec3 uLightVector;
14 uniform lowp int uIsColor;
15
16 out lowp vec2 vUV[2];
17 out lowp mat3 vTBN;
18 out lowp vec4 vColor;
19 flat out int visLight;
20 out highp vec3 vLightDirection;
21 out highp vec3 vPositionToCamera;
22
23 void main()
24 {
25   highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
26   highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );
27   highp vec4 positionV = uViewMatrix * ( invY * positionW );
28
29   vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );
30   vPositionToCamera *= invY.xyz;
31
32   lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
33   vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);
34
35   vUV[0] = aTexCoord0;
36   vUV[1] = aTexCoord1;
37
38   visLight = 1;
39   if( uLightType == 1 )
40   {
41     vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );
42   }
43   else if( uLightType == 2 )
44   {
45     vLightDirection = -( invY.xyz * uLightVector );
46   }
47   else
48   {
49     visLight = 0;
50   }
51
52   vColor = vec4( 1.0 );
53   if( uIsColor == 1 )
54   {
55     vColor = aVertexColor;
56   }
57
58   gl_Position = uProjection * positionV; // needs w for proper perspective correction
59   gl_Position = gl_Position/gl_Position.w;
60 }