spacecloud tnx! that did it!
heres' the working shader
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
uniform float blend_sharpness = 1.0;
uniform float normal_scale = 1.0;
uniform vec3 texture1_scale = vec3(1.0);
uniform sampler2D texture1_albedo : source_color,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture1_normal : hint_normal,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture1_roughness : hint_roughness_gray,filter_linear_mipmap,repeat_enable;
uniform vec3 texture2_scale = vec3(1.0);
uniform sampler2D texture2_albedo : source_color,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture2_normal : hint_roughness_normal,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture2_roughness : hint_roughness_gray,filter_linear_mipmap,repeat_enable;
uniform vec3 texture3_scale = vec3(1.0);
uniform sampler2D texture3_albedo : source_color,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture3_normal : hint_roughness_normal,filter_linear_mipmap,repeat_enable;
uniform sampler2D texture3_roughness : hint_roughness_gray,filter_linear_mipmap,repeat_enable;
uniform sampler2D detailtexture : hint_roughness_gray,filter_linear_mipmap,repeat_enable;
uniform sampler2D detailroughness : hint_roughness_gray,filter_linear_mipmap,repeat_enable;
uniform sampler2D detailnormal : hint_roughness_normal,filter_linear_mipmap,repeat_enable;
uniform vec3 detail_scale = vec3(1.0);
varying vec3 power_normal;
varying vec3 triplanar_pos;
void vertex() {
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);
power_normal = pow(abs(NORMAL),vec3(blend_sharpness));
triplanar_pos = VERTEX;
power_normal /= dot(power_normal,vec3(1.0));
triplanar_pos *= vec3(1.0,-1.0, 1.0);
}
vec3 triplanar_texture(sampler2D p_sampler, vec3 p_triplanar_pos) {
vec3 samp = vec3(0.0);
samp += texture(p_sampler,p_triplanar_pos.xy).xyz * power_normal.z;
samp += texture(p_sampler,p_triplanar_pos.xz).xyz * power_normal.y;
samp += texture(p_sampler,p_triplanar_pos.zy).xyz * power_normal.x;
return samp;
}
vec3 blend(vec3 texture1, vec3 texture2, vec3 texture3, vec4 color){
return ((texture1 * color.r) + (texture2 * color.b) + (texture3 * color.g)).rgb;
}
vec3 normalblend(vec3 n1, vec3 n2)
{
n1 = n1 * 2.0 - 1.0;
n2 = n2 * 2.0 - 1.0;
return normalize(vec3(n1.xy + n2.xy, n1.z * n2.z)) + vec3(0.5, 0.5, 1.0);
}
void fragment() {
vec3 albedo_texture = (blend(triplanar_texture(texture1_albedo, triplanar_pos * texture1_scale), triplanar_texture(texture2_albedo, triplanar_pos * texture2_scale) , triplanar_texture(texture3_albedo, triplanar_pos * texture3_scale), COLOR)) * triplanar_texture(detailtexture, triplanar_pos * detail_scale);
ALBEDO = albedo_texture.rgb;
vec3 orm_texture = (blend(triplanar_texture(texture1_roughness, triplanar_pos * texture1_scale), triplanar_texture(texture2_roughness, triplanar_pos * texture2_scale), triplanar_texture(texture3_roughness, triplanar_pos * texture3_scale), COLOR))* triplanar_texture(detailroughness, triplanar_pos * detail_scale);
AO = 1.0;
ROUGHNESS = orm_texture.r;
METALLIC = 0.0;
NORMAL_MAP = normalblend(blend(triplanar_texture(texture1_normal, triplanar_pos * texture1_scale), triplanar_texture(texture2_normal, triplanar_pos * texture2_scale), triplanar_texture(texture3_normal, triplanar_pos * texture3_scale), COLOR),triplanar_texture(detailnormal, triplanar_pos * detail_scale));
NORMAL_MAP_DEPTH = normal_scale;
}
any idea why my vertex offset shader is bad?