From 223fe8331f014fb1274f7651f7b253ad803c8828 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 19 Aug 2025 10:52:17 +0200 Subject: [PATCH] Auto-sync from SVN revision 64696 --- .../Tests/Runtime/VolumeComponents.meta | 8 --- .../UnifiedRayTracing/Common/TerrainToMesh.cs | 53 +++---------------- 2 files changed, 7 insertions(+), 54 deletions(-) delete mode 100644 Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta diff --git a/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta b/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta deleted file mode 100644 index d8224e70..00000000 --- a/Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b0b931e9e8088714d9ca21864da41d03 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs b/Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs index ea69502c..32e150e3 100644 --- a/Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs +++ b/Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs @@ -10,54 +10,15 @@ namespace UnityEngine.Rendering.UnifiedRayTracing { static private AsyncTerrainToMeshRequest MakeAsyncTerrainToMeshRequest(int width, int height, Vector3 heightmapScale, float[,] heightmap, bool[,] holes) { - int vertexCount = width * height; + int vertexCount = width * height; var job = new ComputeTerrainMeshJob(); + job.heightmap = new NativeArray(vertexCount, Allocator.Persistent); + for (int i = 0; i < vertexCount; ++i) + job.heightmap[i] = heightmap[i / (width), i % (width)]; - //WW1MOD This crashes when baking 4k terrains, as it tries to allocate a *2GB* Buffer!.. which is fine *here* but when it gets uploaded to GPU, it goes crashy or error, depending on dx-API/Driver - //Note heightmap size is always pow2+1 - //the "else" part is the original code - if (height == 4097) - { - const int halfSize = 2049; - int _vertexCount = halfSize * halfSize; - - Debug.Log("Downsizing Terrain heightmap mesh output to 2k to prevent crashes"); - - job.heightmap = new NativeArray(_vertexCount, Allocator.Persistent); - for (int i = 0; i < _vertexCount; ++i) - { - float h0 = heightmap[((i*2)+0) / (width), ((i*2)+0) % (width)]; - float h1 = heightmap[((i*2)+1) / (width), ((i*2)+0) % (width)]; - float h2 = heightmap[((i*2)+0) / (width), ((i*2)+1) % (width)]; - float h3 = heightmap[((i*2)+1) / (width), ((i*2)+1) % (width)]; - - job.heightmap[i] = (h0 + h1 + h2 + h3) / 4f; - } - - job.holes = new NativeArray((halfSize - 1) * (halfSize - 1), Allocator.Persistent); - for (int i = 0; i < (halfSize - 1) * (halfSize - 1); ++i) - { - bool h0 = holes[((i*2)+0) / (width - 1), ((i*2)+0) % (width - 1)]; - bool h1 = holes[((i*2)+1) / (width - 1), ((i*2)+0) % (width - 1)]; - bool h2 = holes[((i*2)+0) / (width - 1), ((i*2)+1) % (width - 1)]; - bool h3 = holes[((i*2)+1) / (width - 1), ((i*2)+1) % (width - 1)]; - - job.holes[i] = h0 || h1 || h2 || h3; - } - - height = width = halfSize; - vertexCount = _vertexCount; - } - else - { - job.heightmap = new NativeArray(vertexCount, Allocator.Persistent); - for (int i = 0; i < vertexCount; ++i) - job.heightmap[i] = heightmap[i / (width), i % (width)]; - - job.holes = new NativeArray((width - 1) * (height - 1), Allocator.Persistent); - for (int i = 0; i < (width - 1) * (height - 1); ++i) - job.holes[i] = holes[i / (width - 1), i % (width - 1)]; - } + job.holes = new NativeArray((width - 1) * (height - 1), Allocator.Persistent); + for (int i = 0; i < (width - 1) * (height - 1); ++i) + job.holes[i] = holes[i / (width - 1), i % (width - 1)]; job.width = width; job.height = height;