Open 3D Engine GradientSignal Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
GradientSignal::ImageGradientComponent Class Reference

#include <ImageGradientComponent.h>

Inherits AZ::Component, AZ::Data::AssetBus::Handler, GradientRequestBus::Handler, ImageGradientRequestBus::Handler, ImageGradientModificationBus::Handler, AzFramework::PaintBrushNotificationBus::Handler, and GradientTransformNotificationBus::Handler.

Public Member Functions

 AZ_COMPONENT (ImageGradientComponent, ImageGradientComponentTypeId)
 
 ImageGradientComponent (const ImageGradientConfig &configuration)
 
void Activate () override
 
void Deactivate () override
 
bool ReadInConfig (const AZ::ComponentConfig *baseConfig) override
 
bool WriteOutConfig (AZ::ComponentConfig *outBaseConfig) const override
 
float GetValue (const GradientSampleParams &sampleParams) const override
 
void GetValues (AZStd::span< const AZ::Vector3 > positions, AZStd::span< float > outValues) const override
 
void OnAssetReady (AZ::Data::Asset< AZ::Data::AssetData > asset) override
 
void OnAssetReloaded (AZ::Data::Asset< AZ::Data::AssetData > asset) override
 
AZStd::string GetImageAssetPath () const override
 
AZStd::string GetImageAssetSourcePath () const override
 
void SetImageAssetPath (const AZStd::string &assetPath) override
 
void SetImageAssetSourcePath (const AZStd::string &assetPath) override
 
uint32_t GetImageHeight () const override
 
uint32_t GetImageWidth () const override
 
AZ::Vector2 GetImagePixelsPerMeter () const override
 
void StartImageModification () override
 
void EndImageModification () override
 
void GetPixelValuesByPosition (AZStd::span< const AZ::Vector3 > positions, AZStd::span< float > outValues) const override
 
void SetPixelValuesByPosition (AZStd::span< const AZ::Vector3 > positions, AZStd::span< const float > values) override
 
void GetPixelIndicesForPositions (AZStd::span< const AZ::Vector3 > positions, AZStd::span< PixelIndex > outIndices) const override
 
void GetPixelValuesByPixelIndex (AZStd::span< const PixelIndex > positions, AZStd::span< float > outValues) const override
 
void SetPixelValuesByPixelIndex (AZStd::span< const PixelIndex > positions, AZStd::span< const float > values) override
 
bool ImageIsModified () const
 

Static Public Member Functions

static void GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetIncompatibleServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetRequiredServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void GetDependentServices (AZ::ComponentDescriptor::DependencyArrayType &services)
 
static void Reflect (AZ::ReflectContext *context)
 

Protected Member Functions

AZ::Data::Asset< AZ::RPI::StreamingImageAsset > GetImageAsset () const
 
void SetImageAsset (const AZ::Data::Asset< AZ::RPI::StreamingImageAsset > &asset)
 
AZStd::vector< float > * GetImageModificationBuffer ()
 
void OnPaintModeBegin () override
 
void OnPaintModeEnd () override
 
AZ::Color OnGetColor (const AZ::Vector3 &brushCenter) const override
 
void OnGradientTransformChanged (const GradientTransform &newTransform) override
 
void CreateImageModificationBuffer ()
 
void ClearImageModificationBuffer ()
 
bool ModificationBufferIsActive () const
 
void UpdateCachedImageBufferData (const AZ::RHI::ImageDescriptor &imageDescriptor, AZStd::span< const uint8_t > imageData)
 
void GetSubImageData ()
 
float GetValueFromImageData (SamplingType samplingType, const AZ::Vector3 &uvw, float defaultValue) const
 
float GetPixelValue (AZ::u32 x, AZ::u32 y) const
 
float InvertYAndGetPixelValue (AZ::u32 x, AZ::u32 invertedY) const
 
float GetTerrariumPixelValue (AZ::u32 x, AZ::u32 y) const
 
void SetupMultiplierAndOffset (float min, float max)
 
void SetupDefaultMultiplierAndOffset ()
 
void SetupAutoScaleMultiplierAndOffset ()
 
void SetupManualScaleMultiplierAndOffset ()
 
void Get4x4Neighborhood (uint32_t x, uint32_t y, AZStd::array< AZStd::array< float, 4 >, 4 > &values) const
 
float GetClampedValue (int32_t x, int32_t y) const
 
float GetValueForSamplingType (SamplingType samplingType, AZ::u32 x0, AZ::u32 y0, float pixelX, float pixelY) const
 
float GetTilingX () const override
 
void SetTilingX (float tilingX) override
 
float GetTilingY () const override
 
void SetTilingY (float tilingY) override
 
bool PixelIndexIsValid (const PixelIndex &pixelIndex) const
 

Friends

class EditorImageGradientComponent
 

Detailed Description

calculates a gradient value based on image data

Member Function Documentation

◆ GetPixelValue()

float GradientSignal::ImageGradientComponent::GetPixelValue ( AZ::u32  x,
AZ::u32  y 
) const
protected

Read the pixel from our image data at the given XY coordinates. This will read from image modification buffer if it exists or else from the image asset, using the component's mip and channel settings. Note that image space Y is inverted from world space because in images, 0 is the top corner and +Y goes down, but in world space we want 0 to be the bottom, and +Y goes up. If you want to get the pixel value using a Y calculated from world space, call InvertYAndGetPixelValue() instead.

Parameters
xThe X coordinate in image space.
yThe Y coordinate in image space.

◆ InvertYAndGetPixelValue()

float GradientSignal::ImageGradientComponent::InvertYAndGetPixelValue ( AZ::u32  x,
AZ::u32  invertedY 
) const
protected

Read the pixel from our image data at the given X coordinate and an inverted Y coordinate. This will read from image modification buffer if it exists or else from the image asset, using the component's mip and channel settings. This is a convenience method that will invert our Y coordinate before calling GetPixelValue() so that we can take a Y coordinate that was calculated from world space axes and invert it into image space as a part of doing the pixel lookup.

Parameters
xThe X coordinate in image space.
invertedYThe inverted Y coordinate in image space.

The documentation for this class was generated from the following file: