Commit Graph

57 Commits (c6ba1ef064ba8a92c937ae74b4b25e272ac2d975)

Author SHA1 Message Date
Guthrie Adams c6ba1ef064 Atom Tools: updated document and windows systems and buses to support multiple instances
• This change is partially to unblock physics tool prototyping. It introduces a tool ID that is passed down into systems and acts as a context for document, window, and other systems and buses.
• The document system component is no longer a component. It is just a system class that can be constructed with a tool ID. Internally, it will connect to its buses and be addressable by tool ID. More than one can be instantiated, each with a unique tool ID.
• These changes are still backward compatible because most of the buses were using broadcast for standalone applications. All of those calls have been updated but not all of the scripts, which should still work as is.
• Got rid of the window factory request bus in favor of just instantiating the main window or any other UI in the application layer.
• Fixed a couple of bugs that were discovered while making these changes.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac ddab03d678 Reponse to code review feedback. The main change is making GetPropertyValues return by const ref.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac b05d4bdf36 Merge remote-tracking branch 'upstream/development' into Atom/santorac/RemixableMaterialTypes4_FlatMaterialFiles
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 1daa9fbbed Changed the .material file format to use a flat list for material property values, instead of a tree structure.
This is needed to support deeply nested material property groups, it just makes the serialization code a lot simpler than trying to support nested groups in the .material file. It also makes the file more readable and easier to search all files for particular properties.
I also updated MaterialSourceData to hide the property values behind a clean API.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams c9c172794e Atom Tools: Document system exposes reflected object data
• This removes a direct dependency on dynamic property groups and data from the document system.
• Added support for names, descriptions, and nesting to dynamic property groups.
• Moved property related functions from base document classes into material editor document classes because dynamic property groups are an implementation detail of the material editor document to support material type flexible data format.
• Change material document to use a table of dynamic property groups instead of a map of properties.
• Added functions to traverse groups and properties.
• This keeps groups and properties organized consistently with the material type file as well as what’s expected in the UI.
• Document data can now be maps directly to the inspector reflective property editors instead of copying one property at a time out of the document and keeping those synchronized.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac 4bb93e4c94 Removed unnecessary MaterialSourceData::Property class.
This wrapper used to be needed in order to bind the custom JsonMaterialPropertyValueSerializer back when property values were represented by AZStd::any. Now that property values have a custom MaterialPropertyValue type, the wrapper class is no longer needed.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams ca0006f570 Minor changes and comments after PR feedback
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams 66be8543cd fixing merge issues
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams 9ded52b141 Wrapping redundant save logic into function in the material editor document class
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams dc598a8b3c Atom Tools: move boilerplate document management code to atom tools framework
• Moved all of the common save and load code to the document base class
• Moved undo and redo support to document base class but will probably extract to its own class or replace with one from AzTF
• Streamlined material editor, shader management console, and other tools with updated document code
• Cleaned up some of shader management console loading code, added support for saving, as well as getting and setting the shader variant list source data structure

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac c2e220ce49 Renamed property 'set' to property 'group' for consistency with the prior naming.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 906db920d0 Merge remote-tracking branch 'upstream/development' into Atom/santorac/RemixableMaterialTypes3
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac a4346de658 Code cleanup. New comments. Added some non-const find functions to MaterialTypeSourceData. Fixed places where I forgot to change m_name to GetName().
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
lumberyard-employee-dm b9824ed172
Updated all array_view uses with the C++20 span. (#7157)
* Updated all array_view uses with the C++20 span.

The updates were done in the following order
1. `AZStd::array_view<([^>].+)\* ?>`  -> `AZStd::span<\1 const>`
2. `AZStd::array_view<(?:const )(.+)>` -> `AZStd::span<const \1>`
3. `AZStd::array_view` -> `AZStd::span`

Removed the implementation of array_view.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added missing whitespace between `const` and the typename for spans.

Updated the ShaderTest comparison of the ShaderResourceGroupLayout span
to compare the sizes as well

Updated comments on some of the methods that stated that they return "an
array" to mention they return "a span".

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
santorac aeb43c4012 Fixed up a few small things to get Material Editor working again.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac b5c7869f14 Merge branch 'development' into Atom/santorac/RemixableMaterialTypes3
There were lots of material system conflicts that had to be resolved. I expect the build is broken at this commit, and I'll fix it in followup commits.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 3e5c1cee1e Fixed a place where GetFullName was still being used.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 02acf2f65e Updated MaterialPropertyId class in preparation for nested material property sets.
Here the class has been generalized for a list of group names and a final property name, rather than assuming a single group containing the property. This included removing the unused GetPropertyName and GetGroupName functions. All that's really need from this class is conversion to a full property ID string.

Testing:
New unit test.
Reprocessed all core material types and StandardPBR test materials used in Atom Sample Viewer's material screenshot test.
Atom Sample Viewer material screenshot test script.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 4ade6bc88a Fixed compile errors in Material Editor.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac c5b128bec4 First pass at reworking and formalizing the way deferred material asset baking works. The feature basically works but needs more testing.
Before, the material builder was loading the MaterialTypeAsset and doing some processing with it, but was avoiding declaring job dependencies that would cause reprocessing lots of assets when a shader or .materialtype file changes. Reading the asset data isn't safe when not declaring a job dependency (or when declaring a weak job dependency like OrderOnce which is the case here). This caused to several known bugs.

The main change here is it no longer loads the MaterialTypeAsset at all; all other changes flow from there.

The biggest changes (when deferred material processing is enabled) are ...
1) MaterialSourceData no longer loads MaterialTypeAsset. All it really needs is to determine whether a string is an image file reference or an enum value, which is easy to do by just looking for the "." for the extension.
2) MaterialAssetCreator no longer produces a finalized material asset. It no longer uses MaterialAssetCreatorCommon because that only produces a non-finalized MaterialAsset, which has very different needs for the SetPropertyValue function. (We could consider merging MaterialAssetCreatorCommon into MaterialTypeAssetCreator since that's the only subclass at this point). And it doesn't do any validation against the properties layout since that can be done at runtime.
3) Moved processing of enum property values from MaterialSourceData to MaterialAsset::Finalize (this was the only thing being done in the builder that actually needed to read the material type asset data).

Also...
- Updated the MaterialAsset class mostly to clarify and formalize the two different modes it can be in: whether it is finalized or not.
- Merged the separate "IncludeMaterialPropertyNames" registry settings from MaterialConverterSystemComponent and MaterialBuilder into one "FinalizeMaterialAssets" setting used for both.
- Removed MaterialSourceData::ApplyVersionUpdates. Now the flow of data is the same regardless of whether the materials are finalized by the AP or at runtime. Version updates are always applied on the MaterialAsset.
- Added a validation check to MaterialTypeAssetCreator ensuring that once a property is renamed, the old name can never be used again for a new property. This assumption was already made previously, but not formalized, in that Material::FindPropertyIndex does not expect every caller to provide a version number for the material property name, also the material asset's list of raw property names was never versioned. The only way for this to be a safe assumption is to prevent reuse of old names.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams f8ca427954
Fixed several material editor bugs related to file paths and hot reload prompts (#6374)
* draft

Signed-off-by: Guthrie Adams <guthadam@amazon.com>

* Removes automatic generation of relative paths for external references for materials
Updated material editor functions for creating new materials, creating or saving model or lighting presets, to save to the project asset folder instead of the material folder which is not included in the new templates
Changed function for getting saved file names to handle case where Qt save file dialog adds double extensions if the extension contains a dot

Signed-off-by: Guthrie Adams <guthadam@amazon.com>

* Fixed problems with material editor hot reloading after documents or dependencies changed.
Triggering message boxes within the tick function, which is executed from the main application timer, caused the tick function to be called a second time recursively.
Switched from using the tick bus to a timer so that the documents re opening and dialogs are triggered outside of the main tick.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac 9f7815fa04 Fixed up a couple incorrectly or incompletely resolved merge conflicts.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac db3d41ad9d Merge remote-tracking branch 'upstream/stabilization/2110' into Atom/santorac/MaterialEditorHandlesMissingTextures 4 years ago
santorac 224e0bd20f Removed the 'data-warnings' concept for checking before saving a material document. It's no longer necessary since we no longer replace the original data with placeholders.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 7d849cc0d2 Changed the overall strategy for how to handle missing image references. Instead of replacing it with one of the placeholder assets, we replace it with an random UUID which will be interpreted as a missing asset (unless some discovers discovers a UUID collision). This eventually gets replaced by one of the placeholder textures at runtime. This approach gives more consistent results in how missing texture are handled between Material Editor and Material Component.
I actually tried this approach before and it didn't seem to work the way we needed, but I realized that's because PropertyAssetCtrl wasn't handling missing assets properly. I fixed a few issues there including showing the error button when the asset can't be found, and fixing a broken reference to the error icon file.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams 198f225bbe Updating parent path usage has part of cherry picked from stabilization combining source data changes with relative path changes
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams 7d51912a6e updated comments
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams b3f3a4245b updated image paths to use new function
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams ed4f7965da Created function to get relative paths to referenced files that will fall back to asset folder relative paths under certain conditions
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams f18f838da6 material editor and exporter save source materials with relative paths
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac f27203a5fa Updated Material Editor to use the available default fallback images to visually indicate a missing texture.
Material Editor also warns the user when saving a material that is populated with fallback image references.
Factored out the path strings for the default images to ImateSystemInterface.h.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac cd28d210ab Working on making Material Editor able to open materials that have missing textures.
Made it a warning instead of an error when MaterialAssetCreator can't find a texture.
Updated the Material Editor's MaterialDocument class to not elevate warnings to errors.
Material Editor uses new features in TraceRecorder to show a message dialog when warnings are detected so the user is notified of the missing texture.

Next I will work on making MaterialAssetCreator put a "missing" texture in place of the requested one.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams 791d11c8f9 Fix parent material loading
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams c0acbe7bd4 Changed how asset creator generates the asset instance. Instead of finding or creating the asset in the asset manager, one is directly instantiated and only added to the asset manager after creation is complete. This allows for reuse of previously loaded asset ids and will replace or “reload” a pre-existing asset with the newly created one. This also sends although correct notifications.
Changed material document to load a source data are for the parent material as well.  It was also a previously loading the parent material products asset which would be out of date compared to the source data.
Changed material document to track source file dependency changes instead of product asset changes.
Fixed a bug or copy paste error in the document manager that was using the same container to track documents the modified externally and from other dependency changes.
Returning source data dependencies when creating a material asset from source.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams 898b1811e0 material editor loads source data
Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
santorac 7ffcbe080e Updated Material Editor's MaterialDocument to apply version updates to the materials that it opens.
Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac a0b1dec929 Added support for material version updates in MaterialSourceData. This is necessary for tools like Material Editor and Asset Processor to work with the latest property names.
- Added MaterialSourceData::ApplyVersionUpdates() for updating the properties. This should be called by tools after loading the MaterialSourceData. (But can be omitted if a tool wants to read the data exactly as it appears in the .material file).
- Updated MaterialTypeSourceData::FindProperty to support applying version update renames, including a ApplyPropertyRenames utility function, which are necessary for MaterialSourceData to be able to find the necessary property definitons while loading.
- Added a new context struct to JsonMaterialPropertyValueSerializer for passing down the material type version number, to help with applying property renames.
- Renamed the .material file format "propertyLayoutVersion" to "materialTypeVersion" which is more accurate. This shouldn't hurt existing data as this field wasn't actually used for anything before.
- Updated Material Editor to again store the material type version number in .material files.

MaterialSourceDataTests updates...
- Updated to include both a .materialtype file and a MaterialTypeAsset for the test material type. Both are used by the MaterialTypeSourceData class.
- The default test material type now includes some version update steps; these are only used for version update tests and won't impact the other test functions.
- Updated the path for storing temp files to disk, to just be in a "temp" folder in the exe path. (Originally they were saved to the gem folder near MaterialSourceDataTests.cpp, but at some point someone changed it to be under the exe folder, so there's no reason to use the full gem path anymore).

MaterialTypeSourceDataTests updates...
- Moved some code that was accidentally added to LoadAllFieldsUsingOldFormat but should have been in LoadAndStoreJson_AllFields.
- Added test cases for unsupported version update operations

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
hershey5045 d8549f9566
Merge branch 'development' into Atom/rbarrand/MaterialVersionUpdate 4 years ago
santorac 1a99103999 Overhauled the .materialtype file format to group all related properties data together. This prepares the way for a number of possible improvements, especially unlocking the ability to factor out material type configuration to be shared by multiple material types.
Here we formalize the concept of a Property Set, which replaces property "groups", containing the group name and description, properties, and functors all in one place.
The Property Set structure will allow arbitrarily deep nesting, whereas before you only had one level of grouping. This nesting is not fully supported yet throughout the system, particularly in the Material Editor. It was easier to go ahead and put in some of the nesting mechanims, parituclar in the implementation of MaterialTypeSourceData.
This change is backward compatible, which is proved with unit tests, and by the fact that only MinimalPBR.materialtype has been updated to the new format. StandardPBR, EnhancedPBR, and others are still using the old format. (In a subsequent commit I'll update these as well, to prove that the new format works correctly).

Other changes and improvements...
- A new constructor for MaterialPropertyId
- Improved API for MaterialTypeSourceData that hides a good deal more of it's data as private, with clear and convenient APIs. Especially AddProperty, AddPropertySet, FindProperty, FindPropertySet, EnumerateProperties, EnumeratePropertySets.
- Added lots of new unit tests
- Updated MinimalPBR.materialtype to the new format.

Testing:
- Updated unit tests.
- Reprocessed Atom material assets.
- Ran AtomSampleViewer material screenshot test.
- Opened, edited, saved material in the Material Editor.
- Opened a level, edited material property overrides, saved and reloaded.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Robin 2607b3471a Resolve PR comments. Add unit tests.
Signed-off-by: Robin <rbarrand@amazon.com>
4 years ago
santorac 55eb85d546 Updated MaterialPropertyId class in preparation for nested material property sets.
Here the class has been generalized for a list of group names and a final property name, rather than assuming a single group containing the property. This included removing the unused GetPropertyName and GetGroupName functions. All that's really need from this class is conversion to a full property ID string.

Testing:
New unit test.
Reprocessed all core material types and StandardPBR test materials used in Atom Sample Viewer's material screenshot test.
Atom Sample Viewer material screenshot test script.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac c2abd2d74f Updated the naming convention for material property "names" vs "IDs".
A "property name" is the name of the just the property without regard to the group that it's in. A "group name" is the name of the group. And a "property ID" is the full unique name of a property in the form "groupName.propertyName". This is important preparation for upcoming changes where property sets can contain other property sets, and property IDs can be arbitrarily long like "layer1.baseColor.factor" for example.

The naming changes include variables, some code comments, and the .materialtype file format. I was able to make these changes in a backward compatible way so a property or group "id" field has been replaced with a "name" field, but "id" is still supported for compatibility. StandardPBR, EnhancedPBR, StandardMultilayerPBR, and Skin have all been updated. Note that MinimalPBR has not been updated, proving that backward compatibility works. (We can update this one too at some point though).

Testing:
Opened up materials in the material editor.
Ran AtomSampleViewer in dx12 and vulkan with no new failures.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
santorac 51f101748d These changes make material system report warnings when gameplay scripts attempt to change PSO-impacting material properties at runtime. So far the material system has always allowed any properties to be changed at runtime, including those that affect Pipeline State Objects (PSOs), as this is supported on several platforms. But some platforms require that Pipeline State Objects be pre-compiled and shipped with the game. At some point we will need to add new restrictions that limit what material properties can be changed at runtime. In the meantime, these warnings should alert users to avoid this, as the functionality likely won't be supported in the future.
- Made the Material and LuaMaterialFunctor classes configurable to report errors or warnings when material properties modify Pipeline State Objects. This is controlled by a new "MaterialPropertyPsoHandling" enum.
- Made the EditorMaterialComponent override PSO handling as Enabled, to prevent warnings when the user is editing material instance property overrides. This requried a new MaterialComponentNotificationBus bus message "OnMaterialInstanceCreated".
- Removed unnecessary GetMaterialPropertyDependencies member from material functor context classes, as this is already available as part of the functor itself.
- Made Material::SetPropertyValue return early when the property value hadn't actually changed. Besides being more efficientn, this prevents unnecessary spamming of the new warning.

Signed-off-by: santorac <55155825+santorac@users.noreply.github.com>
4 years ago
Guthrie Adams 364ac51502 Removed errors from unimplemented status functions
Updated shader management console trace messages
Renamed document rebuild function to reopen

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Guthrie Adams 30fee96c43 Moved material editor document system buses and system components to atom tools framework
Renamed document related buses and components to have generic names
Added a base document class with default implementation from which other application specific documents can be derived to work with the document system
Added document factory function registration to the document system request bus so that each application can specify the type of document it creates
Updated all comments and messaging to only refer to documents, not materials or material documents
Updated material editor and shader management console to conform to the new buses
This will provide a first pass of a common interface for a document management system that can be shared by multiple applications
Corrected status bar message copy and paste errors
Updated all test scripts to use the new buses

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
4 years ago
Steve Pham 38261d0800
Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
4 years ago
Steve Pham b4a2edec6a
Final update copyright headers to reference license files at the repo root (#1693)
* 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>
5 years ago
Qing Tao c29cfaafa4
ATOM-15287 Materials Disappear When Hot Reloading Parent Materials (#1532)
The issue was because the material wasn't compiled when creating the draw packet
5 years ago
Steve Pham 70042fcdcd
O3DE Copyright Updates for Linux Foundation (#1504) 5 years ago
Chris Santora de4e6957e8 Made a bunch of display name and description updates to core material types.
- Renamed "Details" group to "Overview".
- Renamed "UV Names" group to "UV Sets".
- Renamed "General" group to "General Settings".
- Renamed "Parallax" group to "Displacement".
- Renamed "Texture Map" properties to just "Texture". In cases where a specific type of texture is mentioned like "roughness texture map" I called this "roughness map" (which is more common according to google).
- Renamed "Heightmap" to "Height map" (which is more common according to google).

ATOM-14002 [Material Editor] Revisit user facing organization and layout of material types
5 years ago