ntg-unity icon indicating copy to clipboard operation
ntg-unity copied to clipboard

Out of Bounds Error with smoothing enabled

Open Sternenwarte88 opened this issue 1 year ago • 5 comments

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.<CreateInspectorElementUsingIMGUI>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.

Sternenwarte88 avatar Nov 20 '23 17:11 Sternenwarte88

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?

hayden-donnelly avatar Nov 20 '23 18:11 hayden-donnelly

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

kellycode avatar Nov 24 '23 14:11 kellycode

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

hayden-donnelly avatar Nov 25 '23 01:11 hayden-donnelly

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.

StephanLoecher avatar Nov 25 '23 17:11 StephanLoecher

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

Slaverdure06 avatar Sep 05 '24 02:09 Slaverdure06