shader_type spatial;

#include "res://vfx/util.gdshaderinc"

UNIVERSAL_SOLID_PARAMS
uniform sampler2D image: TEXTURE_HINTS;
instance uniform float hue_shift = 0.0;
uniform float hue_range = 1.0;
uniform float reflectivity = 0.0;
uniform float radiance = 0.0;

void fragment() {
	ALBEDO = texture(image, UV).rgb;
	SPECULAR = reflectivity;
	CLEARCOAT = reflectivity;
	CLEARCOAT_ROUGHNESS = 1.0 - reflectivity;
	ROUGHNESS = 1.0 - reflectivity;
	METALLIC = reflectivity;
	RIM = reflectivity;
	RIM_TINT = 1.0 - reflectivity;
	EMISSION = ALBEDO*radiance;
	vec3 albedo_hsv = rgb2hsv(ALBEDO);
	vec3 emission_hsv = rgb2hsv(EMISSION);
	float real_hue_shift = -hue_range*atan(hue_shift)/PI;
	albedo_hsv.x = fract(albedo_hsv.x + real_hue_shift);
	emission_hsv.x = fract(emission_hsv.x + real_hue_shift);
	ALBEDO = hsv2rgb(albedo_hsv);
	EMISSION = hsv2rgb(emission_hsv);
	UNIVERSAL_SOLID_PROCESSING
}