feat: added height line shader
This commit is contained in:
parent
cac2a1288f
commit
9d48b68db0
3 changed files with 25 additions and 0 deletions
24
project/assets/shaders/height_lines.gdshader
Normal file
24
project/assets/shaders/height_lines.gdshader
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
shader_type spatial;
|
||||
render_mode unshaded, skip_vertex_transform;
|
||||
|
||||
uniform float height_step = 10;
|
||||
uniform float line_thickness = 0.1;
|
||||
uniform vec4 lines : source_color;
|
||||
|
||||
varying vec3 var_vertex_position;
|
||||
varying vec3 var_model_normal;
|
||||
|
||||
void vertex() {
|
||||
var_model_normal = normalize(NORMAL);
|
||||
var_vertex_position = (vec4(VERTEX, 1.0) * MODEL_MATRIX).xyz;
|
||||
VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
|
||||
NORMAL = normalize(MODELVIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
|
||||
TANGENT = normalize(MODELVIEW_MATRIX * vec4(TANGENT, 0.0)).xyz;
|
||||
BINORMAL = normalize(MODELVIEW_MATRIX * vec4(BINORMAL, 0.0)).xyz;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = lines.rgb;
|
||||
ALPHA = int(var_vertex_position.y / line_thickness / height_step) % int(2.0 / line_thickness) == 0 ? lines.a : 0.0;
|
||||
ALPHA = var_model_normal.y > 0.99 ? 0.0 : ALPHA;
|
||||
}
|
||||
1
project/assets/shaders/height_lines.gdshader.uid
Normal file
1
project/assets/shaders/height_lines.gdshader.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cf5jptb8gp4u7
|
||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue