blob: 75a2c7dc89eea2b34dcedff5a1da9822d21ae1cc (
plain)
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
|
vec4 diffuse = vec4(0.0);
float ambientBrightness = 0.75;
float directionalBrightness = 0.75;
float pointSize = 0.75f;
VARYING vec3 pos;
void MAIN()
{
if (usePoint) {
float distanceToCenter = distance(vec2(0.0), pos.xy);
if (distanceToCenter > pointSize)
discard;
}
vec4 color;
vec2 gradientUV;
switch (colorStyle) {
case 0: // Uniform
color = uColor.rgba;
break;
case 1: // Object gradient
gradientUV = vec2((pos.y + 1.0) / 2.0, 0.0);
color = texture(custex, gradientUV);
break;
case 2: // Range gradient
vec2 gradientUV = vec2(((VAR_WORLD_POSITION.y + rootScale) / 2.0) / rootScale, 0.0);
color = texture(custex, gradientUV);
break;
}
diffuse = color;
BASE_COLOR = diffuse;
}
void AMBIENT_LIGHT()
{
DIFFUSE += diffuse.rgb * TOTAL_AMBIENT_COLOR * ambientBrightness;
}
void DIRECTIONAL_LIGHT()
{
DIFFUSE += diffuse.rgb * directionalBrightness * LIGHT_COLOR * SHADOW_CONTRIB
* vec3(max(0.0, dot(normalize(NORMAL), TO_LIGHT_DIR)));
}
|