ajout d'un terrain infini et la possibilité de planter n'importe où

This commit is contained in:
2025-11-30 16:53:07 +01:00
parent 72ffa0b222
commit 8917a02a7b
63 changed files with 2847 additions and 1190 deletions

View File

@@ -0,0 +1,29 @@
shader_type canvas_item;
uniform sampler2D red_overlay_tex: repeat_enable, filter_nearest;
uniform sampler2D green_overlay_tex: repeat_enable, filter_nearest;
uniform sampler2D blue_overlay_tex: repeat_enable, filter_nearest;
uniform float scale = 0.006944444; // calculated by 1/texture size e.g. 1/144
varying vec2 world_position;
void vertex(){
// calculate the world position for use in the fragment shader
world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}
void fragment() {
float mix_amount = floor(COLOR.r);
// sample the overlay_tex using worldPos
vec4 red_overlay_color = texture(red_overlay_tex, world_position * scale);
vec4 green_overlay_color = texture(green_overlay_tex, world_position * scale);
vec4 blue_overlay_color = texture(blue_overlay_tex, world_position * scale);
float origin_alpha = COLOR.a;
// combine original color and overlay color together
COLOR = mix(COLOR, red_overlay_color, floor(COLOR.r));
COLOR = mix(COLOR, green_overlay_color, floor(COLOR.g));
COLOR = mix(COLOR, blue_overlay_color, floor(COLOR.b));
COLOR.a = origin_alpha;
}

View File

@@ -1,21 +0,0 @@
shader_type canvas_item;
uniform sampler2D overlay_tex: repeat_enable, filter_nearest;
uniform float scale = 0.006944444; // calculated by 1/texture size e.g. 1/144
varying vec2 world_position;
void vertex(){
// calculate the world position for use in the fragment shader
world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}
void fragment() {
// only apply overlay_tex on the fully red parts of the original tiles
float mix_amount = floor(COLOR.r);
// sample the overlay_tex using worldPos
vec4 overlay_color = texture(overlay_tex, world_position * scale);
// combine original color and overlay color together
COLOR = mix(COLOR, overlay_color, mix_amount);
}