Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.74k stars 159 forks source link

Problem importing splatmap #145

Closed cptnron closed 4 years ago

cptnron commented 4 years ago

Hi, This is a great plugin, but importing a splat map isn't working for me. I am able to import the heightmap, but the splat map has no effect in the shader. If I use a custom shader and output the splat texture from the shader, it is all red. I am using a png file with the same dimensions as the heightmap. If I manually copy the splat file into the terrain directory, I can see the change, but the texture placement has large geometric artifacts (I assume it's using an internal format after importing). Any help is appreciated.
Thanks

Steps to reproduce:

Specs Mac OS X 10.14.4 Radeon Pro 560 Heightmap - current master branch Godot 3.2

Zylann commented 4 years ago

If I manually copy the splat file into the terrain directory, I can see the change, but the texture placement has large geometric artifacts (I assume it's using an internal format after importing).

The importer may need a fix, but there is (almost) no particular format in which the splatmap gets saved. It just needs to be an RGBA PNG texture with alpha compression turned off.

Do those geometric artifacts match the areas where alpha=0? Image editors very often "optimize" color data where alpha is zero because they assume invisible pixels can be compressed away. But for a splatmap, that still matters and must be turned off, if your software allows it. You need to make sure color channels are all preserved (otherwise it means you lost RGB information when saving your splatmap).

Zylann commented 4 years ago

The importer should be fixed in 9b27a733b464c0ac25cd3d07751e07bef94daa46

cptnron commented 4 years ago

Thanks - the importer works now. I am still seeing artifacts but I'll try to get to the bottom of it tomorrow. I am using Gimp on a Mac and I couldn't find anything about alpha compression but I did try setting the compression level to zero, but the result was the same. I also tried adding an alpha channel of all 0s or 1s but saw more or less the same effects.

Zylann commented 4 years ago

image

Save color values from transparent pixels is probably what I meant. I can't click on it though, dunno why. Probably cuz I don't have an alpha channel.

cptnron commented 4 years ago

Thanks, I am making some progress. I think some of my tests were thrown off by issues with the textures I was using, so I went back to the demo project to experiment with those textures. Also, I believe the artifacts had to do with varying the splatmap in the lite shader so I am using a modified version for now.

One thing I am confused about is when I painted the following pattern in the heightmap plugin Screen Shot 2020-04-13 at 7 24 10 PM And then I look at the resulting splatmap file in Gimp, it looked like this: Screen Shot 2020-04-13 at 7 24 53 PM

Going the other way is working now- I can modify or import the splatmap and see the results.

Zylann commented 4 years ago

A splatmap considers the alpha channel like a regular channel so yeah the image will look transparent in most parts of it.