shader_type spatial; render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx, sss_mode_skin; #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Math.gdshaderinc" #include "res://addons/rokojori_action_library/Runtime/Shading/Library/Light.gdshaderinc" uniform vec4 albedo : source_color; uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable; uniform float roughness : hint_range(0.0, 1.0); uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable; uniform float metallic : hint_range(0.0, 1.0, 0.01); uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable; uniform float specular : hint_range(0.0, 1.0, 0.01); uniform vec3 uv1_scale; uniform vec3 uv1_offset; uniform float scatter:hint_range( 0.0, 1.0 ) = 0.5; uniform float scatterBoost:hint_range( 0.0, 1.0 ) = 0.5; uniform float scatterDepth:hint_range( 0.0, 1.0 ) = 0.5; // [ FRESNEL ] group_uniforms fresnel; uniform float fresnelZOffset; uniform float fresnelPowerAmount; uniform float fresnelPostScale; uniform float fresnelPostOffset; uniform float fresnelColorAmount:hint_range( 0.0, 1.0 ); uniform vec3 fresnelColor:source_color; uniform vec3 fresnelEmission:source_color; uniform float fresnelRoughnessAmount:hint_range( 0.0, 1.0 ); uniform float fresnelRoughness; void vertex() { UV = UV * uv1_scale.xy + uv1_offset.xy; } void fragment() { float fresnel = fresnelNormalizedFromViewAdvanced( NORMAL, fresnelPowerAmount, fresnelPostScale, fresnelPostScale, fresnelPostOffset ); fresnel = clamp01( fresnel ); vec4 albedo_tex = texture( texture_albedo, UV ); ALBEDO = albedo.rgb * albedo_tex.rgb; ALBEDO = mix( ALBEDO, fresnelColor, fresnel * fresnelColorAmount ); EMISSION = fresnel * fresnelEmission; float metallic_tex = texture( texture_metallic, UV ).b; METALLIC = metallic_tex * metallic; SPECULAR = specular; float roughness_tex = texture( texture_roughness, UV ).g; ROUGHNESS = roughness_tex * roughness; ROUGHNESS = mix( ROUGHNESS, fresnelRoughness, fresnel * fresnelRoughnessAmount ); SSS_STRENGTH = max( 0.00001, scatter * 2.0 ); SSS_TRANSMITTANCE_COLOR = vec4( 1.0 ); SSS_TRANSMITTANCE_DEPTH = max( 0.00001, scatterDepth * 8.0 ); SSS_TRANSMITTANCE_BOOST = max( 0.00001, scatterBoost * 4.0 ); }