-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wind Animation on Vegetation #122
Comments
This is a very important RFC that will make natural scenery 'act alive' as it is expected in real life. The application of the different vertex color channels as different attributes and wave length is very important (Ala CryTek GPU Gems 3 if I'm not mistaken) and should be well documented when the feature is done. All in all - very important addition |
Based on this addition
I think this feature can benefit from adding support for optional vertex streams. I wonder how easy it would be to add shader option support within the vertex layout structure. It would mean that based on the shader variant we would need to provide different vertex data. Tagging @amzn-tommy @galibzon. |
Actually why dont we just create a new material type with optimized shader for vegetation as part of this work instead of adding this support to enhancedpbr? I would imagine that you would not want to apply enhanced pbr to trees/vegetation as it can significantly impact gpu perf. So we could create something like BasePBRWithWind material type? |
Thanks for your reply. I am not sure where to apply it, since the possible vegetation PBR shader is being developed now. As moudgils said, he suggested to create a new material type like BasePBRWithWind. The application of the different vertex color channels as different attributes is actually introduced from CryTek GPU Gems 3. I will add more technique details about the application into this RFC as soon as possible. |
Thanks for your reply. This feature actually benefit from the optional vertex streams. There is a soft naming convention that associates this with |
Actually, I am not sure where to apply it now. Maybe a new material type like BasePBRWithWind is a better way compared with applying it to all generic PBR vertex shader as adiblev suggested. If do that, features in BasePBRWithWind would only include wind animation at current time, since other features like adding a faster pixel shader and better SSS for two sided foliage haven't completely done. Is a material type like this acceptable for the community? |
HWEnvironment Settings Component:
Gem name - consider "Wind Effects" instead of "Environment"? Or are there plans to put other environmental controls in this gem as well? |
Thanks for the helpful suggestions. We would like to change the components as you said, as they are necessary to improve the usability for users. As for the gem name, we indeed want to put other environmental controls in our internal version of the engine, such as volume fog/cloud and so on. By the way, if developers in community who have added a new environment effect, I think it should be a chance to add more controls in this gem. |
Approved. |
Since this RFC is accepted please open a PR and move this RFC to this folder - https://github.com/o3de/sig-graphics-audio/tree/main/rfcs where we will track all the new RFCs. Thanks. |
Summary:
This proposal outlines how to add an
Environment
gem to provide wind settings and wind animation implementation for vegetation inEnhancedPBR
materialtype in O3DE.What is the relevance of this feature?
Wind animation for vegetation is a kind of important environment effects for natural scenes. Vegetation in O3DE now has always been mainly static. Although we could use
PhysX
components to provide force region to simulate the wind animation, but the performance is relatively poor for large-area plants. We need a GPU-based implementation to animate the wind effect.To solve the problem that our scenes can have thousands of different vegetations, we push the envelope further by making vegetation react to the global wind source, and we bend not only the plant but also the leaves, in detail, with all computations procedurally and efficiently done on the vertex shader.
Feature design description:
This design is mainly divided into two parts:
Environment
gem and wind animation implementation inEnhancedPBR
materialtype.The gem provide necessary global wind settings, and the response happens in the material. An example is given in the following diagram, where we show the relationship. We obtain parameters from the gem, and send them to the
SceneSrg
. When rendering, material could get all parameters from theSceneSrg
.Design of the
Environment
gemThe gem is placed on the
Level
entity. There is a component namedHWEnvironment Settings
, as the picture shows:Now the wind settings in the component include wind switch, wind vector, different wind modes, etc. We send these parameters into
SceneSrg
, thus material shaders could get them. The following diagram shows the editor of this gem.There are two modes provided by the component:Static Wind
: The wind vector is a constant value, as the picture shows:Breezy Wind
: The wind vector could be changed following the time change by a sine function. And the breezy settings could affect the value of the sine function. In the breezy state, the meadow wave effect can be turned on. The meadow wave effect is only for large areas of grass by sampling from a wave texture. At this time, a additional wave texture needs to be set, as the picture shows:Here are parameters descriptions in the component:
Enable Wind
Wind Vector
Wind Mode
Breezy Frequency (1/sec)
Breezy Life Time (min)
Breezy Strength (m/s)
Meadow Wave Settings
Enable Meadow Wave
: Click the button to turn on the effect of generating meadow wave based on plant positions and the wave texture.Wave Texture Scale
: Set the scaling factor for wave texture sample values.Wave Texture
: Specify the sample texture for the grass waves.Now the gem only supports global wind settings, but could extend to add more environment settings. Any other component which responses to this could get the wind related parameters. We hope that other components that need to use the wind settings can uniformly obtain them from here.
Besides the wind setting, we wish that any other global common environment settings could be included in this gem.
Design of the wind animation for vegetation in
EnhancedPBR
materialtypeWind animation is basically a kind of vertex animation implemented in vertex shader.
There are two types for wind animation:
Main Bending
andDetail Bending
. TheMain Bending
is an overall bending of the vegetation which refers to the overall offset of all vertices on the mesh controlled by the wind vector and object mass. TheDetail Bending
is a localized bending for trunks or leaves controlled by wind vector and another detail sources, like noise texture or vertex color attribute.We generate the main bending by using the
xy
components of the wind vector, which gives us the wind direction and its strength, using the vegetation mesh height as a scale to apply a directional vertex deformation. Note that care must be taken to limit the amount of deformation. Otherwise, the results will not look believable.Main Bending
panel in the material editor is shown as following picture:The
Object Mass
can affect the overall bending range, the greater the mass, the smaller the overall bending range. In addition, when openingPerpendicular Bending
, the force in the perpendicular direction can also be added to make the plants bend along the vertical direction of the wind direction, enriching the diversity of bending.To achieve the meadow wave effect, we need to enable the
Enable Meadow Wave
in the wind settings ofHWEnvironment Setting
component and enable theMeadow Wave Bending
in theWind Animation
material property. We only need to perform this operation on the vegetation that we want to have the meadow wave animation. If not desired, just turn offMeadow Wave Bending
.For detail bending, we approach things in a similar fashion, but in this case only wind strength is taken into account. The detail bending of vegetation refers to the fine adjustment of the bending of vegetation branches or leaves through
Detail Source
. There are two types of detail source,Noise Texture
andVertex Color
.The parameter panels are shown by the following pictures when switching
Detail Source
:When the detail source is noise texture, the bending of each vertex in the model is controlled by a certain sampling point in the texture. The sampling point is related to the spatial position of the vertex in the model and changes with time, so it can produce the effect of the vegetation swinging over time. The noise texture needs to be created and specified by the user. The gem has built-in commonly used noise textures by default, such as
HWEnvironment\Assets\Textures\NoiseTextures\perlinNoise_sum.tif
, as shown in the following figure:When the detail source is vertex color, the bending of each vertex in the model is controlled by the vertex color attribute and the control function. The control function is built-in and cannot be changed temporarily. Vertex colors are stored in attributes of each vertex. Artists paint one RGB color per-vertex using a common DCC tool. This color gives us extra information about the detail bending determining the phase and amplitude scaling when sampling from the control function. Taking a leaf as an example, the red channel is used for the stiffness of leaves' edges, the green channel for per-leaf phase variation, and the blue channel for the overall stiffness of the leaves. The red, green and blue components of the vertex color in the leaf are displayed in turn from left to right, as the following figure shows:
Different parameter settings occur in the case of two different detail sources. Also, there are several common parameters both for main bending and detail bending, like common bending frequency and scale. The diagram below shows all the parameters and corresponding descriptions in the wind animation material property:
Enable
Main Bending
Object Mass
Perpendicular Bending
Perpendicular Force
Meadow Wave Bending
Meadow Wave Shift
Detail Bending
Breezy Effect
Detail Source
Noise Texture
Noise Texture Scale
Start Height
Branch Amplitude
Edge Amplitude
Inverse Blue Channel
Common Bending Frequency
Common Bending Scale
Technical design description:
The
HWEnvironment
gem is just developed by following the gem framework in O3DE. The UML class diagram of the gem is shown in the following picture:The most important function is
UpdateSceneSrg
which is responsible for updatingSceneSrg
by using values from the editor component if necessary. We have added a new fileSceneSrg.azsli
to receive the updates fromHWEnvironmentFeatureProcessor
.About the shader, we would add a special
COLOR
input as a optional value.m_optional
prefix gets set automatically by the system at runtime only if it's available.In the vertex shader entry function, we add a snippet to call
ApplyWindAnimation
function to change the world position of this vertex.In function
ApplyWindAnimation
, the detail implementations are just following the explanations in the feature design description.What are the advantages of the feature?
What are the disadvantages of the feature?
How will this be implemented or integrated into the O3DE environment?
We need to merge a new gem into O3DE with modifications of CMake lists. Besides, some updates about EnhancedPBR materialtype should be merged.
Are there any alternatives to this feature?
How will users learn this feature?
Once this proposal is passed, documents will be provided for users and developers to learn this feature. This feature can be added in USER GUIDE to let them know how to add the component and PBR Materials to let them know how to adjust the wind animation parameters in material editor.
Are there any open questions?
Level
editor, since we may need to set several different wind sources with different world positions?The text was updated successfully, but these errors were encountered: