diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardCommonPropertyGroup.json b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardCommonPropertyGroup.json new file mode 100644 index 00000000..e790ebc7 --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardCommonPropertyGroup.json @@ -0,0 +1,107 @@ +{ + "name": "general", + "displayName": "General Settings", + "description": "General settings.", + "properties": [ + { + "name": "doubleSided", + "displayName": "Double-sided", + "description": "Whether to render back-faces or just front-faces.", + "type": "Bool", + "connection": { + "type": "InternalProperty", + "name": "doubleSided" + } + }, + { + "name": "applySpecularAA", + "displayName": "Apply Specular AA", + "description": "Whether to apply specular anti-aliasing in the shader.", + "type": "Bool", + "defaultValue": true, + "connection": { + "type": "ShaderOption", + "name": "o_applySpecularAA" + } + }, + { + "name": "enableShadows", + "displayName": "Receive Shadows", + "description": "Whether to use the shadow maps during lighting.", + "type": "Bool", + "defaultValue": false, + "connection": { + "type": "ShaderOption", + "name": "o_enableShadows" + } + }, + { + // This will have to be connected manually by the .materialtype, because some material types + // have an additional "Shadowmap_WithPS" shader in addition to "Shadowmap". + "name": "castShadows", + "displayName": "Cast Shadows", + "description": "Whether to cast shadows onto other objects.", + "type": "Bool", + "defaultValue": false, + "connection": { + "type": "InternalProperty", + "name": "castShadows" + } + }, + { + "name": "enableDirectionalLights", + "displayName": "Enable Directional Lights", + "description": "Whether to use directional lights.", + "type": "Bool", + "defaultValue": true, + "connection": { + "type": "ShaderOption", + "name": "o_enableDirectionalLights" + } + }, + { + "name": "enablePunctualLights", + "displayName": "Enable Punctual Lights", + "description": "Whether to use punctual lights.", + "type": "Bool", + "defaultValue": true, + "connection": { + "type": "ShaderOption", + "name": "o_enablePunctualLights" + } + }, + { + "name": "enableAreaLights", + "displayName": "Enable Area Lights", + "description": "Whether to use area lights.", + "type": "Bool", + "defaultValue": true, + "connection": { + "type": "ShaderOption", + "name": "o_enableAreaLights" + } + }, + { + "name": "enableIBL", + "displayName": "Enable IBL", + "description": "Whether to use Image Based Lighting (IBL).", + "type": "Bool", + "defaultValue": true, + "connection": { + "type": "ShaderOption", + "name": "o_enableIBL" + } + }, + { + "name": "forwardPassIBLSpecular", + "displayName": "Forward Pass IBL Specular", + "description": "Whether to apply IBL specular in the forward pass.", + "type": "Bool", + "defaultValue": false, + "connection": { + "type": "ShaderOption", + "name": "o_materialUseForwardPassIBLSpecular" + } + } + ] +} diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardOpacityPropertyGroup.json b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardOpacityPropertyGroup.json new file mode 100644 index 00000000..11154329 --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardOpacityPropertyGroup.json @@ -0,0 +1,87 @@ +{ + "name": "opacity", + "displayName": "Opacity", + "description": "Properties for configuring the materials transparency.", + "properties": [ + { + "name": "mode", + "displayName": "Opacity Mode", + "description": "Indicates the general approach how transparency is to be applied.", + "type": "Enum", + "enumValues": [ "Opaque", "Cutout", "Blended", "TintedTransparent" ], + "defaultValue": "Cutout", + "connection": { + "type": "ShaderOption", + "name": "o_opacity_mode" + } + }, + { + "name": "alphaSource", + "displayName": "Alpha Source", + "description": "Indicates whether to get the opacity texture from the Base Color map (Packed) or from a separate greyscale texture (Split).", + "type": "Enum", + "enumValues": [ "Packed", "Split", "None" ], + "defaultValue": "Packed", + "connection": { + "type": "ShaderOption", + "name": "o_opacity_source" + } + }, + { + "name": "textureMap", + "displayName": "Texture", + "description": "Texture for defining surface opacity.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_opacityMap" + } + }, + { + "name": "textureMapUv", + "displayName": "UV", + "description": "Opacity map UV set", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "name": "m_opacityMapUvIndex" + } + }, + { + "name": "factor", + "displayName": "Factor", + "description": "Factor for cutout threshold and blending", + "type": "Float", + "min": 0.0, + "max": 1.0, + "defaultValue": 0.5, + "connection": { + "type": "ShaderInput", + "name": "m_opacityFactor" + } + }, + { + "name": "alphaAffectsSpecular", + "displayName": "Alpha affects specular", + "description": "How much the alpha value should also affect specular reflection. This should be 0.0 for materials where light can transmit through their physical surface (like glass), but 1.0 when alpha determines the very presence of a surface (like hair or grass)", + "type": "float", + "min": 0.0, + "max": 1.0, + "defaultValue": 0.0, + "connection": { + "type": "ShaderInput", + "name": "m_opacityAffectsSpecularFactor" + } + } + ], + "functors": [ + { + "type": "Lua", + "args": { + "file": "Materials/Types/StandardPBR_HandleOpacityMode.lua" + } + } + ] +} diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.azsli b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.azsli new file mode 100644 index 00000000..82a1990a --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.azsli @@ -0,0 +1,113 @@ +/* + * 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 + * + */ + +#pragma once + +#define ENABLE_VERTEX_COLOR 1 + +//TODO(MaterialPipeline): Inline the MaterialSrg files since they aren't reused. +//TODO(MaterialPipeline): Try removing different parts of the SRG and see how hard/easy it is to customize the surface function. +#include + +#include +#include + +#if MATERIALPIPELINE_SHADER_HAS_PIXEL_STAGE + + COMMON_OPTIONS_BASE_COLOR() + COMMON_OPTIONS_VERTEX_COLOR() + COMMON_OPTIONS_ROUGHNESS() + COMMON_OPTIONS_METALLIC() + COMMON_OPTIONS_SPECULAR_F0() + COMMON_OPTIONS_NORMAL() + COMMON_OPTIONS_CLEAR_COAT() + COMMON_OPTIONS_OCCLUSION() + COMMON_OPTIONS_EMISSIVE() + COMMON_OPTIONS_PARALLAX() + + bool ShouldHandleParallax() + { + // Parallax mapping's non uniform uv transformations break screen space subsurface scattering, disable it when subsurface scattering is enabled. + return !o_enableSubsurfaceScattering && o_parallax_feature_enabled && o_useHeightmap; + } + + bool NeedsTangentFrame() + { + return ShouldHandleParallax() || o_normal_useTexture || (o_clearCoat_enabled && o_clearCoat_normal_useTexture); + } + + // Callback function for ParallaxMapping.azsli + DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy) + { + return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy); + } + + + #include + + // custom geom shaders + #include "BillboardStandardPBR_VertexEval.azsli" + //#include + + #include + #include + + #include + #include + +#elif MATERIALPIPELINE_SHADER_HAS_GEOMETRIC_PIXEL_STAGE + + COMMON_OPTIONS_PARALLAX() + + bool ShouldHandleParallax() + { + // TODO(MaterialPipeline): This is the same as the other ShouldHandleParallax() above, needs to be factored out + bool canHandleParallax = !o_enableSubsurfaceScattering && o_parallax_feature_enabled && o_useHeightmap; + + // The depth pass shaders need to calculate parallax when the result could affect the depth buffer, or when + // parallax could affect texel clipping. + return canHandleParallax && (o_parallax_enablePixelDepthOffset || o_opacity_mode == OpacityMode::Cutout); + } + + bool NeedsTangentFrame() + { + return ShouldHandleParallax(); + } + + // Callback function for ParallaxMapping.azsli + DepthResult GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy) + { + return SampleDepthFromHeightmap(MaterialSrg::m_heightmap, MaterialSrg::m_sampler, uv, uv_ddx, uv_ddy); + } + + #include + + // custom geom shaders + #include "BillboardStandardPBR_VertexEval.azsli" + //#include + + #include + #include + + #include "Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli" + + void EvaluateSurface(VsOutput IN, PixelGeometryData geoData) + { + GetAlphaAndClip(geoData.uvs); + } + +#else + + //TODO(MaterialPipeline): I think we should rename these to "PositionOnly_*" + + + #include + #include "BillboardStandardPBR_DepthVertexEval.azsli" + //#include + +#endif diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.materialtype b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.materialtype new file mode 100644 index 00000000..02154489 --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR.materialtype @@ -0,0 +1,77 @@ +{ + "description": "Material Type with properties used to define Standard PBR, a metallic-roughness Physically-Based Rendering (PBR) material shading model.", + "version": 5, + "versionUpdates": [ + { + "toVersion": 4, + "actions": [ + {"op": "rename", "from": "opacity.doubleSided", "to": "general.doubleSided"} + ] + }, + { + "toVersion": 5, + "actions": [ + {"op": "rename", "from": "irradiance.color", "to": "irradiance.manualColor"}, + {"op": "setValue", "name": "irradiance.irradianceColorSource", "value": "Manual"} + ] + } + ], + "propertyLayout": { + "propertyGroups": [ + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/BaseColorPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/VertexColorPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/MetallicPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/RoughnessPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/SpecularPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/NormalPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/OcclusionPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/EmissivePropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/ClearCoatPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/ParallaxPropertyGroup.json" + }, + { + "$import": "BillboardOpacityPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/UvPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/IrradiancePropertyGroup.json" + }, + { + "$import": "BillboardCommonPropertyGroup.json" + }, + { + "$import": "@gemroot:Atom_Feature_Common@/Assets/Materials/Types/MaterialInputs/SilhouetteBlockerPropertyGroup.json" + } + ] + }, + "lightingModel": "Standard", + "materialShaderCode": "BillboardStandardPBR.azsli", + "functors": [ + ], + "uvNameMap": { + "UV0": "Tiled", + "UV1": "Unwrapped" + } +} + diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_DepthVertexEval.azsli b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_DepthVertexEval.azsli new file mode 100644 index 00000000..fe5944ab --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_DepthVertexEval.azsli @@ -0,0 +1,42 @@ +/* + * 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 + * + */ + +#pragma once + +#ifndef EvaluateVertexGeometry +#define EvaluateVertexGeometry EvaluateVertexGeometry_DepthPass +#endif + +#include +#include + +#include "GetFacingUser.azsli" + +VsOutput EvaluateVertexGeometry_DepthPass(VsInput IN, VsSystemValues SV) +{ + VsOutput output; + + float4x4 objectToWorld = GetObjectToWorldMatrix(SV.m_instanceId); + float4 worldPosition = mul(objectToWorld, float4(IN.m_position, 1.0)); + //output.m_position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition); + output.m_position = GetFacingUser(objectToWorld, IN.m_position); +#if MATERIALPIPELINE_USES_PREV_VERTEX_POSITION + output.m_worldPos = worldPosition.xyz; + + if (o_prevPosition_isBound) + { + output.m_worldPosPrev = mul(GetObjectToWorldMatrixPrev(SV.m_instanceId), float4(IN.m_optional_prevPosition, 1.0)).xyz; + } + else + { + output.m_worldPosPrev = mul(GetObjectToWorldMatrixPrev(SV.m_instanceId), float4(IN.m_position, 1.0)).xyz; + } +#endif + + return output; +} diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_VertexEval.azsli b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_VertexEval.azsli new file mode 100644 index 00000000..d305d5f3 --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/BillboardStandardPBR_VertexEval.azsli @@ -0,0 +1,115 @@ +/* + * 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 + * + */ + +#pragma once + +#ifndef ENABLE_VERTEX_COLOR +#define ENABLE_VERTEX_COLOR 0 +#endif + +// This #define magic allows you to use the EvaluateVertexGeometry function in this file without making it the final +// EvaluateVertexGeometry used in your shader. Simply #define EvaluateVertexGeometry before including this file +// +#ifndef EvaluateVertexGeometry +#define EvaluateVertexGeometry EvaluateVertexGeometry_BasePBR +#endif + +#include +#include +#include + +#include "GetFacingUser.azsli" + +VsOutput EvaluateVertexGeometry_BasePBR( + float3 position, + float3 normal, + float4 tangent, + float2 uv0, + float2 uv1, + uint instanceId, + bool useVertexColor0, + float4 color0) +{ + VsOutput output; + + float4x4 objectToWorld = GetObjectToWorldMatrix(instanceId); + float4 worldPosition = mul(objectToWorld, float4(position, 1.0)); + output.worldPosition = worldPosition.xyz; + //output.position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition); + output.position = GetFacingUser(objectToWorld, position); + // By design, only UV0 is allowed to apply transforms. + output.uvs[0] = mul(MaterialSrg::m_uvMatrix, float3(uv0, 1.0)).xy; + output.uvs[1] = uv1; + + output.normal = normal; + output.tangent = tangent; + +#if ENABLE_VERTEX_COLOR + if(useVertexColor0) + { + output.color0 = color0; + } + else + { + output.color0 = float4(1,1,1,1); + } +#endif + + // Set the instanceId on the output so the pixel shader can use it + // since you can't use SV_InstanceID for both a vertex and a pixel shader at the same time + output.m_instanceId = instanceId; + + return output; +} + +void GetVertexColor(VsInput IN, out float4 color, out bool useVertexColor) +{ +#if ENABLE_VERTEX_COLOR + color = IN.m_optional_color0; + useVertexColor = o_color0_isBound; +#else + color = float4(1.0f, 1.0f, 1.0f, 1.0f); + useVertexColor = false; +#endif +} + +VsOutput EvaluateVertexGeometry_BasePBR(VsInput IN, VsSystemValues SV) +{ + float4 color0; + bool useVertexColor0; + GetVertexColor(IN, color0, useVertexColor0); + + return EvaluateVertexGeometry_BasePBR( + IN.position, + IN.normal, + IN.tangent, + IN.uv0, + IN.uv1, + SV.m_instanceId, + useVertexColor0, + color0); +} + +VsOutput EvaluateVertexGeometry_BasePBR( + float3 position, + float3 normal, + float4 tangent, + float2 uv0, + float2 uv1, + uint instanceId) +{ + return EvaluateVertexGeometry_BasePBR( + position, + normal, + tangent, + uv0, + uv1, + instanceId, + false, + float4(1.0f, 1.0f, 1.0f, 1.0f)); +} diff --git a/Gems/Billboards/Assets/BillboardStandardPBR/GetFacingUser.azsli b/Gems/Billboards/Assets/BillboardStandardPBR/GetFacingUser.azsli new file mode 100644 index 00000000..ce49160a --- /dev/null +++ b/Gems/Billboards/Assets/BillboardStandardPBR/GetFacingUser.azsli @@ -0,0 +1,16 @@ +#pragma once + +#include + + +float4 GetFacingUser( float4x4 objectToWorld, float3 inPosition) +{ + float3 vpos = mul((float3x3)objectToWorld, inPosition); + const float4 worldCoord = float4(objectToWorld[0][3],objectToWorld[1][3],objectToWorld[2][3],1); + + const float4x4 Pm = ViewSrg::m_projectionMatrix; + const float4x4 Vm = ViewSrg::m_viewMatrix; + float4 viewPos = mul(Vm, worldCoord) + float4(vpos,0); + float4 outPos = mul(Pm, viewPos); + return outPos; +}; diff --git a/Gems/Billboards/Assets/SampleMaterial/SampleBillboardMaterial.material b/Gems/Billboards/Assets/SampleMaterial/SampleBillboardMaterial.material new file mode 100755 index 00000000..b93ea6d5 --- /dev/null +++ b/Gems/Billboards/Assets/SampleMaterial/SampleBillboardMaterial.material @@ -0,0 +1,9 @@ +{ + "materialType": "../BillboardStandardPBR/BillboardStandardPBR.materialtype", + "materialTypeVersion": 5, + "propertyValues": { + "baseColor.textureMap": "gl-tree-01.png", + "general.enableShadows": true, + "opacity.mode": "Cutout" + } +} \ No newline at end of file diff --git a/Gems/Billboards/Assets/SampleMaterial/gl-tree-01.png b/Gems/Billboards/Assets/SampleMaterial/gl-tree-01.png new file mode 100644 index 00000000..a78a09f5 Binary files /dev/null and b/Gems/Billboards/Assets/SampleMaterial/gl-tree-01.png differ diff --git a/Gems/Billboards/Assets/SampleMaterial/notice b/Gems/Billboards/Assets/SampleMaterial/notice new file mode 100644 index 00000000..b2912f82 --- /dev/null +++ b/Gems/Billboards/Assets/SampleMaterial/notice @@ -0,0 +1 @@ +The texture (gl-tree-01.png) is CC0 provided by https://graphicslearning.com/. Thanks! diff --git a/Gems/Billboards/CMakeLists.txt b/Gems/Billboards/CMakeLists.txt new file mode 100644 index 00000000..d3af6e76 --- /dev/null +++ b/Gems/Billboards/CMakeLists.txt @@ -0,0 +1,21 @@ +# 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 +# + +o3de_gem_setup("Billboards") + +# This indicates to the Builders applications(AssetProcessor, AssetBuilder, AssetBundler) +# that the gem should be added to the "cmake_dependencies..assetbuilder.setreg" +# which is generated when cmake configure occurs. +# Also tooling applications such as the Editor needs the CMake alias +# to see the gem as active +if(PAL_TRAIT_BUILD_HOST_TOOLS) + ly_create_alias(NAME ${gem_name}.Builders NAMESPACE Gem) + ly_create_alias(NAME ${gem_name}.Tools NAMESPACE Gem) + + # Add in CMake dependencies for each gem dependency listed in this gem's gem.json file + # for the Tools and Builders gem variants + o3de_add_variant_dependencies_for_gem_dependencies(GEM_NAME ${gem_name} VARIANTS Tools Builders) +endif() diff --git a/Gems/Billboards/Registry/assetprocessor_settings.setreg b/Gems/Billboards/Registry/assetprocessor_settings.setreg new file mode 100644 index 00000000..93081656 --- /dev/null +++ b/Gems/Billboards/Registry/assetprocessor_settings.setreg @@ -0,0 +1,18 @@ +{ + "Amazon": { + "AssetProcessor": { + "Settings": { + "ScanFolder Billboards/Assets": { + "watch": "@GEMROOT:Billboards@/Assets", + "recursive": 1, + "order": 101 + }, + "ScanFolder Billboards/Registry": { + "watch": "@GEMROOT:Billboards@/Registry", + "recursive": 1, + "order": 102 + } + } + } + } +} diff --git a/Gems/Billboards/docs/MaterialEditor.png b/Gems/Billboards/docs/MaterialEditor.png new file mode 100644 index 00000000..19ca44e9 Binary files /dev/null and b/Gems/Billboards/docs/MaterialEditor.png differ diff --git a/Gems/Billboards/docs/demo_c.gif b/Gems/Billboards/docs/demo_c.gif new file mode 100644 index 00000000..8d8bfbcf Binary files /dev/null and b/Gems/Billboards/docs/demo_c.gif differ diff --git a/Gems/Billboards/gem.json b/Gems/Billboards/gem.json new file mode 100644 index 00000000..d258b829 --- /dev/null +++ b/Gems/Billboards/gem.json @@ -0,0 +1,30 @@ +{ + "gem_name": "Billboards", + "version": "1.0.0", + "display_name": "Billboards", + "license": "Apache-2.0", + "license_url": "https://opensource.org/licenses/Apache-2.0", + "origin": "Robotec.ai", + "origin_url": "https://robotec.ai", + "type": "Asset", + "summary": "A gem that will provide Atom material for billboards", + "canonical_tags": [ + "Gem" + ], + "user_tags": [ + "Billboards" + ], + "platforms": [ + "" + ], + "icon_path": "preview.png", + "requirements": "None", + "documentation_url": "", + "dependencies": [ + ], + "repo_uri": "", + "compatible_engines": [ + ], + "engine_api_dependencies":[ + ] +} diff --git a/Gems/Billboards/preview.png b/Gems/Billboards/preview.png new file mode 100644 index 00000000..83afae48 Binary files /dev/null and b/Gems/Billboards/preview.png differ diff --git a/Gems/Billboards/readme.md b/Gems/Billboards/readme.md new file mode 100644 index 00000000..a87cd365 --- /dev/null +++ b/Gems/Billboards/readme.md @@ -0,0 +1,72 @@ +# Billboards in O3DE +![](docs/demo_c.gif) + +A Standard PBR implementation that makes a mesh always face the camera. +It is usefull to be used as last LOD for vegetation: +- reduce number of vertices to be drawn +- can be used with cutout and without opacity +- reduce alliasing when rendering far-away vegetation + +# Usage + +You can create new material using material type in O3DE material editor. + +![](docs/MaterialEditor.png) + +> [!IMPORTANT] +> Receiving and casting shadows does not work. + +# Porting to newer version of the O3DE. + +This gem contains a lot of code copied from Atom Gem. Lest break down files and changes that I've made to enable the conversion: + + +# `Assets/BillboardStandardPBR/BillboardOpacityPropertyGroup.json` + +Orginal file : `o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OpacityPropertyGroup.json` +Changes: + - Set `Opacity Mode` by default to `Cutout` + +# `Assets/BillboardStandardPBR/BillboardCommonPropertyGroup.json` + +Orginal file : `o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/CommonPropertyGroup.json` +Changes: + - Disable `Cast Shadows` + - Disable `Receive Shadows` + +# `Assets/BillboardStandardPBR/BillboardStandardPBR.materialtype` + +Orginal file : `o3de/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype` +Changes: +- Add `@gemroot:Atom_Feature_Common@/` to reference JSONs from Atom gem +- Reference custom `BillboardOpacityPropertyGroup.json` and `BillboardCommonPropertyGroup.json` + +# `Assets/BillboardStandardPBR/BillboardStandardPBR.azsli` + +Original file `StandardPBR.azsli` +Changes: +```diff +- #include "BillboardStandardPBR_VertexEval.azsli" ++ //#include +``` + +# `Assets/BillboardStandardPBR/BillboardStandardPBR_VertexEval.azsli` + +Original file `StandardPBR_VertexEval.azsli` +Changes: +- include `GetFacingUser.azsli` +```diff +- output.position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition); ++ output.position = GetFacingUser(objectToWorld, position); +``` + +# `Assets/BillboardStandardPBR/BillboardStandardPBR_DepthVertexEval.azsli` + +Original file `DepthVertexEval.azsli` +Changes: +- include `GetFacingUser.azsli` +```diff +- output.m_position = mul(ViewSrg::m_viewProjectionMatrix, worldPosition); ++ output.m_position = GetFacingUser(objectToWorld, IN.m_position); +``` + diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 0165d62b..00000000 --- a/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -The default license for Open 3D Engine is the Apache License, Version 2.0 (see LICENSE_APACHE2.TXT). This license applies to the majority of the codebase. Certain Gems may be licensed under the MIT License (see LICENSE_MIT.TXT). For comprehensive licensing details pertaining to individual Gems, please consult the `gem.json` files in each folder. - -The contributions must be made under the respective licenses. diff --git a/LICENSE_APACHE2.TXT b/LICENSE.TXT similarity index 100% rename from LICENSE_APACHE2.TXT rename to LICENSE.TXT diff --git a/LICENSE_MIT.TXT b/LICENSE_MIT.TXT deleted file mode 100644 index 1b16d6d3..00000000 --- a/LICENSE_MIT.TXT +++ /dev/null @@ -1,7 +0,0 @@ -Copyright Contributors to the Open 3D Engine - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index bea9d361..a01d460e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Note that this is not a "Canonical" part of O3DE - those gems are third-party co | [**Smoothing**](#smoothing) | compatible | | [**ViewportStreamer**](#viewportstreamer) | not verified | | [**WheelAnimTool**](#wheelanimtool) | compatible | +| [**Billboards**]((#billboards) | compatible | # CsvSpawner @@ -505,3 +506,8 @@ The component needs: It should be attached to Dynamic rigid body. The component will compute Jacobian matrix (w.r.t wheel locatio, radius and model) of the robot locomotion. Jacobian will be used to find wheels rotation speed. More in dedicated [readme.md](Gems/WheelAnimTool/readme.md) + +# Billboards + +Billboard material. +More in dedicated [readme.md](Gems/Billboards/readme.md) \ No newline at end of file