Fixing up Vulkan branch after merge to dali_1.3.26
[platform/core/uifw/dali-core.git] / dali / graphics / vulkan / shaders / mesh-visual-normal-map-shader.frag
1 #version 430
2
3 layout(location=0) in vec2 vTexCoord;
4 layout(location=1) in vec3 vLightDirection;
5 layout(location=2) in vec3 vHalfVector;
6
7 layout( set = 0, binding = 1, std140 ) uniform FragData
8 {
9     vec4 uColor;
10     vec3 mixColor;
11     float opacity;
12     float preMultipliedAlpha;
13 };
14
15 layout( set = 0, binding = 2 ) uniform sampler2D sDiffuse;
16 layout( set = 0, binding = 3 ) uniform sampler2D sNormal;
17 layout( set = 0, binding = 4 ) uniform sampler2D sGloss;
18
19 layout( location = 0 ) out vec4 fragColor;
20
21 void main()
22 {
23     vec4 diffuse = texture( sDiffuse, vTexCoord );
24     vec3 normal = normalize( texture( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );
25     vec4 glossMap = texture( sGloss, vTexCoord );
26     vec4 visualMixColor = vec4(mixColor,1.0);
27
28     float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );
29     lightDiffuse = lightDiffuse * 0.5 + 0.5;
30
31     float shininess = pow ( max ( dot ( normalize( vHalfVector ), normal ), 0.0 ), 16.0 );
32
33     fragColor = vec4( diffuse.rgb * uColor.rgb * visualMixColor.rgb * lightDiffuse + shininess * glossMap.rgb, diffuse.a * uColor.a * visualMixColor.a );
34 }