Fix visual defect during text scroll
[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 mediump vec3 uLightVector;
13 uniform lowp float uIsPointLight;
14 uniform lowp float uHasVertexColor;
15
16 out lowp vec2 vUV[2];
17 out lowp mat3 vTBN;
18 out lowp vec4 vColor;
19 out highp vec3 vLightDirection;
20 out highp vec3 vPositionToCamera;
21
22 void main()
23 {
24   highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
25   highp vec4 positionW = uModelMatrix * vec4(aPosition * uSize, 1.0);
26   highp vec4 positionV = uViewMatrix * (invY * positionW);
27
28   vPositionToCamera = transpose(mat3(uViewMatrix)) * (-vec3(positionV.xyz / positionV.w));
29   vPositionToCamera *= invY.xyz;
30
31   lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
32   vTBN = mat3(uModelMatrix) * mat3(aTangent.xyz, bitangent, aNormal);
33
34   vUV[0] = aTexCoord0;
35   vUV[1] = aTexCoord1;
36
37   vLightDirection = mix(-(invY.xyz * uLightVector), (invY.xyz * uLightVector) - (positionW.xyz / positionW.w), uIsPointLight);
38
39   vColor = mix(vec4(1.0f), aVertexColor, uHasVertexColor);
40
41   gl_Position = uProjection * positionV; // needs w for proper perspective correction
42   gl_Position = gl_Position/gl_Position.w;
43 }