Commit Graph

598 Commits

Author SHA1 Message Date
chris tchou
f480a146f2 Fix for an editor crash in grass builder when the landscape component scene proxy is removed while grass generation for that component is in the pipeline
Also removing the grass data bIsDirty flag, that is no longer used.

#rb jonathan.bard
#jira UE-222387

[CL 36753681 by chris tchou in 5.5 branch]
2024-10-01 18:52:46 -04:00
serge bernier
29d7e5ecc0 DynamicShaderPreloading. Removed changes to CollectPSOInitializers functions so that we dont have to do deprecations. Moved all code logic for PSO shader preloading in one location (AddGraphicsPipelineStateInitializer) to improve code maintenance.
#rb Kenzo.Terelst, daniele.vettorel

#ushell-cherrypick of 36478045 by serge.bernier (second/final submit)

[CL 36748004 by serge bernier in 5.5 branch]
2024-10-01 17:50:10 -04:00
serge bernier
f3620d4994 Support Dynamic shader preloading. Similar to PSOPrecaching, we can load shaders on demand instead of preloading all of them when we load the package. This reduce the memory footprint on shaders since we only load shaders that will be used for rendering. Shader preloading also support the same code logic to delay the creation of the prender proxy when the shaders are not finished loading.
Save up to 16MB on some platforms.

#rb daniele.vettorel, danny.couture, Kenzo.Terelst
#tests 66d8b4154a47dde1dd226334



#ushell-cherrypick of 36036431 by serge.bernier (first of 2 submits)

[CL 36747837 by serge bernier in 5.5 branch]
2024-10-01 17:48:22 -04:00
jonathan bard
f382badf50 Moved landscape visibility layer info asset to from EditorLandscapeResources to EngineResources so that it doesn't get stripped on cook when "Exclude editor content when cooking" is used
#jira UE-224662
#rb luc.eygasier

#virtualized

[CL 36449768 by jonathan bard in 5.5 branch]
2024-09-19 16:16:43 -04:00
jonathan bard
2bec4499eb [Backout] - CL36437966
#fyi jonathan.bard
Original CL Desc
-----------------------------------------------------------------
Moved landscape visibility layer info asset to from EditorLandscapeResources to EngineResources so that it doesn't get stripped on cook when "Exclude editor content when cooking" is used

#jira UE-224662
#rb luc.eygasier

#virtualized

[CL 36446330 by jonathan bard in 5.5 branch]
2024-09-19 15:08:41 -04:00
jonathan bard
2c993c2dae Moved landscape visibility layer info asset to from EditorLandscapeResources to EngineResources so that it doesn't get stripped on cook when "Exclude editor content when cooking" is used
#jira UE-224662
#rb luc.eygasier

#virtualized

[CL 36437966 by jonathan bard in 5.5 branch]
2024-09-19 12:28:31 -04:00
jonathan bard
231fcb2cfa Fix for crash when trying to make a landscape proxy "modified" on PostLoad when the main landscape actor has not registered to its ULandscapeInfo yet
#rb luc.eygasier

[CL 35823351 by jonathan bard in ue5-main branch]
2024-08-27 09:29:49 -04:00
chris tchou
b2ec444f70 Fix an issue when cooking levels containing multiple instances of the same level in a commandlet.
Previously it would warn about duplicate landscape GUIDs during cook, because it would load the level with the level instances, but not apply the unique instance GUIDs to each landscape.

This change applies the instance GUID when level instances are loaded in a commandlet, but then restores the original GUID on save.

#rb jonathan.bard

[CL 35806814 by chris tchou in ue5-main branch]
2024-08-26 15:13:23 -04:00
jeanfrancois dube
cd4867be82 [Backout] - CL35490350
[FYI] jeanfrancois.dube
Original CL Desc
-----------------------------------------------------------------
[Landscape] Fix Landscape proxies registering their landscape info object into the main world instead of their outer world.
The logic behind this changes comes from the fact that WorldCreationEventFunction and WorldDestroyEventFunction uses the outer world to register and unregister landscape info objects.
Also outered landscape info objects to the world they are registered to just to make it clear to what object they belongs to.

#rb Sebastien.Lussier, Jonathan.Bard
#p4v-cherrypick 34932525, 34940115

[CL 35563023 by jeanfrancois dube in ue5-main branch]
2024-08-15 10:41:05 -04:00
jeanfrancois dube
d0802e38a0 [Landscape] Fix Landscape proxies registering their landscape info object into the main world instead of their outer world.
The logic behind this changes comes from the fact that WorldCreationEventFunction and WorldDestroyEventFunction uses the outer world to register and unregister landscape info objects.
Also outered landscape info objects to the world they are registered to just to make it clear to what object they belongs to.

#rb Sebastien.Lussier, Jonathan.Bard
#p4v-cherrypick 34932525, 34940115

[CL 35490371 by jeanfrancois dube in ue5-main branch]
2024-08-13 07:25:28 -04:00
jonathan bard
b36160ec29 Made collision settings LandscapeOverridable
#rb chris.tchou
#lockdown marc.audy

[CL 35372569 by jonathan bard in ue5-main branch]
2024-08-07 12:51:42 -04:00
jonathan bard
c70b8af6e7 Introducing landscape batched merge (activated by CVar : landscape.EditLayersLocalMerge.Enable 2): complete refactor of the landscape edit layers merge algorithm to solve the taxing GPU memory requirements that global merge has and serve as the basis for future features (new weight-blending methods, partial exports, ...) and performance and workflow improvements (deterministic editing of partially-loaded worlds, local updates, removal of useless weightmap allocations, ...)
Unlike local merge (landscape.EditLayersLocalMerge.Enable 1), batched merge is backwards-compatible with BP brushes and will therefore replace both global merge and local merge in the near future. However, in order to maintain full backwards-compatibility, existing BP brushes will still act as they do now wrt determinism, requiring the entire world to be loaded by default. This means that as long as a landscape uses existing and not-yet converted brushes like Landmass, Water, etc., it will effectively act as global merge, with the same memory constraints as the current ones.
It also supports both vertical (in between edit layers) and horizontal (in between paint layers) blending, which allows legacy weight-blending to still work but opens up several possibilities in term of paint layers blending improvements.

Details:
* ILandscapeEditLayerRenderer is an interface (UInterface, actually) to implement for any element that needs to write heightmaps/weightmaps/visibility maps. These can be anything (edit layers, BP brushes, actors, components, ...), which streamlines the rendering/blending capabilities while maintaining backwards-compatibility
* UE::Landscape::EditLayers::IEditLayerRendererProvider is an interface to implement in order to provide a sequence of ILandscapeEditLayerRenderer to the landscape. This will be called on-demand when merging the landscape, which means the landscape dynamically retrieves its active renderers instead of relying on the landscape actor's data to do so. This solves the issue of having to checkout the landscape when adding/removing an element (e.g. a BP brush) to it. BP brushes are still supported, but things like landscape patch components can now be trivially added to a sequence of render operations without checking out the landscape actor
* The merge operation is now generic and is split into several render batches (instead of one large render, the size of the entire loaded landscape), hence the name. Each batch is sized automatically so that it contains a minimal amount of weightmaps and a minimal amount of landscape components.
* A component dependency analysis is run in order to maximize the amount of components to render in a given batch while trying to respect the optimal batch size (CVar landscape.EditLayersLocalMerge.MaxResolutionPerRenderBatch, default value : 1024) If a given component depends on components outside the batch, though, it will either be rendered in another batch (if possible) or the batches will be made large enough to render these (which allows the system to be compatible with existing BP brushes such as Water, but also prevents batched merge to solve the GPU memory requirements that global merge has)
* The merge is split into the following phases :
1. Retrieval of edit layer renderers and their associated states for the various merge types (supported/enabled for heightmaps/weightmaps/visibility)
At this point, the user can selectively change the enabled state of the supported renderers, which allows to customize the merge operation without mutating the landscape state (e.g. only keeping the layers under edit layer N enabled)
2. Trim the unneeded renderers for the requested merge operation (disabled renderers, unneeded weightmaps, etc.)
3. (weightmap merge only) Analyze the renderers' weightmaps usage and divide the renders into several "render groups", that is, a set of weightmaps rendered together because they have a(n horizontal) dependency. Each render group will be rendered separately (i.e. reduces the memory requirements of weight-blending to the minimum)
4. Each renderer provides a list of "render items", which contain locality information (where does this render item outputs data? what input data does it require? does it output heightmap/weightmap/visibility? what weightmap(s) does it output?) and a full component dependency analysis is then run on all renderers/requested components
5. The work is split into several batches, each batch into several render steps : for each render group, there's one step per active renderer, and one last step : a simple callback, which the user can attach to, which allows to retrieve the data that has been rendered for this render group for this batch, i.e. a portion of the merge landscape data, before the render target it was using gets repurposed for another batch/render group.
Currently, this is where the readback of heightmaps/weightmaps to the final texture is done and eventually, the same merge can be repurposed by using another callback and, for example, copying into a transient render target (partial renders), or an image on disk (partial exports)
6. The list of render batches and render steps is executed. Some renderers are automatically added to mix (e.g. default data rendering, to provide the initial clear, at the beginning, and "legacy" weight-blending and normals rendering, both at the end of the merge process) and each batch also has a list of "validity" render targets (one per target layer), which is nothing else than a binary "stencil" buffer, masking the components that are *not* in a given batch. These are not implemented as stencil buffers, though, because we eventually might need access to them on the BP side, so they are plain UTextureRenderTarget2D.
* Several CVars (landscape.BatchedMerge.VisualLog.*) were added to help debug the merge process
* In order to improve rendering time, a new utility shader (CopyQuadsMultiSourcePS) was made  to copy several (up to 63) source textures into an atlas, which optimizes quite a bit the edit layer->atlas copy operation

Misc changes:
* Improvements/fixes to landscape-related GPU tags
* Fixed landscape.DumpWeightmapDiff which would leave txt/png files for weightmap allocations that haven't actually changed if one of the other channels of the weightmap had some data changes

Code details:
* OnFullHeightmapRenderDoneDelegate has been replaced with OnEditLayersMerged and is now called for each batch render
* Non-public API landscape utils have moved to LandscapeUtilsPrivate.h/.cpp
* Fixed edge case of a map that was saved with an invalid ULandscapeEditLayer (e.g. after having uninstalled a plugin where the base class of a layer was defined): we now clear the layer and make sure we don't fall into a situation where there's no edit layer altogether (which is not allowed and usually enforced by the UX)
* Added parameter to ReallocateWeightmaps in order to restrict the re-allocation of weightmaps to a given set of components. This is to avoid a situation where we're trying to add weightmap allocations to components that are not part of the merge. This will eventually go away when we refactor the weightmap allocation system in the editor
* Since the whole thing has to run on the game thread (because of BP calls), a new "scratch render target" system has been added (ULandscapeEditResourcesSubsystem / ULandscapeScratchRenderTarget) in order to help the various merge steps to request/release URenderTargets (2D and 2D array) and manage their RHI access. This would normally be done via RDG but we don't have access to it outside the render thread. This is shared across landscapes, which minimizes the amount of render targets needed when editing multiple landscapes at the same time.

#rb chris.tchou
#jira UE-214800
#tests Editor, cooked game

[CL 35108473 by jonathan bard in ue5-main branch]
2024-07-26 10:30:17 -04:00
bradley heath
975e448999 Add a getter and setter for NetUpdateFrequency, MinNetUpdateFrequency and NetCullDistanceSquared, and deprecate the existing public UPROPERTY.
#rb LouisPhilippe.Seguin, Ryan.Gerleve

[CL 34812206 by bradley heath in ue5-main branch]
2024-07-15 10:06:53 -04:00
kevin macaulayvacher
276d09f6df Remove all simple usage of REN_ForceNoResetLoaders from the codebase since the flag has been deprecated and currently does nothing. Simple in this case is direct use of the flag with no conditional logic. More complex uses were removed in another change.
#rnx
#rb Francis.Hurteau

[CL 34424068 by kevin macaulayvacher in ue5-main branch]
2024-06-17 11:55:02 -04:00
chris tchou
881677171a Revert landscape nanite content ID to avoid cook time hit (again)
This means that the fix requires users to manually rebuild nanite on the affected landscapes, they will not automatically rebuild to correct the issue.

#rb roey.borsteinas
#jira UE-215826, UE-215517

[CL 34131822 by chris tchou in ue5-main branch]
2024-06-05 13:46:18 -04:00
chris tchou
f072eec94b Fix for landscape nanite mesh export DDC cache
(It was not writing the data to DDC correctly)
Also adding some debug logging
Bumping landscape nanite content ID to force automatic rebuild of the nanite meshes (again)

#rb jonathan.bard

[CL 34106096 by chris tchou in ue5-main branch]
2024-06-04 16:42:24 -04:00
chris tchou
087e98365d Revert landscape nanite content ID to avoid cook time hit
This means that the fix requires users to manually rebuild nanite on the affected landscapes, they will not automatically rebuild to correct the issue.

#rb roey.borsteinas
#jira UE-215826, UE-215517

[CL 34074541 by chris tchou in ue5-main branch]
2024-06-03 15:46:10 -04:00
chris tchou
47cd4d5468 Fix for nanite landscape UV seams between streaming proxies
(the nanite mesh was using proxy relative coords instead of global coords, and was also applying LOD scale incorrectly)

#rb jonathan.bard
#jira UE-215826, UE-215517

[CL 34027288 by chris tchou in ue5-main branch]
2024-05-31 01:23:17 -04:00
chris tchou
41f1d0ed43 Fix for crash painting landscape introduced in 33667964
#rb jonathan.bard
#jira UE-216137

[CL 34020620 by chris tchou in ue5-main branch]
2024-05-30 19:40:51 -04:00
chris tchou
7493a17f76 Simplify disabling runtime grass generation per-proxy at runtime.
Doubly ensure disabled grass generation components never leave the NotReady state in game (and a bit of optimization by completely removing the check in non-editor builds).

#rb jonathan.bard

[CL 34012330 by chris tchou in ue5-main branch]
2024-05-30 16:34:26 -04:00
jonathan bard
bac7d0f946 * Improvement to the landscape target layers deprecation : if possible, try to deprecate the list of existing target layers instead of entirely relying on the analysis of the layer allocations within the landscape components. This allows not to lose landscape layer info pointers when loading map where a given layer is not used (i.e. there's no weightmap allocation associated with this layer)
* Prevent landscape target layers from being renamed to a layer name that's already in use

#jira UE-216036
#rb chris.tchou

[CL 34009471 by jonathan bard in ue5-main branch]
2024-05-30 15:00:09 -04:00
chris tchou
701f719229 Fix for rare runtime crashes in FAsyncGrassBuilder at world shutdown
#rb luc.eygasier

[CL 33954257 by chris tchou in ue5-main branch]
2024-05-28 17:29:22 -04:00
jonathan bard
f49525b388 * Fixed deprecation of target layers in landscape : the previous code did not dirty the main landscape actor, where the source list of target layers lies (all of the proxies' lists are a copy of the source list, because of the LandscapeInherited behavior), so all proxies had inconsistent list against the source landscape actor, and since deprecation had already been performed, they would not re-run the deprecation code that analyzes weightmap allocations and deduces the layer info pointers to update the main landscape actor's target layers list upon reload, effectively leaving null entries for layer info everywhere in the source landscape actor upon reload. The fix involves going through all proxies and resynchronizing landscape shared properties any time a proxy discovers an unregistered landscape layer info in one of its layer allocations, because this updates the TargetLayers list in the source actor, and this list needs to be re-synchronized with all proxies. Fortunately, this is a one-time thing (this deprecation step won't be performed afterwards) and only necessary when going from a target layer with a null layer info to a non-null one (i.e. once per target layer)
* Another issue was discovered when re-assigning a null target layer of an existing target layer : this would not call Modify on the main landscape actor, which 1) incorrectly prevents the operation from being undone 2) also prevents the actor to be dirty, and therefore, upon reload, the landscape would not retain the proper layer info assignment
* Also fixed a bunch of places where Modify was called before changing landscape properties
#rb chris.tchou

[CL 33948178 by jonathan bard in ue5-main branch]
2024-05-28 14:57:30 -04:00
jonathan bard
abf995fa6a Fixed incorrect ensure triggering when loading old landscape levels that have landscape edit layers textures with more than a single mip. This ensure is only valid if CVar landscape.StripLayerMipsOnLoad is active (it's currently not)
#rb roey.borsteinas

[CL 33938005 by jonathan bard in ue5-main branch]
2024-05-28 08:29:55 -04:00
chris tchou
d1dc689710 Fix for crash in serialization for PIE when using Mobile preview mode
The textures and materials array must have the same number of entries in serialize and deserialize, and thus cannot depend on whether the pointer is null or not (in fact we replace the property pointers with null on serialize, so it's guaranteed to be null on deserialize, and always have a mismatch in the count)

#rb jonathan.bard

[CL 33794098 by chris tchou in ue5-main branch]
2024-05-21 10:14:09 -04:00