61 lines
2.3 KiB
Plaintext
61 lines
2.3 KiB
Plaintext
// NOTE: Shader automatically converted from Godot Engine 4.2.2.stable's StandardMaterial3D.
|
|
|
|
shader_type spatial;
|
|
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
|
|
uniform vec4 albedo : source_color;
|
|
uniform sampler2D texture_albedo : source_color,filter_nearest_mipmap_anisotropic,repeat_enable;
|
|
uniform sampler2D texture_albedo2 : source_color,filter_nearest_mipmap_anisotropic,repeat_enable;
|
|
uniform float point_size : hint_range(0,128);
|
|
uniform float roughness : hint_range(0,1);
|
|
varying vec3 uv1_triplanar_pos;
|
|
uniform float uv1_blend_sharpness;
|
|
varying vec3 uv1_power_normal;
|
|
uniform vec3 uv1_scale;
|
|
uniform vec3 uv1_offset;
|
|
uniform vec3 uv2_scale;
|
|
uniform vec3 uv2_offset;
|
|
|
|
varying float normal_y;
|
|
uniform float min_rock_slope:hint_range(0.0, 1.0, 0.1);
|
|
uniform float max_ice_slope:hint_range(0.0, 1.0, 0.1);
|
|
|
|
void vertex() {
|
|
vec3 normal = NORMAL;
|
|
TANGENT = vec3(0.0,0.0,-1.0) * abs(normal.x);
|
|
TANGENT+= vec3(1.0,0.0,0.0) * abs(normal.y);
|
|
TANGENT+= vec3(1.0,0.0,0.0) * abs(normal.z);
|
|
TANGENT = normalize(TANGENT);
|
|
BINORMAL = vec3(0.0,1.0,0.0) * abs(normal.x);
|
|
BINORMAL+= vec3(0.0,0.0,-1.0) * abs(normal.y);
|
|
BINORMAL+= vec3(0.0,1.0,0.0) * abs(normal.z);
|
|
BINORMAL = normalize(BINORMAL);
|
|
uv1_power_normal=pow(abs(NORMAL),vec3(uv1_blend_sharpness));
|
|
uv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset;
|
|
uv1_power_normal/=dot(uv1_power_normal,vec3(1.0));
|
|
uv1_triplanar_pos *= vec3(1.0,-1.0, 1.0);
|
|
normal_y = normal.y;
|
|
}
|
|
|
|
|
|
vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_triplanar_pos) {
|
|
vec4 samp=vec4(0.0);
|
|
samp+= texture(p_sampler,p_triplanar_pos.xy) * p_weights.z;
|
|
samp+= texture(p_sampler,p_triplanar_pos.xz) * p_weights.y;
|
|
samp+= texture(p_sampler,p_triplanar_pos.zy * vec2(-1.0,1.0)) * p_weights.x;
|
|
return samp;
|
|
}
|
|
|
|
|
|
void fragment() {
|
|
float rock_ice_weight = normal_y;
|
|
rock_ice_weight = max(min_rock_slope, rock_ice_weight);
|
|
rock_ice_weight = min(max_ice_slope, rock_ice_weight);
|
|
rock_ice_weight -= min_rock_slope;
|
|
rock_ice_weight /= max_ice_slope - min_rock_slope;
|
|
|
|
vec4 albedo_tex = triplanar_texture(texture_albedo,uv1_power_normal,uv1_triplanar_pos);
|
|
vec4 albedo_tex2 = triplanar_texture(texture_albedo2,uv1_power_normal,uv1_triplanar_pos);
|
|
|
|
ALBEDO = albedo.rgb * mix(albedo_tex2.rgb, albedo_tex.rgb, rock_ice_weight);
|
|
}
|