This commit is contained in:
2026-10-13 15:27:01 +08:00
parent 850d657404
commit c81571ec1e
28 changed files with 551 additions and 113 deletions
+54
View File
@@ -0,0 +1,54 @@
#include "base-cel-shader.gdshaderinc"
group_uniforms Anisotropy;
uniform float anisotropy_ratio: hint_range(-1,1) = 0.0;
uniform vec3 anisotropy_direction = vec3(0.0, -1.0, 0.0);
uniform float aniso_map_dir_ratio: hint_range(0,1) = 0.0;
uniform sampler2D anisotropy_flowmap: hint_anisotropy;
group_uniforms;
varying vec3 ANISOTROPY_DIR;
varying float ANISOTROPY_RATIO;
struct AnisotropyData {
vec3 direction;
float ratio;
};
AnisotropyData anisotropy_fragment(vec2 uv) {
return AnisotropyData(
mix(
normalize(anisotropy_direction),
texture(anisotropy_flowmap, uv).rgb * 2.0 - 1.0,
aniso_map_dir_ratio
),
anisotropy_ratio * texture(anisotropy_flowmap, uv).a
);
}
vec3 anisotropy_specular(
vec3 light_color,
vec3 specular_color,
float specular_strength,
vec3 normal,
vec3 view,
vec3 light,
float attenuation,
vec2 uv,
vec3 aniso_dir,
float aniso_ratio
) {
vec3 half = normalize(view + light);
float aniso = max(0, sin(dot(normalize(normal + aniso_dir), half) * PI));
float spec = mix(dot(normal, half), aniso, aniso_ratio);
float spec_gloss = pow(2.0, 8.0 * (1.0 - specular_strength));
float spec_intensity = smoothstep(
0.05,
0.05 + specular_smoothness,
pow(spec, spec_gloss * spec_gloss)
);
return light_color
* specular_color
* spec_intensity
* is_lit(light, normal, attenuation);
}
@@ -0,0 +1 @@
uid://u6yltf3ostgg
+23
View File
@@ -0,0 +1,23 @@
#include "base-cel-shader.gdshaderinc"
group_uniforms Backlight;
uniform vec3 backlight : source_color;
uniform sampler2D backlight_texture : hint_default_white;
group_uniforms;
vec3 backlight_fragment(vec2 uv) {
return backlight * texture(backlight_texture, uv).rgb;
}
vec3 backlight_diffuse(
vec3 albedo,
vec3 light_color,
vec3 light,
vec3 normal,
float attenuation,
vec3 backlight_color
) {
float value = diffuse_sample(light, normal);
return albedo * light_color * attenuation
* (value + backlight_color * (1.0 - value));
}
@@ -0,0 +1 @@
uid://81vh3myp0qw
@@ -0,0 +1,65 @@
global uniform sampler2D diffuse_curve: repeat_disable;
global uniform float specular_smoothness;
global uniform float fresnel_smoothness;
float diffuse_sample(vec3 light, vec3 normal) {
return texture(diffuse_curve, vec2(dot(light, normal), 0)
).r;
}
float is_lit(vec3 light, vec3 normal, float attenuation) {
return attenuation * diffuse_sample(light, normal);
}
vec3 diffuse_light(
vec3 albedo,
vec3 light_color,
vec3 light,
vec3 normal,
float attenuation
) {
return albedo * light_color * is_lit(light, normal, attenuation);
}
vec3 specular_light(
vec3 light_color,
vec3 specular_color,
float specular_strength,
vec3 normal,
vec3 view,
vec3 light,
float attenuation
) {
vec3 half = normalize(view + light);
float gloss = pow(2.0, 8.0 * (1.0 - specular_strength));
float intensity = pow(dot(normal, half), gloss * gloss);
return light_color
* specular_color
* is_lit(light, normal, attenuation)
* smoothstep(
0.05,
0.05 + specular_smoothness,
intensity
);
}
vec3 fresnel_light(
vec3 light_color,
vec3 fresnel_color,
float fresnel_strength,
vec3 normal,
vec3 view,
vec3 light,
float attenuation
) {
float fresnel_dot = 1.0 - dot(normal, view);
float fresnel_threshold = pow((1.0 - fresnel_strength), dot(light, normal));
return light_color
* fresnel_color
* is_lit(light, normal, attenuation)
* smoothstep(
fresnel_threshold - fresnel_smoothness / 2.0,
fresnel_threshold + fresnel_smoothness / 2.0,
fresnel_dot
);
}
@@ -0,0 +1 @@
uid://dm3y4ql7kxkxa
+9
View File
@@ -0,0 +1,9 @@
group_uniforms Emission;
uniform vec4 emission : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float emission_energy = 1.0;
uniform sampler2D emission_texture : hint_default_black;
group_uniforms;
vec3 emission_fragment(vec2 uv) {
return (emission.rgb + texture(emission_texture, uv).rgb) * emission_energy;
}
+1
View File
@@ -0,0 +1 @@
uid://c1rlmi7m6ie71
+33
View File
@@ -0,0 +1,33 @@
group_uniforms HeightMap;
uniform float height_scale: hint_range(-16.0, 16.0) = 5.0;
uniform int min_layers = 8;
uniform int max_layers = 32;
uniform vec2 height_flip = vec2(1, 1);
uniform sampler2D height_map: hint_default_black, filter_linear, repeat_enable;
group_uniforms;
vec2 height_map_fragment(vec2 uv, vec3 vertex, vec3 tangent, vec3 binormal, vec3 normal) {
vec2 base_uv = uv;
{
vec3 view_dir = normalize(normalize(-vertex) * mat3(tangent * height_flip.x, -binormal * height_flip.y, normal));
float num_layers = mix(float(max_layers),float(min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));
float layer_depth = 1.0 / num_layers;
vec2 P = view_dir.xy * height_scale * 0.01;
vec2 delta = P / num_layers;
vec2 ofs = base_uv;
float depth = 1.0 - texture(height_map, ofs).r;
float current_depth = 0.0;
while(current_depth < depth) {
ofs -= delta;
depth = 1.0 - texture(height_map, ofs).r;
current_depth += layer_depth;
}
vec2 prev_ofs = ofs + delta;
float after_depth = depth - current_depth;
float before_depth = (1.0 - texture(height_map, prev_ofs).r ) - current_depth + layer_depth;
float weight = after_depth / (after_depth - before_depth);
ofs = mix(ofs,prev_ofs,weight);
base_uv = ofs;
return base_uv;
}
}
@@ -0,0 +1 @@
uid://cxjrc82pbspws
+28
View File
@@ -0,0 +1,28 @@
group_uniforms NormalMap;
uniform float normal_scale : hint_range(-16,16) = 1.0;
uniform sampler2D normal_map : hint_normal;
group_uniforms;
struct NormalData {
vec3 vector;
vec3 map;
float depth;
};
NormalData normal_map_fragment(
vec2 uv,
vec3 normal,
vec3 tangent,
vec3 binormal,
) {
vec3 map = texture(normal_map, uv).rgb;
vec3 vector = map;
vector.xy = vector.xy * 2.0 - 1.0;
vector.z = sqrt(max(0.0, 1.0 - dot(vector.xy, vector.xy)));
vec3 ref_normal = normalize(mix(
normal,
tangent * vector.x + binormal * vector.y + normal * vector.z,
normal_scale
));
return NormalData(vector, map, normal_scale);
}
@@ -0,0 +1 @@
uid://ds1ojh3qbgv4s
+16
View File
@@ -0,0 +1,16 @@
group_uniforms Occlusion;
uniform float ao_light_affect: hint_range(0,1) = 0.0;
uniform sampler2D ao_map : hint_default_white;
group_uniforms;
struct OcclusionData {
float ao;
float ao_light_affect;
};
OcclusionData occlusion_fragment(vec2 uv) {
return OcclusionData(
texture(ao_map, uv).r,
ao_light_affect
);
}
@@ -0,0 +1 @@
uid://hs5e8wk7dna1
+17
View File
@@ -0,0 +1,17 @@
group_uniforms Reflections;
uniform float metallic : hint_range(0,1) = 0.0;
uniform float roughness : hint_range(0,1) = 1.0;
uniform sampler2D texture_surface : hint_default_white;
group_uniforms;
struct Surface {
float metallic;
float roughness;
};
Surface reflections_fragment(vec2 uv) {
return Surface(
metallic * texture(texture_surface, uv).r,
roughness * texture(texture_surface, uv).g
);
}
@@ -0,0 +1 @@
uid://dy51hoh6i2uqu
+36
View File
@@ -0,0 +1,36 @@
group_uniforms Refraction;
uniform float refraction : hint_range(-16, 16) = 0.05;
uniform float blurriness : hint_range(0.0, 1.0) = 0.0;
group_uniforms;
uniform sampler2D screen_texture :
hint_screen_texture,
repeat_disable,
filter_linear_mipmap;
uniform sampler2D depth_texture :
hint_depth_texture,
repeat_disable,
filter_linear_mipmap;
vec3 refraction_fragment(
float alpha,
vec3 normal,
vec2 screen_uv,
float depth
) {
float amount = 1.0 - alpha;
vec2 offset = screen_uv - normal.xy * refraction;
float image_depth = texture(depth_texture, offset).r;
return image_depth < depth
? textureLod(
screen_texture,
screen_uv,
blurriness * 8.0
).rgb * amount
: textureLod(
screen_texture,
offset,
blurriness * 8.0
).rgb * amount;
}
@@ -0,0 +1 @@
uid://b0c7qptxov8yo
+8
View File
@@ -0,0 +1,8 @@
uniform sampler2D screen_texture :
hint_screen_texture,
repeat_disable,
filter_linear_mipmap;
vec3 transparency_fragment(float alpha, vec2 screen_uv) {
return (1.0 - alpha) * texture(screen_texture, screen_uv).rgb;
}
@@ -0,0 +1 @@
uid://b6rxwstxjta3c