Files
Diabolo/Demon_v0.19/maiden_heat.gdshader

41 lines
1.9 KiB
Plaintext

shader_type spatial;
render_mode cull_disabled;
uniform float heat=0.0;
uniform float base_height=0.0;
uniform vec4 base_color:source_color=vec4(1.0);
uniform sampler2D color_map:source_color,hint_default_white,filter_linear_mipmap_anisotropic;
uniform sampler2D metal_map:hint_default_white,filter_linear_mipmap_anisotropic;
uniform sampler2D rough_map:hint_default_white,filter_linear_mipmap_anisotropic;
uniform sampler2D normal_map:hint_normal,filter_linear_mipmap_anisotropic;
uniform float metal_value=1.0;
uniform float rough_value=1.0;
uniform float normal_strength=1.0;
uniform bool use_normal=false;
uniform int metal_channel=2;
uniform int rough_channel=1;
uniform vec2 uv_scale=vec2(1.0);
uniform vec2 uv_offset=vec2(0.0);
uniform bool tile_region=false;
uniform vec2 atlas_origin=vec2(0.0);
uniform vec2 atlas_size=vec2(1.0);
varying float model_height;
void vertex(){ model_height=(MODEL_MATRIX*vec4(VERTEX,1.0)).y-base_height; }
float channel_value(vec4 color,int channel){
if(channel==4){return dot(color.rgb,vec3(.333333));}
return color[channel];
}
void fragment(){
vec2 uv=UV*uv_scale+uv_offset;
if(tile_region){uv=atlas_origin+fract(uv*vec2(4.0,7.0))*atlas_size;}
vec3 original=base_color.rgb*texture(color_map,uv).rgb;
float warmth=clamp(heat*1.10-smoothstep(.2,3.1,model_height)*.08,0.0,1.0)*smoothstep(.18,.35,model_height);
vec3 hot=mix(vec3(.75,.002,.001),vec3(1.0,.10,.003),smoothstep(.25,.80,warmth));
hot=mix(hot,vec3(1.0,.44,.045),smoothstep(.82,1.0,warmth)*.65);
ALBEDO=mix(original,hot*.35,smoothstep(.35,1.0,warmth)*.45);
METALLIC=metal_value*channel_value(texture(metal_map,uv),metal_channel);
ROUGHNESS=clamp(rough_value*channel_value(texture(rough_map,uv),rough_channel),.1,1.0);
if(use_normal){NORMAL_MAP=texture(normal_map,uv).rgb;NORMAL_MAP_DEPTH=normal_strength;}
float texture_relief=.45+.55*clamp(dot(original,vec3(.333333))*3.5,0.0,1.0);
EMISSION=hot*pow(warmth,1.8)*1.4*texture_relief;
}