31 lines
650 B
Plaintext
31 lines
650 B
Plaintext
shader_type spatial;
|
|
render_mode depth_prepass_alpha;
|
|
|
|
uniform float max_distance = 2.0;
|
|
uniform float min_distance = 1.0;
|
|
|
|
void fragment() {
|
|
mat4 thresholdMatrix = mat4(
|
|
vec4(1, 9, 3, 11),
|
|
vec4(13, 5, 15, 7),
|
|
vec4(4, 12, 2, 10),
|
|
vec4(16, 8, 14, 6)
|
|
);
|
|
float dist = length(NODE_POSITION_WORLD - CAMERA_POSITION_WORLD);
|
|
if (dist < max_distance) {
|
|
int x = int(FRAGCOORD.x * 0.5);
|
|
int y = int(FRAGCOORD.y * 0.5);
|
|
float threshold = float(thresholdMatrix[x % 4][y % 4]) / 17.0;
|
|
|
|
//ALBEDO.r = threshold;
|
|
|
|
if (dist - threshold < 0.5) {
|
|
discard;
|
|
}
|
|
}
|
|
|
|
//ALBEDO = vec3(dist - 1.0);
|
|
//ALBEDO = COLOR.rgb;
|
|
//ALPHA = COLOR.a;
|
|
}
|