Files

37 lines
1.4 KiB
Plaintext

// Original opaque petal geometry: soft wrap lighting without alpha overdraw.
shader_type spatial;
render_mode skip_vertex_transform, cull_disabled, specular_disabled;
uniform vec2 wind_direction = vec2(1.0, 0.7);
uniform float wind_amount : hint_range(0.0, 1.0) = 0.115;
uniform float fade_begin = 42.0;
uniform float fade_end = 56.0;
varying float palette_variation;
void vertex() {
vec3 anchor = MODEL_MATRIX[3].xyz;
float distance_to_camera = distance(anchor, CAMERA_POSITION_WORLD);
float presence = 1.0 - smoothstep(fade_begin, fade_end, distance_to_camera);
float height = max(VERTEX.y, 0.0);
float phase = dot(anchor.xz, vec2(0.38, 0.29));
float gust = sin(TIME * 1.15 + phase) * 0.65 + sin(TIME * 0.58 + phase * 0.42) * 0.35;
VERTEX *= presence;
vec3 world_vertex = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
world_vertex.xz += normalize(wind_direction) * wind_amount * gust * height * height * presence;
VERTEX = (VIEW_MATRIX * vec4(world_vertex, 1.0)).xyz;
vec3 local_normal = normalize(NORMAL + vec3(0.0, 1.6, 0.0));
NORMAL = normalize((MODELVIEW_MATRIX * vec4(local_normal, 0.0)).xyz);
palette_variation = mix(0.92, 1.06, INSTANCE_CUSTOM.r);
}
void fragment() {
ALBEDO = COLOR.rgb * palette_variation;
ROUGHNESS = 1.0;
}
void light() {
float sunlight = smoothstep(-0.35, 0.55, dot(NORMAL, LIGHT));
vec3 shade = mix(vec3(0.43, 0.58, 0.55), vec3(1.0, 0.98, 0.90), sunlight);
DIFFUSE_LIGHT += shade * LIGHT_COLOR * ATTENUATION / PI;
}