|
|
|
|
Reply From: |
klaas |
Hi,
i assume you want to use visual shaders. But i dont know a lot about the nodes.
But i can give you a glsl shader wich isnt to hard to modify
The base of the code is from here:
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);
varying vec3 wNormal;
uniform float _TriplanarBlendSharpness : hint_range(2,20) = 5.0;
uniform vec4 north : hint_color = vec4(1.0,0.0,0.0,1.0);
uniform vec4 west : hint_color = vec4(0.0,1.0,0.0,1.0);
uniform vec4 near : hint_color = vec4(0.0,0.0,1.0,1.0);
uniform vec4 south : hint_color = vec4(1.0,0.5,0.5,1.0);
uniform vec4 east : hint_color = vec4(0.5,1.0,0.5,1.0);
uniform vec4 far : hint_color = vec4(0.5,0.5,1.0,1.0);
void vertex() {
//calculate the world space normal
wNormal = normalize((WORLD_MATRIX * vec4(NORMAL,0.0)).xyz);
}
void fragment() {
METALLIC = metallic;
ROUGHNESS = roughness;
SPECULAR = specular;
//calculate the blend weight
vec3 blendWeights = pow(abs(wNormal),vec3(_TriplanarBlendSharpness));
blendWeights = blendWeights / (blendWeights.x + blendWeights.y + blendWeights.z);
//set black becaus we want to add the color on to it
ALBEDO = vec3(0.0);
//for the left we multiply by blendweight and the sign
ALBEDO += clamp(west.rgb * blendWeights.x * sign(wNormal.x),0.0,1.0);
//for the right we multiply it by the inverted sign
ALBEDO += clamp(east.rgb * blendWeights.x * sign(wNormal.x*-1.0),0.0,1.0);
// do so for the other directions
ALBEDO += clamp(north.rgb * blendWeights.y * sign(wNormal.y),0.0,1.0);
ALBEDO += clamp(south.rgb * blendWeights.y * sign(wNormal.y*-1.0),0.0,1.0);
ALBEDO += clamp(near.rgb * blendWeights.z * sign(wNormal.z),0.0,1.0);
ALBEDO += clamp(far.rgb * blendWeights.z * sign(wNormal.z*-1.0),0.0,1.0);
}
Thanks for the help
Ogeeice | 2020-09-04 08:13