grunk/src/shaders/gunk.gdshader

30 lines
786 B
Plaintext
Raw Normal View History

2025-03-01 14:40:02 -07:00
shader_type spatial;
render_mode cull_back;
uniform vec4 color_1: source_color = vec4(0.0, 0.03, 0.1, 1.0);
uniform vec4 color_2: source_color = vec4(0.0, 0.1, 0.3, 1.0);
uniform float roughness: hint_range(0.0, 1.0) = 0.15;
uniform float specular_contribution = 0.2;
uniform sampler2D gunk_mask;
uniform highp sampler2D gunk_noise;
uniform highp sampler2D gunk_normal_map;
void fragment() {
float mask = texture(gunk_mask, UV).r;
if(mask < 0.1) {
float value = texture(gunk_noise, UV).r;
vec4 color = mix(color_1, color_2, value);
float roughness_mix = value * roughness;
ALBEDO = color.rgb;
ROUGHNESS = roughness_mix;
SPECULAR = 0.5 * inversesqrt(specular_contribution);
NORMAL_MAP = texture(gunk_normal_map, UV).xyz;
ALPHA = 1.0;
} else {
ALPHA = 0.0;
}
}