Godot Version
4.3
Question
`Could someone explain to me how to draw with textures? I recently saw a dev from the game lumencraft and there you could draw with various resources on the map. https://www.reddit.com/r/godot/comments/rh2g91/lumencraft_devlog_1_lets_destroy_this_world/
or as in dungeondraft https://youtu.be/7yD0hHzKJAE w 17:33
I don’t know what it’s called professionally and I don’t really know how to find it, and I’d like someone to explain it to me in a relatively simple way.
`
maybe a “map”? I don’t think there is one name for, they are using standard color channels for other data, this is used everywhere in games. The most common would be normal maps, heightmaps are another.
The technique is recognizing that images are data and can be used as such. In this case they used green to represent different texture ids and red for a sort of terrain “health”. This should be achieved with a shader using texture
to get the fragment data, then another texture
to draw based on that data.
vec4 terrain_data = texture(terrain_texture, terrain_uv);
vec4 final_draw_color;
if (terrain_data.g == 1.0) { // using green channel
final_draw_color = texture(green_texture, terrain_uv);
} else {
final_draw_color = texture(not_green_texture, terrain_uv);
}
final_draw_color *= terrain_data.r; // darken if "health" is low
Dungeondraft is a robust map editor/drawing tool though, they have drawn and programmed custom brushes.