summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common/shader_3d/diffuse_frag.shd
blob: 7b6dc2bf694c7b586a52d8b3192e6439c0396ef0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifdef NEED_TEX_COORD
varying vec2   vTexCoord;
#endif //TEX_COORD

#ifdef FOG_ENABLED
uniform float uFogFactor;
uniform vec4  uFogColor;
#endif //FOG_ENABLED

#ifdef DIFFUSE
uniform   vec4        uMaterialDiffuse;

#ifdef DIFFUSE_TEXTURE
uniform sampler2D  uTextureDiffuse0;
#endif //DIFFUSE_TEXTURE

#ifdef DIFFUSE_TEXTURE_BLEND
uniform sampler2D  uTextureDiffuse1;
uniform float      uTextureDiffuseWeight;
#endif //DIFFUSE_TEXTURE_BLEND

#endif //DIFFUSE

void main() {

#ifdef DIFFUSE_TEXTURE_BLEND
   gl_FragColor = (texture2D(uTextureDiffuse0, vTexCoord) *
   uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vTexCoord) *
   (1.0 - uTextureDiffuseWeight)) * uMaterialDiffuse;
#else

#ifdef DIFFUSE_TEXTURE
   gl_FragColor = texture2D(uTextureDiffuse0, vTexCoord) * uMaterialDiffuse;
#else
   gl_FragColor = uMaterialDiffuse;
#endif //DIFFUSE_TEXTURE

#endif //DIFFUSE_TEXTURE_BLEND

#ifdef FOG_ENABLED
   float z = gl_FragCoord.z / gl_FragCoord.w;
   float fogFactor = exp2( -uFogFactor * uFogFactor * z * z * 1.44);
   fogFactor = clamp(fogFactor, 0.0, 1.0);
   gl_FragColor = mix(uFogColor, gl_FragColor, fogFactor);
#endif //FOG_ENABLED

}