Zylann / godot_heightmap_plugin

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

Brush is offset from cursor #142

Open andersmmg opened 4 years ago

andersmmg commented 4 years ago

Describe the bug The brush circle if offset from where my cursor is, and it's further off the further I am from the terrain. Makes editing it really hard, especially since the offset isn't always the same so drawing something like a circle ends up as a sort of tilted oval. I've had the problem on multiple projects, but haven't been able to reproduce it when I try.

To Reproduce It only happens sometimes, but I still have yet to find a fix. A bit after creating a terrain, one day it'll just be way off. If you see any errors in the console, that may also help.

Expected behavior The brush should stay aligned with the cursor.

Screenshots terrainnope

Environment

Zylann commented 4 years ago

Did you transform the terrain? (scale, translation, rotation?) I can't reproduce this so far.

andersmmg commented 4 years ago

It has happened when I did that, but no I didn't this time or some other times

On Sun, Apr 12, 2020, 8:04 AM Marc notifications@github.com wrote:

Did you transform the terrain? (scale, translation, rotation?)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zylann/godot_heightmap_plugin/issues/142#issuecomment-612619862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2HVO2OX2FG5QAQQSSDC5DRMHC6RANCNFSM4MFYOBNQ .

Wallace99 commented 4 years ago

You don't have the editor perspective set to half resolution do you?

andersmmg commented 4 years ago

I don't, but I have done that sometimes. Could it affect it if it's not currently on half resolution now but it has been recently? Though it's also happened on projects I never used half resolution on.

On Thu, Apr 16, 2020, 5:34 PM Wallace99 notifications@github.com wrote:

You don't have the editor perspective set to half resolution do you?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zylann/godot_heightmap_plugin/issues/142#issuecomment-614949310, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2HVO4JEFT44LRLOH23XNLRM6IW5ANCNFSM4MFYOBNQ .

Wallace99 commented 4 years ago

I'm not too sure, I know I've had the same thing happen when editor set to half resolution using this plugin: https://github.com/Zylann/godot_scatter_plugin which I assume uses a similar way of placing stuff at the cursor

Strange that it only happens sometimes though

Zylann commented 4 years ago

@Wallace99 I fixed the half-resolution thing with the terrain plugin but not with scatter

andersmmg commented 4 years ago

So far scatter hasn't done that to me, though it does sometimes place like 3 of the same scene in the same place with one click. It's annoying, but otherwise scatter rocks

On Thu, Apr 16, 2020, 6:47 PM Marc notifications@github.com wrote:

@Wallace99 https://github.com/Wallace99 I fixed the half-resolution thing with the terrain plugin but not with scatter

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zylann/godot_heightmap_plugin/issues/142#issuecomment-614971766, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2HVO75IZMOGC44BXZIAWDRM6RLNANCNFSM4MFYOBNQ .

TokisanGames commented 4 years ago

The cursor is offet on Windows when the brush size is 1 or 2. When the player is a size of 1 or 2, that's the size I want to paint at. But at 1 or 2, the cursor bounces all over the place, except where I want it (probably popping between vertices), but it's not aligned with the cursor. It's very annoying. My 1k Terrain is not transformed.

I have not had it as far off as Op, but I have had it non-responsive, especially when in ortho view, but only sometimes.

Zylann commented 4 years ago

@tinmanjuggernaut you realize size 1 or 2 is barely a pixel in terms of heightmap resolution, right^^ It bounces because of the pixel grid... the plugin isn't really meant to be used at such small scales. Unless the first screenshot has terrain cells the size of the screen, I think the offset shown is something else entirely.

TokisanGames commented 4 years ago

I didn't realize that. But in game, my 1x2x1 character might walk on a 1-3 width path. That's not a tiny scale. The default cube is 1x1x1. A path or a groove that's 5-10, which is easier to paint, is unnaturally big and the cursor doesn't paint at size 1 very well. Maybe I could scale everything else up.

Zylann commented 4 years ago

@tinmanjuggernaut eventually the brush could be made to use interpolation so it can paint "in between" pixels, although it will significantly lower its speed, particularly with the GDScript backend. So that would only be viable at small sizes (still, requires to dupe all paint operations with interpolation logic). If you really need this you can make a new issue.

RonanZe commented 4 years ago

Aren't you using a C++ lib now?

Zylann commented 4 years ago

@RonanZe I do, but it only runs on Windows 64 bits for Godot 3.2.1 users specifically. And that would also slow it down, although surely much less. The annoying one is GDScript really. It still exists because porting GDNative to all platforms is quite a challenge. @Calinou experimented with CI but I don't have experience in that yet

RonanZe commented 4 years ago

Can't you use some kind of shader layer paint tech? Paint directly to the graphic card they saved on the drive when possible?

The new shader capacity in Godot 4 seems to give some possibilites in that direction: https://godotengine.org/article/godot-40-gets-global-and-instance-shader-uniforms

Is there a fast function in Godot to save the texture on the drive?

Zylann commented 4 years ago

@RonanZe yes I would like to move to GPU later but that's going to be Godot 4. Godot 3 can somewhat do that too, but it's too limited and calls for way too many changes and issues with the features supported by this plugin. It's still not related to the topic though, it's already been around in this old issue https://github.com/Zylann/godot_heightmap_plugin/issues/17

Calinou commented 4 years ago

@Zylann Maybe brush interpolation could be enabled only at very low brush sizes. This would reduce its performance impact on day-to-day use.

Gyeff commented 4 years ago

I have also noticed this issue on my low resolution game, I assumed it was because of the low resolution. Mainly occurs with small brush as mentioned already.

This is not a major problem in my opinion (or even a problem at all really). This is because it's not difficult to work even with the displaced circle indicator. Just pretend like the circle is under the mouse because that's where the painting actually takes place.

I personally wouldn't use 1-2 all the time. Only use it for minor adjustments if necessary. This is because with a brush that small there are some other problems too. For example, with flatten tool on 100% opacity, it doesn't pull the verts all the way up to the flatten level, it pulls verts as if the brush has some opacity.

Brush works perfectly at 5 and above.

A thing that you can do with low scale games is try to play with the x scale and z scale of the heightmap. You need to do this anyway because otherwise low scale moving sprites and objects appear to clip through terrain in certain areas with big height changes. This is likely because of vert arrangement and inability to calculate collisions 100% property when the verts are so far away from eachother.

Zylann commented 4 years ago

Note that subpixel precision is likely not what @andersmmg has experienced in the first post, because it looks like it happened at a "regular" size (until further info is known?) and had very large offset. If subpixel precision is desired it has to be another issue.