-
Notifications
You must be signed in to change notification settings - Fork 1
/
blend.gdshader
69 lines (53 loc) · 1.86 KB
/
blend.gdshader
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_lambert, specular_schlick_ggx;
uniform sampler2D AlbedoRough1 : source_color;
uniform sampler2D AlbedoRough2 : source_color;
uniform sampler2D AlbedoRough3 : source_color;
uniform sampler2D Normal1;
uniform sampler2D Normal2;
uniform sampler2D Normal3;
uniform sampler2D BlendMap;
uniform float UVFactor1 = 10;
uniform float UVFactor2 = 10;
uniform float UVFactor3 = 10;
uniform float Metal1 = 0.0;
uniform float Metal2 = 0.0;
uniform float Metal3 = 0.0;
uniform float Spec1 = 0.0;
uniform float Spec2 = 0.0;
uniform float Spec3 = 0.0;
void fragment() {
vec2 UVx1 = UV * UVFactor1;
vec2 UVx2 = UV * UVFactor2;
vec2 UVx3 = UV * UVFactor3;
vec3 factor = texture(BlendMap, UV).rgb;
vec3 a1 = texture(AlbedoRough1, UVx1).rgb;
vec3 a2 = texture(AlbedoRough2, UVx2).rgb;
vec3 a3 = texture(AlbedoRough3, UVx3).rgb;
float r1 = texture(AlbedoRough1, UVx1).a;
float r2 = texture(AlbedoRough2, UVx2).a;
float r3 = texture(AlbedoRough3, UVx3).a;
vec3 n1 = texture(Normal1, UVx1).rgb;
vec3 n2 = texture(Normal2, UVx2).rgb;
vec3 n3 = texture(Normal3, UVx3).rgb;
vec3 albedo_1 = mix(a1, a2, factor.r);
float rough_1 = mix(r1, r2, factor.r);
float metal_1 = mix(Metal1, Metal2, factor.r);
float spec_1 = mix(Spec1, Spec2, factor.r);
vec3 normal_1 = mix(n1, n2, factor.r);
vec3 albedo_2 = mix(albedo_1, a3, factor.g);
float rough_2 = mix(rough_1, r3, factor.g);
float metal_2 = mix(metal_1, Metal3, factor.g);
float spec_2 = mix(spec_1, Spec3, factor.g);
vec3 normal_2 = mix(normal_1, n3, factor.g);
vec3 c = 0.3 * COLOR.rgb;
vec3 r_mix = mix(albedo_2, vec3(1,0,0), c.r);
vec3 g_mix = mix(r_mix, vec3(0,1,0), c.g);
vec3 b_mix = mix(g_mix, vec3(0,0,1), c.b);
ALBEDO = albedo_2;
//ALBEDO = b_mix;
ROUGHNESS = rough_2;
METALLIC = metal_2;
SPECULAR = spec_2;
NORMAL_MAP = normal_2;
}