* Added a ModelReloader class that handles reloading the hierarchy of assets in the correct order. A ModelReloaderSystem that is used to make sure there is only one ModelReloader at a time for a given asset. Modified the Model, ModelLodAsset, and Buffer assets to not automatically reload, and instead handle reloads manually via AssetCatalog events. Modified the MeshLoader to kick off a reload via the ModelReloaderSystem whenever a model asset is added or changed.
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Comment updates
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Minor naming and comment updates based on PR feedback
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Correcting previous commit. I flipped == to != when switching from count to find, when it should have stayed ==
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Updating RenderCommon header
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Removing unneeded headers
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Reverting RayTracingFeatureProcessor change following Doug's guidance. This logic was tricky to get right initially, and leads to TDR when incorrect, so leaving as is.
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Removing a tab
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Added missing #include for AssetId
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Adding missing RTTI header
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Include ModelAsset definition intead of forward declaring it to avoid a static assert on Linux
Signed-off-by: amzn-tommy <waltont@amazon.com>
* Terrain feature processor improvements regarding material, mesh, and lod
- Now using a material with pbr lighting for terrain. Removed some of the old shader code that wasn't needed anymore
- Move heightmap image declaration to the material so it's not needed in the object SRG anymore
- Added prototype code (commented out) for smoothing the terrain with a b-spline weighting function
- Mesh data is all made with a proper mesh asset now.
- Added basic LOD support (no continuous LOD yet, but it does pop between lod levels)
- Moved RenderCommon to be accessible publicly. It contains stencil refs that should be public.
Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
* Fixing terrain's per object srg because of changes in the default per object srg.
Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
* PR Fixes
Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
* Removing unused static.
Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
* Remove the "TEST_SUPPORTED" traits.
Terrain unit tests should be usable on all platforms, so they shouldn't need a platform-specific trait to enable/disable.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix a few misc terrain bugs.
* Change Activate/Deactivate to happen immediately instead of deferring. There were too many order-of-operation bugs caused by trying to defer this.
* Added implementation for calculating normals.
* Fixed bug where GetHeightSynchronous wasn't stopping at the highest-priority layer.
* Added locks for SurfaceData bus to help ensure we lock our mutexes in the correct order and avoid deadlocks.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add trivial TerrainSystem tests.
Tests construction, Activate(), Deactivate(), and destruction.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Unified Terrain system calls on single bus.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added mock for TerrainDataNotificationBus listener.
Also added unit tests to verify the listener, and added in missing notification events.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed extra Sampler class.
Fixed up APIs to correctly pass Sampler and terrainExistsPtr around.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switched MockTerrainSystem to be proper gmock.
This makes it for flexible to use and easier to reuse from other test environments.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix settings bug caused by bad order of operations that occurred when the methods moved to a different bus.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Eliminate extra EBus by simplifying area initialization.
Previously, there was a back-and-forth ebus signal used for the terrain system to find any terrain spawners that were created prior to the terrain system activation. Now it uses the more simple technique of just grabbing all the spawners that are currently hooked up to the spawner ebus.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Switch to NiceMock so that "uninteresting" mock calls get ignored.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed PR feedback.
Filled in terrainExistsPtr at the end, and added it to GetNormal as well.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed shader height calculation.
It was off by half a pixel, and it was interpolating, both of which were wrong.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Create initial LmbrCentral mocks that other Gems can use.
To help improve mock maintenance over time, this creates mocks in the same Gem as the systems being mocked, instead of the other Gems that need to use mocked systems during testing. This way, the mocks should more easily stay in sync with the interface that they mock out.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Null-guard any uses of Atom to make the class easier to unit test.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add more mocked terrain services
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Moved Terrain mocks to publicly-available Mocks directory. Also added more unit tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Change debug code to use EXACT instead of BILINEAR height sampling, because it's specifically using the terrain grid.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added support for the sampler filters.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix bad merge.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Add unit test to verify terrain layers define terrain regions.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Moved the AABB component mock into a private terrain header, since it's a specialized mock just for the terrain tests.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Moved sampler and normal calculations into TerrainSystem so that they can work across multiple adjacent areas.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Missed a couple of unit test changes.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed normal query as well, that needs a seprate unit test.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed unused variable that was only caught in Linux/Android builds.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed PR feedback
Made the parameter names consistently listed in MockShapes.h.
Added comments to TerrainHeightGradientListComponent explaining why terrainExists is always true when a gradient exists.
Also fixed a bug where terrainExists should technically be *false* if no gradient exists.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Added more descriptive comments and names for ClampPosition.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Unit tests to verify height samplers work correctly.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fix bug where wireframe didn't refresh when the setting changed.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Created TerrainWorldRenderer Component and moved all terrain rendering management code into it.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed the icon references
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed expensive profile marker.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Addressed PR feedback
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed AR error - constexpr doesn't need to be in a lambda capture.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
- Removed all unnecessary includes to Atom CpuProfiler.h
- Added includes to AzCore Profiler.h where necessary
Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
- Added new interface type AZ::Debug::Profiler to externally register profiler systems
- Modified the Atom CPU profiler to register as an AzCore profiler
-- This allows full engine markers to be visualized in the associated ImGui tool
- Converted all AZ_ATOM_PROFILE_* macros to use AZ_PROFILE_* macros instead
Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
Many of these are just extra noise in the profile, but the one in Archive.cpp could also cause PIX to crash.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
Repro steps:
- Create two entities.
- Entity 1
- Add a mesh component and assign a model with multiple sub-meshes
- Add a material component. The material component looks correct.
- Entity 2
- Add a mesh component and assign the same model as the other entity
- Add a material component. The material component shows "<unknown>" for all material slot names
The problem was that ReflectedPropertyEditor creates a new Asset<> reference with the correct ID but does not load it. This asset is passed to EditorMaterialComponent, MaterialComponentController, and MeshFeatureProcessor and none of these tell the Asset to load. The MeshFeatureProcessor was not loading the Asset or connecting to the AssetBus because the instance already existed in the InstanceDatabse so from the FP's perspecive there was no need. But for the FP's GetModelAsset() API to function correctly it needs to have the asset initialized to the available AssetData pointer. So we updated the MeshFeatureProcessor to always connect to the AssetBus so it will find the available AssetData via the OnAssetReady callback.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
Here we inttroduce a new struct ModelMaterialSlot which formalizes the concept of material slot, with an ID, display name, and default material assignment. The ID still comes from the MaterialUid like before. The display name is built-in, rather than being parsed out from the asset file name. And the default material assignment can be any material asset, it doesn't have to come from the FBX (or other scene file).
This commit is just the preliminary set of changes. Cursory testing shows that it works pretty well but more testing is needed (and likely some fixes) before merging.
Here is what's left to do...
Add serialization version converters to preserve prior prefab data.
See if we can get rid of GetLabelByAssetId function only rely on the display name inside ModelMaterialSlot.
I'm not sure if the condition for enabling the "Edit Material Instance..." context menu item is correct.
Test actors
Lots more testing in general
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
* Final update copyright headers to reference license files at the repo root
Signed-off-by: spham <spham@amazon.com>
* Fix copyright validator unit tests to support the stale O3DE header scenario
Signed-off-by: spham <spham@amazon.com>
-Re-purposed an unused boolean in RPI::Cullable for previous frame's visiblity to instead represent objects that are hidden in the simulation.
-Updated MeshFeatureProcessor::SetVisible to set this value on the cullable.
-Updated the MeshComponent to handle visiblity changes by not rendering the mesh instead of deactivating and/or reactivating the component.
-Updated the AtomActorInstance to handle changes to the visibility from the ActorComponent.
Tested by creating two entities with static mesh components, on entity hidden and the other visible. Plus three entities with actor components, one where the actor is visible, one where the entity is visible but the 'render character' setting on the actor component is disabled, and one where the 'render character' setting is enabled, but the entity is not visible.
For each of these 5 entities, I added them as 5 loose entities, 5 entities that were children to a parent entity, and a slice with all 5 as children to a parent entity, and tested toggling visibility of the parent entities.
For each of these 3 sets of 5 entities, I added them directly to the level, added them all to a layer where the layer was visible, and added them all to a layer where the layer was not visible, and tested toggling the visibility of the layers.
[ATOM-14344][ATOM-13908] Merging skinned and static mesh motion shaders using an optional vertext stream. This removes the log spam "Mesh does not have all the required input streams. Missing 'POSITIONT0'." and allows Material::GetShaderCollection() to be const only as it was intended. The MeshFeatureProcessor also no longer needs to decide which motion vector shader to use, and therefore no longer has m_skinnedMeshWithMotion in the descriptor to acquire a mesh.
* Move SetUseForwardPassIblSpecular to happen when acquiring a mesh, instead of immediately after so that we don't build the drawpacket twice for every mesh
* Update the MeshFeatureProcessor to use the booleans from the descriptor directly instead of having loose booleans in the MeshDataInstance
* m_excludeFromReflectionCubeMaps is not (and does not need to be) part of the descriptor, since setting is cheap and doesn't duplicate work that is done when acquiring the mesh
Added a ShaderSystem supervariant to provide a system-wide supervariant name.
Changed ShaderAsset to append the system-wide supervariant name when searching for supervariants.
Added the NoMSAA supervariant to several shaders.