ozikazina / Hydra

Blender hydraulic erosion addon using OpenGL.
MIT License
21 stars 3 forks source link

Issue with the erosion solver(I think it is the erosion image) #12

Open joelRVC opened 1 month ago

joelRVC commented 1 month ago

Hi. First of all I want to thank you for creating this, it looks very interesting. I tried it with a mountain model and when the geonodes preview appears, certain parts of geometry jump to infinite locations. I thought it was because of my model so I tried with Suzanne but I get similar behavior, I looked for the image generated by the erosion and in both scenarios it has certain pixels with errors.

I tried with blender 4.3 beta and also with 4.0, in the latter I show the image generated by the erosion:

Blender 4.3b:

https://github.com/user-attachments/assets/ce16a1c3-35e9-4612-84b3-8a70fb540959

Blender 4.0.2:

https://github.com/user-attachments/assets/41a1f346-4367-484a-b89e-61587804c90c

{B6EF1716-D05B-4535-9C49-66712A1339FD}

ozikazina commented 1 month ago

Hello. The latest release doesn't yet support overlapping geometry (planets, Susanne and so on), but I've never seen it fail like that. What GPU do you have and what operating system are you using?

I'll try it with the release version tommorow, it's possible I fixed the issue since then: obrazek

joelRVC commented 1 month ago

Thanks for the response. I have an Intel UHD 620 integrated GPU and a Radeon RX 560 discrete GPU.

I'll try it with the release version tommorow, it's possible I fixed the issue since then:

Thanks, I'll wait for that release then.

ozikazina commented 1 month ago

Could you please send a heightmap generated by the Hydra - Heightmaps panel and a heightmap after thermal erosion? The heightmap for susanne seems to generate correctly on your machine but then something goes very wrong during erosion.

joelRVC commented 1 month ago

I'll share an example with the mountain I mentioned before. It seems that the heighmap is generated without problems.

{0C99583A-0F29-41B4-8EFC-CCBE963CAF74}

With the heightmap after erosion, do you mean the image called displacement?

{7E0C6883-EA20-4579-8F81-24A55AD80899}

ozikazina commented 1 month ago

I meant the heightmap result - you can export it using the image button in the Result section (next to the geometry nodes symbol).

My only guess right now is that the erosion shaders launch too many threads for older GPUs. Check the console after launch for any errors, but if it runs, then the shaders probably compile fine. I'll try to send you a development version next week with modified shaders.

ozikazina commented 1 month ago

Here is a modified version of Hydra: Hydra_1.2.0dev.zip It has a panel in 3D View which will launch some tests to check how your system behaves. It creates two images and also prints OpenGL info in the console. I've added some memory barriers to thermal erosion and clamped the result, so it at least shouldn't explode to infinity. You could also try to run thermal erosion multiple times to see if it breaks in the exact same places. tabs tests

joelRVC commented 1 month ago

Hi. When I try to install this version in the addon menu a warning appears "there is no moderngl module", nor does the submenu where external dependencies could be installed. So I installed them manually but when I restart blender I get this notice in the console:

ModernGL not found.
Traceback (most recent call last):
  File "E:\RECURSOS Y software especializado\Blender\Blender versiones anteriores o experimentales\daily\blender-4.3.0\4.3\scripts\modules\addon_utils.py", line 407, in enable
    mod = importlib.import_module(module_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\RECURSOS Y software especializado\Blender\Blender versiones anteriores o experimentales\daily\blender-4.3.0\4.3\python\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\joels\AppData\Roaming\Blender Foundation\Blender\4.3\scripts\addons\Hydra\__init__.py", line 43, in <module>
    from Hydra.addon.preferences import get_exports
  File "C:\Users\joels\AppData\Roaming\Blender Foundation\Blender\4.3\scripts\addons\Hydra\addon\__init__.py", line 3, in <module>
    from Hydra.addon import preferences, properties, ops_heightmap, ops_common, ops_object, ops_image, ui_common, ui_image, ui_object, ui_nodes, ops_nodes
  File "C:\Users\joels\AppData\Roaming\Blender Foundation\Blender\4.3\scripts\addons\Hydra\addon\ops_heightmap.py", line 6, in <module>
    from Hydra import common
  File "C:\Users\joels\AppData\Roaming\Blender Foundation\Blender\4.3\scripts\addons\Hydra\common.py", line 3, in <module>
    import moderngl as mgl
ModuleNotFoundError: No module named 'moderngl'

The hydra panel in the viewport does not appear.

joelRVC commented 1 month ago

I meant the heightmap result - you can export it using the image button in the Result section (next to the geometry nodes symbol).

My only guess right now is that the erosion shaders launch too many threads for older GPUs. Check the console after launch for any errors, but if it runs, then the shaders probably compile fine. I'll try to send you a development version next week with modified shaders.

Btw, I also got what you asked for(with release version 1.1.0). In this case it is a cone-shaped cylinder with subdivisions, the erosion map seems to come out fine so your assumption could be correct.

{0BF4C414-AF39-41B8-8856-69ED95A089FB}

ozikazina commented 1 month ago

Hello and thank you for the heightmap. If both the generated heightmap and the eroded heightmap seem correct then it might just be something during their subtraction. You can also try to generate a landscape from the image (Decouple button in the Image viewer Hydra panel, and then generate in the Landscape panel). There might still be some invalid values that are hard to see.

Here is a slightly corrected version of the addon (I messed up an UI element in the preferences, the previous version would throw an exception anyway, sorry): Hydra_v1.2.0dev1.zip

As for the moderngl issue, you could try deleting everything with moderngl and glcontext in Blender's python packages (C:\Program Files\Blender Foundation\Blender X.X\X.X\python\lib\site-packages on Windows) and reinstall it if you haven't done so. I've personally had an issue where Blender was reaching for system python's packages too for some reason. I must admit that getting extra libraries into Blender is a little scuffed right now though.

joelRVC commented 1 month ago

An apology for the delay. I just tested the version you sent, although now I focused on running the tests you added to the panel. Since it is data, I don't know what the results mean, so I am attaching the images that were generated and the test file in which I ran the addon (download the .txt and change the extension to just .rar, then unzip).

{A227AE7A-5817-4EA1-B1BB-EFB80DDA1AFC}

hydra test.rar.txt

ozikazina commented 1 month ago

Thank you for the data. All individual shader functions seem to work fine and so do large thread blocks, so my idea was incorrect. I may have discovered a bug in moderngl with AMD and texture binding, but that doesn't come up in the erosion algorithms used. Here is a second set of tests (you only need to replace the file in the addon's root): hyd_tests.zip

It mainly tests thermal erosion a bunch of times because so far it seems that the addon literaly just fails at subtracting two images.

joelRVC commented 4 weeks ago

{AD87D5CE-98CB-474A-A679-FA2CFD644C7E} textures.rar.txt

ozikazina commented 4 weeks ago

Thanks again. I'm gonna be honest, I still have no idea what's going on. It seems now that there is some unwanted dependency between erosion runs when it's on your system. I wanted to write a proper suite of unit tests before, so it looks like I'm going to have to now if you don't mind running them 😅 I'll have to do it for every step of the pipeline, so writing them will take me some time.

joelRVC commented 4 weeks ago

Of course, I put my help at your disposal.

ImagePlant commented 3 weeks ago

I'm happy to help test as well if need be. I'm running an Arc A770 gpu on Win11.

On Sun, Oct 27, 2024 at 1:07 PM joelRVC @.***> wrote:

Of course, I put my help at your disposal.

— Reply to this email directly, view it on GitHub https://github.com/ozikazina/Hydra/issues/12#issuecomment-2440158169, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTHPHB2KD6WUAKAENKK54TZ5VBYLAVCNFSM6AAAAABPK4RFNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBQGE2TQMJWHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>