-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to paint a lot of different textures #10
Comments
looks like the sampler3D got implemented. godotengine/godot#20597 |
Yep, didn't get the time to work on it yet |
@Zylann Any possibilty to impliment this? Is it an easy task, or does it require a large rewrite? |
@kimamb it needs to introduce a new type of splatmap and an entirely new shader. It will also look a bit different in quality, from the few tests I've done in the past. But so far I didnt get the time to get it implemented. |
@Zylann I see. If it's anything to go by; I would really apreciate if you could look at it, though I realize that you are a busy person. I believe that the two most important things to make this usable in a game is this and #55. I wish I knew enough to contribute to the addon,but this is way above my level of knowledge. |
+1 for this |
@omomthings Please don't bump issues without contributing significant new information; use the 👍 reaction button on the first post instead. |
I modified the shader to provide separate UV scale and opacity per channel. This allows us to scale a stone path separately from the grass or mountain. Also it allows us to use a "snow" texture (white w/ a noise texture for normal/roughness) and then paint it any color we want for dirt or other textures. We can also paint textures to avoid repeating patterns, then use the opacity as a colorist would. Here the color map opacity for the grass is turned off and for the mountain turned down. The left side is what it would look like in the regular shader. It was impossible to get a good looking blend between grass and colormap dirt without this. The shader cost is negligible, and the "extra" materials it provides can be a good workaround for the time being. I now have snow, stone path, grass, and rock. Then snow can be painted to unlimited other colors. This is brown snow depthmap blended with the grass. It took only a few seconds to paint the white snow texture, blend in the grass with the mottled brush on low opacity, then dump brown over the area. The grass has the color map turned off. And of course I could have added more colors to the dirt and blended them all. Since the color map is turned off for the grass we're free to blend the dirt without making a mess in the grass. Here's the shader so I don't have to fork and submit a PR. But it would be great if added to master. |
@tinmanjuggernaut it could be added to the main shader, probably using |
I started experimenting with a new kind of shader, and as you can see the amount of different textures is greatly increased: And in theory it can go up to 256. At the moment I made it so only textures with an odd index can blend with textures with an even index, while the others don't... it's a bit technical. If you try to paint them, it results in this: But it can probably be overcomed with careful painting, or maybe baking the map from a color-coded image with carefully chosen indexes using I-dont-know-which-algorithm. Smoke and mirrors :D |
Really nice! |
Well, yes and no, it's actually the first way I found how to paint it at all xD I had another idea but sounded too complicated and could still mess up. So for now I'm still experimenting, that workflow would need a whole section in the doc because there is a bit of setup to do. I should probably make a branch for people to try out, you could have some ideas. |
Looks very promesing. Yeah, it would be nice if you pushed it to a branch; so that we could try it. |
Pushed my WIP to the |
I just downloaded the texture array branch but I'm not sure how to use it. I've tried to switch to "Shader Type, Custom", |
@RonanZe it needs a whole doc section. There are a bunch of things to do before you can use it, although you did most of it.
Note that this is a WIP, there can be bugs and things that I have yet to figure out. |
Thanx! seem to works. Not in the right way --> it paint only flat colors. I didn't realize that texture array was the same has color atlas. |
I don't think it's any different from having more (but smaller) textures. Recent desktop/laptop GPUs all support 16384×16384 textures. Even 10-year-old NVIDIA Fermi GPUs do 🙂 Older GPUs like the GeForce 8/9 series are limited to 8192×8192, but these will most likely not work well with the GLES3 renderer anyway (which is a requirement for this plugin). |
Enable repeat flag in your texture import settings.
I hope that's actually not a limitation for the final game, because it does get imported as a texture array, not as is. So you can go higher if you like, in reality the imported texture will be 3D. It may consume as much memory though, unless compression settings work on these. I tried another way to kind of automatically assign sensible indexes and weight, but it's barely any better than odd-even. It's still really finnicky to paint. The potential is there, authoring just needs a lot more technique than a classic 4-texture splatmap. nVidia gamework's example also conveniently eludes that :p Other tools like MegaSplat in Unity use texture arrays, I just have no idea how they use them in such a way painting isn't a hassle. |
I also had to erase the .import dir. Without that, the texture stay locked (by the plug?) and no way to select the flag repeat. But I also feel the potential! 😋 |
I reported it godotengine/godot#38870 |
Not the more efficient way but can be a temp workaround before discovering a better system: I take twice the memory but then you can do additionnals checks after im.get_pixel(x,y) in the "for y ... for x" loops of the hterrain_brush.gd, if c.b > 0.5: But maybe it's to hacky or I don't have to whole picture 😄 |
@RonanZe I tried the
More indexes only dilute the problem but surely allow more wiggle room. It needs to be experimented. |
Ok, this is now merged to Take a look at the docs for more info: https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/doc/main.md#array-workflow |
Great! |
Closing this now that it's possible to paint many textures. That said, there is still room for improvement, so changes can still happen with this workflow. |
Master e51b7bd
|
Channels have no "color". What you see looks like an overstretch, bad UVs, global map not blending properly, or wrong mip. What are your shader settings, and the import settings of your texture array?
Looks different. Import settings got overwritten I guess. I had to reverse-engineer Godot's
It does have the same features as the other shaders, and uses the same packing convention.
It's actually more than that. As I said, it uses the same packing convention. If you want to use all features of the shader, you must make two texture arrays, so two RGBA atlases:
|
So assuming Godot did import your texture array correctly, I don't see anything wrong here. Maybe the problem is in the shader settings then. UV scale of 0 (like your screenshot shows) or globalmap fading too close are possible scenarios to cause this. Looks like there is an internal problem with the format of the index map as well. |
When I close and reopen Godot now in the editor it looks the same as in the game, with the rainbow borders. Once I start painting again, the textures shift and go back to the first image, with the borders looking somewhat smooth. Scale, blend distance or depth blending have no positive effect on the borders. |
Depth blending only works if you alpha-pack bump next to albedo. |
@Zylann Why not hiding the packed RGB+A optmization think behind the plugin? Right now, makes the changes on textures can be slow because you have to always repack the channels. And if you want to test several textures, it became a bit paintful. It would be good to have that also for Arrays. If arrays where not directly accessible in the Plug but Array where rebuild when you change one texture directly in Godot, it whould make the things easier. Is it because GDScript is to slow? |
@RonanZe it's not because GDScript is slow (well it does that slowly but it does the job), and in fact I have a branch in which I tried to implement a tool for that. The problem is how to integrate that nicely... For the classic shader, packing was relatively easy with the channel packer, but atlasing is one more step to go through. I can consider merging this "tool" though, but it still needs some work to support either regular textures or atlased ones. |
Currently the plugin is limited to 4, or maybe up to 8 different textures. Adding more would drop performance significantly.
In order to support more, we could use texture arrays in a new shader, but Godot doesn't support them yet.
Writing an atlas-based shader could help emulating texture arrays, however it has annoying limitations such as pixel bleeding with mipmaps and filter.
Eventually there should be a more flexible API so shaders can be switched and the editor can adapt to which features it supports.
Depends on godotengine/godot#9008
The text was updated successfully, but these errors were encountered: