Browse Source

Auto-sync from SVN revision 64696

ww1dev/hdrp17/svn
Nico de Poel 6 months ago
parent
commit
223fe8331f
  1. 8
      Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta
  2. 39
      Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs

8
Packages/com.unity.render-pipelines.core/Tests/Runtime/VolumeComponents.meta

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b0b931e9e8088714d9ca21864da41d03
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

39
Packages/com.unity.rendering.light-transport/Runtime/UnifiedRayTracing/Common/TerrainToMesh.cs

@ -12,44 +12,6 @@ namespace UnityEngine.Rendering.UnifiedRayTracing
{
int vertexCount = width * height;
var job = new ComputeTerrainMeshJob();
//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<float>(_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<bool>((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<float>(vertexCount, Allocator.Persistent);
for (int i = 0; i < vertexCount; ++i)
job.heightmap[i] = heightmap[i / (width), i % (width)];
@ -57,7 +19,6 @@ namespace UnityEngine.Rendering.UnifiedRayTracing
job.holes = new NativeArray<bool>((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;

Loading…
Cancel
Save