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
| shader_type spatial; render_mode ambient_light_disabled;
uniform sampler2D base:source_color; uniform sampler2D sss:source_color; uniform sampler2D ilm:source_color;
uniform float shinese= 32.0f; uniform float shade_threshold:hint_range(0,1)=0.3; uniform float spec_threshold:hint_range(0,0.1)=0.05f; uniform float test:hint_range(0,1)=0.5f;
varying vec4 v_color;
void vertex(){ v_color = COLOR; }
void light(){ float fade_ao_weight = v_color.r; vec3 base_color = texture(base,UV).rgb; vec3 shade_color = texture(sss,UV).rgb;
float shadow_weight = texture(ilm, UV).g; float LdotN = dot(LIGHT, NORMAL); float shade = LdotN*fade_ao_weight; float factor = LdotN*shadow_weight*fade_ao_weight; float is_shade = step(shade_threshold, shade); if(is_shade>0.0f){ DIFFUSE_LIGHT += base_color*(LIGHT_COLOR*test); }else{ DIFFUSE_LIGHT += (base_color+fade_ao_weight)*shade_color*(LIGHT_COLOR*test); } vec3 outline_color = texture(ilm, UV).aaa; DIFFUSE_LIGHT *= outline_color; float spec_mask = texture(ilm,UV).r; float spec_shape = texture(ilm,UV).b;
vec3 halfwayDir = normalize(LIGHT + VIEW); float spec = pow(max(dot(NORMAL, halfwayDir), 0.0), shinese);
spec = spec*spec_mask*spec_shape; float sm_spec = step(spec_threshold,spec);
SPECULAR_LIGHT += base_color* sm_spec; }
|