shader_type spatial; render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx; uniform sampler2D grid_texture : hint_albedo; uniform vec4 albedo : hint_color = vec4(1.0); uniform float scale = float(1.0); uniform vec3 uv1_offset = vec3(0); varying vec3 uv1_power_normal; varying vec3 uv1_triplanar_pos; 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 vertex() { uv1_power_normal=pow(abs(NORMAL),vec3(1.0)); uv1_power_normal/=dot(uv1_power_normal,vec3(1.0)); vec3 uv1_scale = vec3(scale); uv1_triplanar_pos = VERTEX * uv1_scale + uv1_offset; uv1_triplanar_pos *= vec3(1.0,-1.0, 1.0); } void fragment() { vec4 albedo_tex = triplanar_texture(grid_texture,uv1_power_normal,uv1_triplanar_pos); ALBEDO = albedo.rgb * albedo_tex.rgb; }