mohsenph69 / Godot-MTerrain-plugin

A GDExtension plugin which give godot the ability to produce highly optimized Terrain for Open world games
MIT License
478 stars 25 forks source link

godot crashes when i try to paint a different texture. #66

Closed lucasthomaz97 closed 3 days ago

lucasthomaz97 commented 1 week ago

image this warning is appearing but i dont know how to create a splatmap since the interface is different from any tutorial i found.

i'm using an array texture, just sampling the colors i want to prototype, this is the reason i'm using just 1 px per texture, i would like to use a different method importing the textures separated, but i did not discovered how to do this, this is the texture i'm using: color_scheme

when i try painting with a different layer than the one that covers the entire terrain, godot just crashes.

https://github.com/user-attachments/assets/5ff791d6-e74d-487f-9f49-8422b1b94031

as shown in this capture, everytime i open the scene, the create box is unmarked, i even need to set it by using a script when i wanted to run the scene, is this a bug or a feature?

lucasthomaz97 commented 1 week ago

update: i tried using a 16bits bigger texture, but it keeps the same behavior color_scheme

lucasthomaz97 commented 6 days ago

today i discovered that the color layer creator option is not appearing in the tools menu image i'll try using it running the scene directly

lucasthomaz97 commented 6 days ago

I discovered that the way textures and splatmaps are handles have changed, which means i was doing wrong, this addon is pretty powerful in functionality, but it really lacks documentation at the point it's really hard to get into, i felt like i had to reverse engineer the addon to understand what was wrong and figure for myself how to use it. i can help writing documentation if you want. Now i'm really struggling to paint colors without getting pixelated, specially in the lower sizes brushes. also the colors are kinda more clear than it's supposed to be. since i want to make an almost flat colors game with toon shading, i really need to use it this way, this is the kind of style i want: image

this is how it's looking right now, notice the difference between the color of the brush and the color in the terrain, also notice the differentce between the bigger size brush and the lower size one. image I am using texture compression QOI and image format RGBA8, i already tried many other formats, including gzip compression, but it's not looking good at all. what can i make to improve it?

lucasthomaz97 commented 4 days ago

I solved the problem of the pixelated or blurry color transitions by using this shader approach:


void fragment(){
    vec4 splatmap = texture(mterrain_splatmap, region_uv);
    vec3 albedo = vec3(0.0);

    // Aplicar as cores de forma constante com base no limiar
    if (splatmap.r > threshold) {
        albedo = grass_color.rgb;
    } else if (splatmap.g > threshold) {
        albedo = stone_color.rgb;
    } else if (splatmap.b > threshold) {
        albedo = ground_color.rgb;
    }
    ALBEDO = albedo;
}

Also, if the addon code don't find the brush/layer you choose, godot crashes. I found out how to texture paint, the documentation needs to be updated for yesterday! i suggest for the contributors to implement some error handling in the code to prevent these crashes and return some error messaging for the user, i can't help just because i don't have knowledge on C++.

lucasthomaz97 commented 3 days ago

I found the problem, i'll open another more specific issue.