Author Topic: Is it possible to flush cached nodes? Running out of memory.  (Read 1757 times)

Flint Stryker

  • Jr. Member
  • **
  • Posts: 14
I have a component I'm working on. It's pretty cool I think. But it uses a minimum of 126 mask or terrain nodes, including a lot of blend nodes that combine everything, and when working with a 4K terrain this causes an out of memory crash. I assume this is because my component is caching 126 4K masks/terrains, which by my calculations adds up to..... a lot of bytes. This seems unnecessary, since all of those nodes are blended in pairs, and then those pairs are blended, and so on until there is only 1 blend of all 126 nodes. Is there any way to discard the cached nodes after the blend step?

Edit: attached the terrain file in case anyone's interested.
« Last Edit: January 07, 2021, 03:47:27 PM by Flint Stryker »

Alexis Vaisse

  • Administrator
  • *****
  • Posts: 189
No there is no way to tell Instant Terra to discard the cached nodes.

Instant Terra uses an automatic discard system. For instance, it's possible to compute the three Vector Warp Blur nodes of your project with 4K terrains and masks with a computer with 16 GB of RAM, even if the total amount of memory required to store the terrains and masks of all nodes is greater than 16 GB.

To get a quick visual feedback, Instant Terra doesn't compute nodes one by one, but all nodes at the same time (kind of). That's why it requires quite a lot of RAM to run.

If the amount of available RAM is too low, Instant Terra may not be able to compute a node (you will see the waiting animation forever), but it's not supposed to crash. If it crashes, it's a bug that we have to fix.

For your specific project, you can use Multi blend nodes. For instance, you can replace 4 Blend nodes by a single Multi Blend node. The number of nodes will be reduced and the project will require less memory.

BTW congratulations for your component, the results are awesome!

Flint Stryker

  • Jr. Member
  • **
  • Posts: 14
Thanks! I'll see if switching to multi blends helps solve the crashing problem. I should probably look into Python or GPU scripting solutions for some of this, though I'm not sure how I would run a vector warp node in script or if that's possible.

Alexis Vaisse

  • Administrator
  • *****
  • Posts: 189
A custom GPU node is probably the best solution.
There's no loop in GPU scripts, but as a vector warp is basically just one line of code (Input[DisplacementX, DisplacementY]), you will end up with a script of 64 lines, which is totally manageable.

You can for instance create 3 custom GPU nodes, one for each mode (average, min, max) and a simple component node with a Select node to choose between the 3 modes.

Flint Stryker

  • Jr. Member
  • **
  • Posts: 14
That's very elegant. I didn't realize it was such a simple algorithm. I'll have to try that, since the multi blend technique does not prevent crashing with 4K terrains. I'll submit a bug report when I can get around to it. I also discovered that adding more than 7 layers to a multi blend causes a very annoying bug, so I'll write that up as well.