Commit Graph

15 Commits (e8b7bba0f22af82b3afbcc900361c2c8c2b8bc2a)

Author SHA1 Message Date
Ken Pruiksma 2f1346c719
Terrain Feature Processor separated into several classes. Macro materials abstracted from meshes. (#6350)
* Breaking up terrain FP wip - macro materials decoupled from meshes. Mesh creation and rendering pulled out from MeshFeatureProcessor into TerrainMeshManager. Stubs added for macro and detail material managers.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Separated macro material management from the terrain feature processor. Also separated bindless image array handling from terrain feature processor.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Detail materials separated from terrain feature processor. Also pulled out Aabb2i and Vector2i into their own simple classes

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Changed some classes so that when the SRG changes the classes don't need to be completely reinitialized and can instead just update their indices and push data to the new srg. Fixed an issue where MacroMaterialData wasn't being exposed to ScriptCanvas. Terrain shader reloads should now work correctly. Also added some debug logging to help catch an issue where sometimes detail materials don't seem to load.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Terrain PR reveiw updates

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Some small PR review fixes. More comments in TerrainDetailMaterialManager.h

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing unused variable causing clang failure

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing unused variable in release.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing a forward declare that oddly didn't work on linux.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing linux missing include... not sure why only linux failed on this.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding missing include

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 8bccd36d03
Terrain detail textures support with bindless arrays (#5460)
* Added buffer for material properties of detail mateirals, storing them in a multi-indexed data vector. Updated shader with relevant struct and buffer, but the buffer will need to be moved out of the mateiral SRG to work.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added buffer for material properties of detail mateirals, storing them in a multi-indexed data vector. Updated shader with relevant struct and buffer, but the buffer will need to be moved out of the mateiral SRG to work.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added buffer for material properties of detail mateirals, storing them in a multi-indexed data vector. Updated shader with relevant struct and buffer, but the buffer will need to be moved out of the mateiral SRG to work.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* - Moved settings related to the detail material to a partial view srg owned by the terrain gem.
- Added support for base color in detail materials.
- Hooked up basic base color rendering of detail materials.
- Corrected the way the material data was stored.
- Added ref counting for detail materials so they can be released when no longer used.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added buffer for material properties of detail mateirals, storing them in a multi-indexed data vector. Updated shader with relevant struct and buffer, but the buffer will need to be moved out of the mateiral SRG to work.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* - Moved settings related to the detail material to a partial view srg owned by the terrain gem.
- Added support for base color in detail materials.
- Hooked up basic base color rendering of detail materials.
- Corrected the way the material data was stored.
- Added ref counting for detail materials so they can be released when no longer used.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Detail materials now put textures into bindless array that's accessed in the shader. Shader now pulls all the detail materal information for a single mateiral but does no blending.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Correcting rebase merge problem.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fix detail roughness fade out with distance.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding tests for new MultiIndexedDataVector functions

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updates to move bindless array to separate SRG
- Exposed BindSrg() in renderpass so it's possible to add additional SRGs to a pass
- Created a TerrainSrg for use by the terrain forward shader
- Moved the bindless array out of the partial view SRG to the TerrainSrg

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Moved more properties out of the view srg to the terrain srg.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Spelling fixes

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing bug where the roughness min/max value were inverted. Also fixed bug where bad data would show for areas where there was no macro material.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updates from PR review

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing case issues and updating function name due to a recent fix.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Mike Balfour a9d65b25ec Merge commit 'd52ce49dcb827c04150a6f11b7cceead9f61a43c' into mbalfour/gitflow_211102_o3de 4 years ago
Ken Pruiksma d52ce49dcb
Terrain macro material fixes (#5182)
* Minor fixes for macro materials
- When macro image views are no longer used, they will explicitely be set to nullptr
- limiting for loop in shader to the number of macro materials total so it doesn't read unitialized memory

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Removing parts of the terrain shader no longer used.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing normalization in shaders, adding default valus for all structs used in SRGs.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Adi Bar-Lev d64b9d4945 Merge commit '8d7eb4767afff80992bebe4619afc10aef04a93b' into barlev/gitflow_211028_O3DE
Signed-off-by: Adi Bar-Lev <82479970+Adi-Amazon@users.noreply.github.com>
4 years ago
Ken Pruiksma a661189ea9
Fix for rendering artifacts on height map update. (#5066)
* Fix for rendering artifacts on height map update. This was being caused by not always lining up update aabbs with the query resolution correctly. In the future the float -> integer aabb calculations should be abstracted away. Some of this is done in the detail material ID work, but doesn't exist in the stabilization branch so we can circle around to it later.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* PR review updates - fixing cast, making constexpr for bytes per pixel.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 97920feaf1
Detail material Id texture created from surface weights. (#4984)
* Added some structs for detail materials

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added some template functions for looking up materials. Added lookups for all the relevant detail material fields in StandardPBR.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added some structs for detail materials

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added some template functions for looking up materials. Added lookups for all the relevant detail material fields in StandardPBR.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added support for generating a detail material texture with IDs populated from surface weights.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updated TerrainAreaMaterailRequestBus to have separate calls for region vs materials instead of the awkward out parameter
Update MaterialPropertyDescriptor so that you can retrieve enum names by ID
Several bug fixes / updates to the terrain feature processor dealing with detail materials.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updating detail material texture based on offsets. Not quite working yet but close. Added visualization for detail material in shader (currently on, will be turned off before final commit)

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Small bugfixes
* Fix compile error in non-unity builds
* Fixed backwards x/y loops causing the wrong pixels to update
* Fixed selection of surface type with multiple surface weights

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Adding seam to detail texture debug display. Offseting edges by a half-pixel to avoid bleed. Disabling debugging detail textures by default.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Missing file from last commit for detail material change.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Cleanups

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* bug fix

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Bug fix in the terrain fp for TerrainAreaMaterialRequestBus returning incomplete materials on GetSurfaceMaterialMappings

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Some PR updates. Exposing detail material id debugging through a cvar.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Various updates from review.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* PR updates dealing with debug texture boundary line.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Hiding some fields from the terrain material

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing type in generic lambda for linux / android

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

Co-authored-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour 91ca986e2a
Terrain Macro Material component improvements (#4930)
* First pass of non-working changes to Terrain Macro Material Component.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Reworked Terrain Macro Material to use properties instead of a material.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fixed comments.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* PR feedback - disable attributes when no normal map selected

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>

* Fix linux compile error - unused variables.

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Ken Pruiksma 937c2b2e88
Terrain FP supports macro material component (#4587)
* Adding basic support for TerrainMacroMaterialNotificationBus. Tracking macro materials in list.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit b4773454334de940d730620ffff300b46d6c611d)

* Adding bus connection

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit 66c99f503adb24f4be4f81716b544202d8e237d9)

* Additions to indexed data vector to allow for getting an index from the data or deleting data with a reference to the data itself instead of the index.
Additions to the feature processor for tracking macro material indices in sectors.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit 06365dbde5454e18e5fdf941f03b17b0d632027c)

* Macro materials updating which macro materials are used in which sectors. Correctly handling construction / destruction.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updating the terrain macro material type to have the correct properties and also not attempt to render. Refactored some of the update loop in the TerrainFP to only rebuild the sectors when necessary, otherwise just update the srgs.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixed up macro material to not try to actually render anything with shaders or hook to any shader data
Terrain FP now pulls data pulling from macro material instance to use in the terrain material
Various bug fixes around when terrain sectors needed reprocessing

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding basic support for TerrainMacroMaterialNotificationBus. Tracking macro materials in list.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit b4773454334de940d730620ffff300b46d6c611d)

* Adding bus connection

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit 66c99f503adb24f4be4f81716b544202d8e237d9)

* Additions to indexed data vector to allow for getting an index from the data or deleting data with a reference to the data itself instead of the index.
Additions to the feature processor for tracking macro material indices in sectors.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
(cherry picked from commit 06365dbde5454e18e5fdf941f03b17b0d632027c)

* Macro materials updating which macro materials are used in which sectors. Correctly handling construction / destruction.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updating the terrain macro material type to have the correct properties and also not attempt to render. Refactored some of the update loop in the TerrainFP to only rebuild the sectors when necessary, otherwise just update the srgs.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixed up macro material to not try to actually render anything with shaders or hook to any shader data
Terrain FP now pulls data pulling from macro material instance to use in the terrain material
Various bug fixes around when terrain sectors needed reprocessing

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Constify all the things

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updates from PR review.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 8fc8baa579
Terrain FP now pulls data from Terrain system (#4492)
* Feature processor now pulls data instead of the render component pushing it. This results in fewer and cheaper heightmap rebuilds. The feature processor can also handle dirty regions correctly now, although it doesn't seem like they are being passed in correctly yet.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing issues with initialization, dirty region tracking, and total rendered world size.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing bug with resizing the world

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Decreasing the scope of a mutex

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixes from PR review

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixed a math issue with float rounding. Fixed static AZ::Name usage.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Removing unused variable

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 7052ccfa52
Terrain detail and macro texture support (#4403)
* 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>

* Adding more material options to terrain shader

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>

* Added more features to the terrain material. Shader & Material reloads are now handled.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added stub for terrain render max area setting in the renderer component. Added detail texture tiling setable from the material

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Missing change to material type from last commit

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding macro material in material type and support detail roughness.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing merge issues in terrain material type

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding more features to the terrain material
- Macro color and normals
- Detail layer fade out
- Reoriented detail normals

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Remove line that unintentionally was added back during a rebase & merge.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing previously deleted unused static that came back after a merge. Fixed an issue with macro normals in the terrain shader.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 8791ae7ed7
Terrain feature processor improvements regarding material, mesh, and lod (#4303)
* 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>
4 years ago
Ken Pruiksma d17ac748ac
Various terrain improvements: (#3942)
* Various terrain improvements:
- Height now stored in a R16_unorm to decrease the amount of memory / memory bandwidth needed for the height field
- Many simplifications to the feature processor
- Added a shader to render to the depth pre pass
- Pulled common functionality needed by depth and forward to a common include shader
- Forward shader now outputs to all the expected render targets
- Adjusted the way normals and lighting are being calculated

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding missing shader files. Updated terrain shader to alter the color slightly with height.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Removed pixel shader code from terrain depth pass

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Renamed the depth pass shaders to no longer indicate they include a pixel shader.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Removing unneeded code from TerrainCommon.azsli

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Ken Pruiksma 0c7dfce5a0
First pass terrain cleanup (#3753)
* First pass cleanup of some terrain components.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding basic culling to terrain sectors

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Adding default value for m_transform

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
Mike Balfour 40f41689ee
Initial Terrain System (#3401)
This represents the very beginnings of the Terrain System presented in Sig-Content RFC 4 ( https://github.com/o3de/sig-content/blob/main/rfcs/rfc-4-terrain-system.md ). There is some basic working functionality in this PR, but the system as a whole should not be considered working yet. The gem is disabled by default in all projects.

All of the code below is contained in the Terrain Gem, which is disabled by default. The following components exist and can be experimented with, but should not be expected to be functionally complete yet:

Terrain World - level component for enabling terrain
Terrain World Debugger - level component for enabling terrain debugging features
Terrain Layer Spawner - component for defining a region of terrain
Terrain Height Gradient List - component for defining a list of gradients to use as terrain heights

Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago