123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /*
- * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
- * its licensors.
- *
- * For complete copyright and license terms please see the LICENSE at the root of this
- * distribution (the "License"). All use of this software is governed by the License,
- * or, if provided, by the license below or the license accompanying this file. Do not
- * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *
- */
- #pragma once
- #include <CommonSampleComponentBase.h>
- #include <Atom/Feature/CoreLights/DirectionalLightFeatureProcessorInterface.h>
- #include <Atom/Feature/CoreLights/SpotLightFeatureProcessorInterface.h>
- #include <AzCore/Component/TickBus.h>
- #include <Utils/ImGuiSidebar.h>
- #include <Utils/Utils.h>
- namespace AtomSampleViewer
- {
- //! Demostrate the effect of Parallax Mapping and Pixel Depth Offset
- class ParallaxMappingExampleComponent final
- : public CommonSampleComponentBase
- , public AZ::TickBus::Handler
- {
- public:
- AZ_COMPONENT(ParallaxMappingExampleComponent, "{C2530F5A-8626-49B7-8913-DDEA25C7E7CD}", CommonSampleComponentBase);
- static void Reflect(AZ::ReflectContext* context);
- ParallaxMappingExampleComponent();
- ~ParallaxMappingExampleComponent() override = default;
- void Activate() override;
- void Deactivate() override;
- private:
- // AZ::TickBus::Handler overrides...
- void OnTick(float deltaTime, AZ::ScriptTimePoint time);
- static constexpr float ConeAngleInnerRatio = 0.9f;
- static constexpr float CutoffIntensity = 0.1f;
- AZ::Render::MeshFeatureProcessorInterface::MeshHandle LoadMesh(
- AZ::Data::Asset<AZ::RPI::ModelAsset> modelAsset,
- AZ::Data::Instance<AZ::RPI::Material> material,
- AZ::Transform transform);
- void CreateDirectionalLight();
- void CreateSpotLight();
- void DrawSidebar();
- void SaveCameraConfiguration();
- void RestoreCameraConfiguration();
- void SetCameraConfiguration();
- void ConfigureCameraToLookDown();
- // Mesh Handles
- AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_planeHandle;
- AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_boxHandle;
- // Light
- AZ::Render::DirectionalLightFeatureProcessorInterface* m_directionalLightFeatureProcessor = nullptr;
- AZ::Render::SpotLightFeatureProcessorInterface* m_spotLightFeatureProcessor = nullptr;
- AZ::Render::DirectionalLightFeatureProcessorInterface::LightHandle m_directionalLightHandle;
- AZ::Render::SpotLightFeatureProcessorInterface::LightHandle m_spotLightHandle;
- float m_lightRotationAngle = 0.f; // in radian
- bool m_lightAutoRotate = true;
- int m_lightType = 0; // 0: diectionalLight, 1: spotLight
- //Assets
- AZ::Data::Asset<AZ::RPI::ModelAsset> m_planeAsset;
- AZ::Data::Asset<AZ::RPI::ModelAsset> m_boxAsset;
- AZ::Data::Asset<AZ::RPI::MaterialAsset> m_defaultMaterialAsset;
- AZ::Data::Asset<AZ::RPI::MaterialAsset> m_parallaxMaterialAsset;
- AZ::Data::Instance<AZ::RPI::Material> m_defaultMaterial;
- AZ::Data::Instance<AZ::RPI::Material> m_parallaxMaterial;
- AZ::RPI::MaterialPropertyIndex m_parallaxEnableIndex;
- AZ::RPI::MaterialPropertyIndex m_parallaxFactorIndex;
- AZ::RPI::MaterialPropertyIndex m_parallaxAlgorithmIndex;
- AZ::RPI::MaterialPropertyIndex m_parallaxQualityIndex;
- AZ::RPI::MaterialPropertyIndex m_parallaxUvIndex;
- AZ::RPI::MaterialPropertyIndex m_pdoEnableIndex;
- // Other UVs that when parallaxUv is changed, they must follow the change.
- AZ::RPI::MaterialPropertyIndex m_ambientOcclusionUvIndex;
- AZ::RPI::MaterialPropertyIndex m_baseColorUvIndex;
- AZ::RPI::MaterialPropertyIndex m_normalUvIndex;
- AZ::RPI::MaterialPropertyIndex m_roughnessUvIndex;
- AZ::RPI::MaterialPropertyIndex m_centerUVIndex;
- AZ::RPI::MaterialPropertyIndex m_tileUIndex;
- AZ::RPI::MaterialPropertyIndex m_tileVIndex;
- AZ::RPI::MaterialPropertyIndex m_scaleUVIndex;
- AZ::RPI::MaterialPropertyIndex m_offsetUIndex;
- AZ::RPI::MaterialPropertyIndex m_offsetVIndex;
- AZ::RPI::MaterialPropertyIndex m_rotationUVIndex;
- // parallax setting
- bool m_parallaxEnable = true;
- bool m_pdoEnable = true;
- float m_parallaxFactor = 0.03f;
- // see StandardPbr.materialtype for the full enum list.
- int m_parallaxAlgorithm = 2; // POM
- int m_parallaxQuality = 2; // High
- int m_parallaxUv = 0; // 0 = UV0, 1 = UV1
- // plane setting
- AZ::Transform m_planeTransform;
- float m_planeRotationAngle = 0.f; // in radian
- float m_planeCenterU = 0.f;
- float m_planeCenterV = 0.f;
- float m_planeTileU = 1.f;
- float m_planeTileV = 1.f;
- float m_planeScaleUV = 1.f;
- float m_planeOffsetU = 0.f;
- float m_planeOffsetV = 0.f;
- float m_planeRotateUV = 0.f; // in degrees
- // original camera configuration
- float m_originalFarClipDistance = 0.f;
- float m_originalCameraFovRadians = 0.f;
- // ImGui
- ImGuiSidebar m_imguiSidebar;
- };
- } // namespace AtomSampleViewer
|