You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.0 KiB
Plaintext
68 lines
2.0 KiB
Plaintext
shader_type spatial;
|
|
uniform bool is_target = false;
|
|
uniform vec3 target_position = vec3(0, 1.28, 1);
|
|
uniform bool show_air_wall = true;
|
|
varying vec3 world_position;
|
|
varying vec2 uv1;
|
|
varying vec2 uv2;
|
|
uniform sampler2D tex_noise1 : source_color;
|
|
uniform sampler2D tex_noise2 : source_color;
|
|
|
|
void vertex()
|
|
{
|
|
world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
|
vec2 local_uv = vec2(world_position.x,world_position.y + world_position.z);
|
|
uv1 = local_uv / 32.0;
|
|
uv2 = local_uv / 32.0;
|
|
}
|
|
|
|
void fragment() {
|
|
vec3 c = COLOR.rgb;
|
|
if(c.r+c.g+c.b<0.1){
|
|
ALBEDO = vec3(0.0);
|
|
}else if(c.r+c.g+c.b>2.9){
|
|
if(show_air_wall){
|
|
ALBEDO = vec3(1.0);
|
|
}else{
|
|
discard;
|
|
}
|
|
}else{
|
|
float brightness = 1.0;
|
|
if(is_target){
|
|
float offset_y = abs(floor((world_position.y-target_position.y) / 0.02) * 0.02);
|
|
offset_y = max(0.0,offset_y-0.64);
|
|
float rate = clamp(1.0-offset_y/4.48,0.0,1.0);
|
|
brightness = rate;
|
|
}else{
|
|
brightness = 1.0;
|
|
}
|
|
vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
|
|
bool is_light = c.r+c.g+c.b>2.8;
|
|
if(!is_light && world_normal.y<0.1){
|
|
brightness = brightness*0.6;
|
|
}
|
|
if(show_air_wall){
|
|
brightness = 1.0;
|
|
}
|
|
|
|
float noise_value1 = texture(tex_noise1,floor(uv1 /0.02) *0.02).r;
|
|
float discrete_noise_value1 = floor(noise_value1 / 0.5) * 0.5;
|
|
float noise_value2 = texture(tex_noise2,floor(uv2 /0.02) *0.02).r;
|
|
float discrete_noise_value2 = floor(noise_value2 / 0.5) * 0.5;
|
|
c -= discrete_noise_value1 * 0.2;
|
|
c += discrete_noise_value2 * 0.2;
|
|
c.rgb = mix(vec3(0.0), c.rgb, brightness);
|
|
ALBEDO = c.rgb;
|
|
if(is_light){
|
|
EMISSION = c.rgb * 2.0;
|
|
}
|
|
}
|
|
}
|
|
|
|
void light() {
|
|
vec3 c = ALBEDO.rgb;
|
|
float rgb_sum = c.r+c.g+c.b;
|
|
if (!(rgb_sum<0.1 || rgb_sum>2.9)){
|
|
DIFFUSE_LIGHT += clamp(dot(NORMAL, LIGHT), 0.0, 1.0) * ATTENUATION * LIGHT_COLOR;
|
|
}
|
|
} |