Created
March 10, 2021 19:43
-
-
Save gerardogc2378/660903e975837618b04d408b4779a329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type spatial; | |
render_mode specular_schlick_ggx, world_vertex_coords; | |
uniform sampler2D img : hint_albedo; | |
uniform vec4 base_color : hint_color; | |
uniform vec4 top_color : hint_color; | |
uniform vec4 right_color : hint_color; | |
uniform vec4 front_color : hint_color; | |
uniform float intensity : hint_range(0.0, 1.0) = 0.1; | |
varying vec3 true_normal; | |
vec4 blendAwithBFunc(vec4 c1, vec4 c2, float f) { | |
return mix(c1, c2, c2.a * f); | |
} | |
void vertex() { | |
true_normal = NORMAL; | |
} | |
void fragment() { | |
vec4 n_tex_read = texture(img, UV.xy); | |
vec3 n_x = vec3(true_normal.x) * vec3(true_normal.x); | |
vec3 n_y = vec3(true_normal.y) * vec3(true_normal.y); | |
vec3 n_z = vec3(true_normal.z) * vec3(true_normal.z); | |
vec3 n_out = vec3( | |
dot(n_x, vec3(0.333333, 0.333333, 0.333333)), | |
dot(n_y, vec3(0.333333, 0.333333, 0.333333)), | |
dot(n_z, vec3(0.333333, 0.333333, 0.333333)) | |
); | |
vec3 temp_output = (base_color.rgb * top_color.rgb); | |
vec3 c1 = (mix(mix(mix(temp_output, (base_color.rgb * right_color.rgb), n_out.x), temp_output ,n_out.y), (base_color.rgb * front_color.rgb), n_out.z)); | |
vec3 final_color = blendAwithBFunc(vec4(n_tex_read.rgb * base_color.rgb, 1.0), vec4(c1, 1.0), intensity).rgb; | |
ALBEDO = final_color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment