-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from judysng/Atom/njud/vegetation-bending
Add AtomTutorials gem + vegetation bending
- Loading branch information
Showing
66 changed files
with
2,345 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
...AtomTutorials/Assets/VegetationBending/MaterialInputs/VegetationBendingPropertyGroup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"name": "vegetationBending", | ||
"displayName": "Vegetation Bending", | ||
"description": "Properties for configuring the bending.", | ||
"properties": [ | ||
{ | ||
"name": "DetailBendingFrequency", | ||
"displayName": "Detail bending frequency", | ||
"description": "Detail bending frequency.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": 0.0, | ||
"max": 1.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_detailFrequency" | ||
} | ||
}, | ||
{ | ||
"name": "DetailBendingLeafAmplitude", | ||
"displayName": "Detail bending leaf amplitude", | ||
"description": "Detail bending leaf amplitude.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": 0.0, | ||
"max": 1.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_detailLeafAmplitude" | ||
} | ||
}, | ||
{ | ||
"name": "DetailBendingBranchAmplitude", | ||
"displayName": "Detail branch amplitude", | ||
"description": "Detail branch amplitude.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": 0.0, | ||
"max": 1.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_detailBranchAmplitude" | ||
} | ||
}, | ||
{ | ||
"name": "WindX", | ||
"displayName": "Wind direction x", | ||
"description": "Wind in the x direction. This would typically come from a wind system instead of a material property, but is here as a proof of concept.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": -1.0, | ||
"max": 1.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_windX" | ||
} | ||
}, | ||
{ | ||
"name": "WindY", | ||
"displayName": "Wind direction y", | ||
"description": "Wind in the y direction. This would typically come from a wind system instead of a material property, but is here as a proof of concept.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": -1.0, | ||
"max": 1.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_windY" | ||
} | ||
}, | ||
{ | ||
"name": "WindBendingStrength", | ||
"displayName": "Bending strength", | ||
"description": "Bending strength. This would typically come from a wind system instead of a material property, but is here as a proof of concept.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": 0.0, | ||
"max": 7.0, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_bendingStrength" | ||
} | ||
}, | ||
{ | ||
"name": "WindBendingFrequency", | ||
"displayName": "Wind Bending Frequency", | ||
"description": "The frequency that the object sways back and forth caused by the wind. This would typically come from a wind system instead of a material property, but is here as a proof of concept.", | ||
"type": "Float", | ||
"defaultValue": 0.0, | ||
"min": 0.0, | ||
"max": 1.5, | ||
"connection": { | ||
"type": "ShaderInput", | ||
"name": "m_windBendingFrequency" | ||
} | ||
} | ||
] | ||
} |
77 changes: 77 additions & 0 deletions
77
atom_gems/AtomTutorials/Assets/VegetationBending/MeshMotionVectorVegetationBending.azsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) Contributors to the Open 3D Engine Project. | ||
* For complete copyright and license terms please see the LICENSE at the root of this distribution. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 OR MIT | ||
* | ||
*/ | ||
|
||
#include <Atom/Features/PBR/DefaultObjectSrg.azsli> | ||
#include <VegetationBending_Common.azsli> | ||
|
||
#include <scenesrg.srgi> | ||
#include <viewsrg.srgi> | ||
|
||
#include <Atom/RPI/ShaderResourceGroups/DefaultDrawSrg.azsli> | ||
|
||
struct VSInput | ||
{ | ||
float3 m_position : POSITION; | ||
float3 m_normal : NORMAL; | ||
|
||
float4 m_optional_color : COLOR0; | ||
}; | ||
|
||
struct VSOutput | ||
{ | ||
float4 m_position : SV_Position; | ||
float3 m_worldPos : TEXCOORD0; | ||
float3 m_worldPosPrev: TEXCOORD1; | ||
}; | ||
|
||
struct PSOutput | ||
{ | ||
float2 m_motion : SV_Target0; | ||
}; | ||
|
||
VSOutput MainVS(VSInput IN) | ||
{ | ||
VSOutput OUT; | ||
|
||
float4x4 objectToWorld = SceneSrg::GetObjectToWorldMatrix(ObjectSrg::m_objectId); | ||
float4 worldPosition = mul(objectToWorld, float4(IN.m_position, 1.0)); | ||
|
||
float4x4 prevObjectToWorld = SceneSrg::GetObjectToWorldMatrixPrev(ObjectSrg::m_objectId); | ||
float4 prevWorldPosition = mul(prevObjectToWorld, float4(IN.m_position, 1.0)); | ||
|
||
float currentTime = SceneSrg::m_time; | ||
worldPosition = ProcessBending(currentTime, IN.m_position, IN.m_normal, IN.m_optional_color, worldPosition, objectToWorld); | ||
float prevTime = SceneSrg::m_prevTime; | ||
prevWorldPosition = ProcessBending(prevTime, IN.m_position, IN.m_normal, IN.m_optional_color, prevWorldPosition, prevObjectToWorld); | ||
|
||
OUT.m_worldPos = worldPosition.xyz; | ||
OUT.m_worldPosPrev = prevWorldPosition.xyz; | ||
OUT.m_position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition); | ||
|
||
return OUT; | ||
} | ||
|
||
PSOutput MainPS(VSOutput IN) | ||
{ | ||
PSOutput OUT; | ||
|
||
// Current clip position | ||
float4 clipPos = mul(ViewSrg::m_viewProjectionMatrix, float4(IN.m_worldPos, 1.0)); | ||
|
||
// Reprojected last frame's clip position, for skinned mesh it also implies last key frame | ||
float4 clipPosPrev = mul(ViewSrg::m_viewProjectionPrevMatrix, float4(IN.m_worldPosPrev, 1.0)); | ||
|
||
float2 motion = (clipPos.xy / clipPos.w - clipPosPrev.xy / clipPosPrev.w) * 0.5; | ||
|
||
OUT.m_motion = motion; | ||
|
||
// Flip y to line up with uv coordinates | ||
OUT.m_motion.y = -OUT.m_motion.y; | ||
|
||
return OUT; | ||
} |
24 changes: 24 additions & 0 deletions
24
atom_gems/AtomTutorials/Assets/VegetationBending/MeshMotionVectorVegetationBending.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"Source" : "MeshMotionVectorVegetationBending.azsl", | ||
|
||
"DepthStencilState" : { | ||
"Depth" : { "Enable" : true, "CompareFunc" : "GreaterEqual" } | ||
}, | ||
|
||
"DrawList" : "motion", | ||
|
||
"ProgramSettings": | ||
{ | ||
"EntryPoints": | ||
[ | ||
{ | ||
"name": "MainVS", | ||
"type": "Vertex" | ||
}, | ||
{ | ||
"name": "MainPS", | ||
"type": "Fragment" | ||
} | ||
] | ||
} | ||
} |
Binary file added
BIN
+3 MB
atom_gems/AtomTutorials/Assets/VegetationBending/Objects/aspen_bark_01_basecolor.tif
Binary file not shown.
Binary file added
BIN
+3 MB
atom_gems/AtomTutorials/Assets/VegetationBending/Objects/aspen_bark_02_basecolor.tif
Binary file not shown.
Binary file added
BIN
+4 MB
atom_gems/AtomTutorials/Assets/VegetationBending/Objects/aspen_leaf_basecolora.tif
Binary file not shown.
Binary file not shown.
94 changes: 94 additions & 0 deletions
94
atom_gems/AtomTutorials/Assets/VegetationBending/VegetationBending.materialtype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"description": "Material Type like StandardPBR, but does bending for vegetation.", | ||
"version": 1, | ||
"propertyLayout": { | ||
"propertyGroups": [ | ||
{ | ||
"$import": "MaterialInputs/VegetationBendingPropertyGroup.json" | ||
}, | ||
// Currently we cannot import property groups across gems, so we are hard coding the full path, even though it is not portable, as a proof of concept. | ||
// There is a GHI to enable importing across gems at https://github.com/o3de/o3de/issues/10623. | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/BaseColorPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/MetallicPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/RoughnessPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/SpecularPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/NormalPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/EmissivePropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/ClearCoatPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/ParallaxPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OpacityPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/UvPropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/IrradiancePropertyGroup.json" | ||
}, | ||
{ | ||
"$import": "{your-path-to-o3de}/o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/GeneralCommonPropertyGroup.json" | ||
} | ||
] | ||
}, | ||
"shaders": [ | ||
{ | ||
"file": "./VegetationBending_ForwardPass.shader", | ||
"tag": "ForwardPass" | ||
}, | ||
{ | ||
"file": "./VegetationBending_ForwardPass_EDS.shader", | ||
"tag": "ForwardPass_EDS" | ||
}, | ||
{ | ||
"file": "Shaders/Shadow/Shadowmap.shader", | ||
"tag": "Shadowmap" | ||
}, | ||
{ | ||
"file": "./VegetationBending_Shadowmap_WithPS.shader", | ||
"tag": "Shadowmap_WithPS" | ||
}, | ||
{ | ||
"file": "./VegetationBending_DepthPass.shader", | ||
"tag": "DepthPass" | ||
}, | ||
{ | ||
"file": "./VegetationBending_DepthPass_WithPS.shader", | ||
"tag": "DepthPass_WithPS" | ||
}, | ||
{ | ||
"file": "./MeshMotionVectorVegetationBending.shader", | ||
"tag": "MeshMotionVector" | ||
} | ||
], | ||
"functors": [ | ||
{ | ||
"type": "Lua", | ||
"args": { | ||
"file": "VegetationBending_ShaderEnable.lua" | ||
} | ||
} | ||
], | ||
"uvNameMap": { | ||
"UV0": "Tiled", | ||
"UV1": "Unwrapped" | ||
} | ||
} |
Oops, something went wrong.