-
-
Save andrew-wilkes/aab1d9e066cf19bc336bbbb0d940c648 to your computer and use it in GitHub Desktop.
Grid Shader for Godot
This file contains 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 canvas_item; | |
uniform float cell_size = 16; | |
uniform float cell_spacing = 2; | |
uniform vec4 line_color : hint_color; //Now called source_color in Godot 4 | |
varying vec2 v; | |
void vertex() { | |
v = VERTEX; | |
} | |
void fragment() { | |
COLOR.a = 0.; | |
float step_size = cell_size + cell_spacing; | |
float ratio = cell_spacing / step_size; | |
// Grid | |
if (fract(v.x / step_size) < ratio || fract(v.y / step_size) < ratio) COLOR = line_color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the the example. While using it in Godot 4 i noticed hint_color has been changed to "source_color" i suggest in making a comment with "//Now called source_color in Godot 4". Also the size variable does nothing it seems.