stick-the-quick/vfx/multimat.gdshader

51 lines
1.2 KiB
Plaintext
Raw Normal View History

shader_type spatial;
#include "res://vfx/util.gdshaderinc"
UNIVERSAL_SOLID_PARAMS
uniform sampler2D image: TEXTURE_HINTS;
uniform float hue_precision = 0.075;
uniform float saturation_threshold = 0.25;
uniform float glass_hue = -1.0;
uniform float chrome_hue = -1.0;
uniform float glow_hue = -1.0;
uniform float neon_hue = -1.0;
uniform float wax_hue = -1.0;
uniform float gloss_hue = -1.0;
void fragment() {
vec3 rgb = texture(image, UV).rgb;
ALBEDO = rgb;
vec3 hsv = rgb2hsv(rgb);
if (hsv.y >= saturation_threshold) {
if (abs(hsv.x - glass_hue) <= hue_precision) {
CLEARCOAT = 1.0;
CLEARCOAT_ROUGHNESS = 0.05;
ROUGHNESS = 0.05;
SPECULAR = 1.0;
METALLIC = 1.0;
}
if (abs(hsv.x - chrome_hue) <= hue_precision) {
CLEARCOAT = 1.0;
CLEARCOAT_ROUGHNESS = 0.05;
ROUGHNESS = 0.05;
SPECULAR = 1.0;
METALLIC = 1.0;
}
if (abs(hsv.x - glow_hue) <= hue_precision) {
EMISSION = ALBEDO/4.0;
}
if (abs(hsv.x - neon_hue) <= hue_precision) {
EMISSION = ALBEDO;
}
if (abs(hsv.x - wax_hue) <= hue_precision) {
CLEARCOAT = 0.05;
CLEARCOAT_ROUGHNESS = 0.95;
}
if (abs(hsv.x - gloss_hue) <= hue_precision) {
CLEARCOAT = 0.25;
CLEARCOAT_ROUGHNESS = 0.25;
}
}
UNIVERSAL_SOLID_PROCESSING
}