novaia / ntg-unity

Neural Terrain Generation package for Unity.
Apache License 2.0
29 stars 3 forks source link

Out of Bounds Error with smoothing enabled #2

Open Sternenwarte88 opened 11 months ago

Sternenwarte88 commented 11 months ago

Hey, don´t be harsh with me, it´s my first issue and I hope it´s okay, I got an out of bound error when I got smoothing enabled.

IndexOutOfRangeException: Index was outside the bounds of the array. NeuralTerrainGeneration.TerrainHelper.SetTerrainHeights (UnityEngine.Terrain terrain, System.Single[] heightmap, System.Int32 width, System.Int32 height, System.Single heightMultiplier, System.Boolean scale) (at Assets/NeuralTerrainGeneration/Scripts/TerrainHelper.cs:40) NeuralTerrainGeneration.NeuralTerrainGeneratorTool.FromScratchGUI (UnityEngine.Terrain terrain) (at Assets/NeuralTerrainGeneration/Scripts/NeuralTerrainGeneratorTool.cs:282) NeuralTerrainGeneration.NeuralTerrainGeneratorTool.OnInspectorGUI (UnityEngine.Terrain terrain, UnityEditor.TerrainTools.IOnInspectorGUI editContext) (at Assets/NeuralTerrainGeneration/Scripts/NeuralTerrainGeneratorTool.cs:122) UnityEditor.TerrainInspector.OnInspectorGUI () (at <7aeb7d7a52d04045b8a1c734633fa931>:0) UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.b__0 () (at <7aeb7d7a52d04045b8a1c734633fa931>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

I tried to debug with rider and noticed that in the function, rider debugger didn´t pass this following logic:

    float[,] newHeightmap = new float[width+1, height+1];
        for(int x = 0; x < width; x++)
        {
            for(int y = 0; y < height; y++)
            {
                newHeightmap[x, y] = heightmap[x + y * width] * scaleCoefficient;
            }
        }

It´s line 35 on TerrainHelper.cs.

If I turn of smoothing, the Terrain gots without errors generated. For reproduction, I made a new Terrain and I tried an Demo scene, where it also happends.

Worker type I tried it with different types, also Auto and Stigma and Kernel are set to Kernel:6 Stigma:3. I also tried different numbers but every time kernel /2 for stigma.

hayden-donnelly commented 11 months ago

Hey, thanks for reporting this. Which Unity version are you on? Also did you install locally by cloning this repo, or did you install through the asset store?

kellycode commented 11 months ago

Took a look at this issue: Downloaded from asset store an hour ago. Same error with smoothing enabled. Created default terrain with no changes, no mats. Only happens with Worker Type "Auto" or "Compute Precompiled". All other workers work fine with the exception of "C Sharp Ref" seems to stick in a "Compiling Scripts" thread (I let it run for five minutes and killed the task).

Otherwise, extremely nice asset, very useful. Thank you

Unity Version 2022.3.13f1 OS: Windows 11 Version 10.0.22621 Build 22621 NVIDIA GeForce RTX 3070

hayden-donnelly commented 11 months ago

Thanks for the info. I'll fix this as soon as I have the time.

StephanLoecher commented 11 months ago

Hey Sorry, was longer not here, ehm yeah I got it from the Asset Store and got nearly the same specs. Only got an Nvidia GTX 1050 Ti.

Slaverdure06 commented 2 months ago

Any update ? Stated using it from the asset store and the problem is still there!