X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Fpublic-api%2Floader%2Fmaterial-definition.h;h=39b915368d47627ed33f1e586f46e4ad79753b9a;hb=0ab2af8053436971758161fbf1c4ad73058ac5ce;hp=e6df18e232cfc0800b9e1cbc7393d64ed94f9077;hpb=89641815d206e3bf569f0140ea534146ba8d99c7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/public-api/loader/material-definition.h b/dali-scene3d/public-api/loader/material-definition.h index e6df18e..39b9153 100644 --- a/dali-scene3d/public-api/loader/material-definition.h +++ b/dali-scene3d/public-api/loader/material-definition.h @@ -1,7 +1,7 @@ #ifndef DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H #define DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,26 +17,24 @@ * */ -// INTERNAL INCLUDES -#include "dali-scene3d/public-api/api.h" -#include "dali-scene3d/public-api/loader/environment-definition.h" -#include "dali-scene3d/public-api/loader/index.h" -#include "dali-scene3d/public-api/loader/utils.h" - // EXTERNAL INCLUDES +#include #include +#include #include -#include "dali/public-api/common/vector-wrapper.h" -#include "dali/public-api/math/vector4.h" -namespace Dali -{ -namespace Scene3D -{ -namespace Loader +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + +namespace Dali::Scene3D::Loader { /** * @brief Helper enum for encoding and decoding sampler states. + * @SINCE_2_0.7 */ struct DALI_SCENE3D_API SamplerFlags { @@ -79,47 +77,59 @@ struct DALI_SCENE3D_API SamplerFlags }; /** - * @return SamplerFlags bit pattern calculated from the given Dali Sampler settings. + * @brief Retrieves the bit pattern calculated from the given Dali Sampler settings. + * @SINCE_2_0.7 + * @return SamplerFlags bit pattern. */ static Type Encode(FilterMode::Type minFilter, FilterMode::Type magFilter, WrapMode::Type wrapS, WrapMode::Type wrapT); /** * @brief Decodes the minification filter patter of @a flags into the corresponding FilterMode. + * @SINCE_2_0.7 */ static FilterMode::Type GetMinFilter(Type flags); /** * @brief Decodes the magnification filter patter of @a flags into the corresponding FilterMode. + * @SINCE_2_0.7 */ static FilterMode::Type GetMagFilter(Type flags); /** * @brief Decodes the horizontal wrap pattern of @a flags into the corresponding WrapMode. + * @SINCE_2_0.7 */ static WrapMode::Type GetWrapS(Type flags); /** * @brief Decodes the vertical wrap pattern of @a flags into the corresponding WrapMode. + * @SINCE_2_0.7 */ static WrapMode::Type GetWrapT(Type flags); /** * @brief Creates a Sampler with the settings encoded in @a flags. + * @SINCE_2_0.7 */ static Sampler MakeSampler(Type flags); }; /** * @brief Defines a texture from a combination of an image URI and its sampler definition. + * @SINCE_2_0.7 */ struct DALI_SCENE3D_API TextureDefinition { - std::string mImageUri; - SamplerFlags::Type mSamplerFlags; - ImageDimensions mMinImageDimensions; - SamplingMode::Type mSamplingMode; + std::string mImageUri; // When the texture is loaded from embedded resources, this URI is used as a data stream. + std::string mDirectoryPath; + SamplerFlags::Type mSamplerFlags; + ImageDimensions mMinImageDimensions; + SamplingMode::Type mSamplingMode; + std::vector mTextureBuffer; TextureDefinition(const std::string& imageUri = "", SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR); + TextureDefinition(std::string&& imageUri, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR); + TextureDefinition(std::vector&& textureBuffer, SamplerFlags::Type samplerFlags = SamplerFlags::DEFAULT, ImageDimensions minImageDimensions = ImageDimensions(), SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR); }; /** @@ -127,6 +137,7 @@ struct DALI_SCENE3D_API TextureDefinition * is enabled, and an index of an environment (usually of all environments in a * scene). Textures from the environment are added last when the DALi TextureSet * is being created. + * @SINCE_2_0.7 */ struct DALI_SCENE3D_API MaterialDefinition { @@ -155,6 +166,7 @@ struct DALI_SCENE3D_API MaterialDefinition /** * @brief A(n image based) texture that's used in a material. + * @SINCE_2_0.7 */ struct TextureStage { @@ -186,14 +198,16 @@ struct DALI_SCENE3D_API MaterialDefinition /** * @brief Loads (or, in the case of solid color materials, creates) raw pixel data, * which is then returned. + * @SINCE_2_0.7 * @note This may be called from any thread. */ - RawData LoadRaw(const std::string& imagesPath) const; + RawData LoadRaw(const std::string& imagesPath); /** * @brief Creates Textures from the pixel data in @a raw, gets the * the cube maps from the iEnvironment'th element of @a environments, * then creates a DALi TextureSet and returns it. + * @SINCE_2_0.7 * @note This must be called from the event thread. * @note The textures are added in the following order: 2D, cube maps. */ @@ -201,11 +215,13 @@ struct DALI_SCENE3D_API MaterialDefinition /** * @brief Checks if the given mask matches any of the textures defined. + * @SINCE_2_0.7 */ bool CheckTextures(uint32_t flags) const; /** * @return The alpha test reference value. + * @SINCE_2_0.7 * @note A value of 0.f means no alpha testing. */ float GetAlphaCutoff() const @@ -215,6 +231,7 @@ struct DALI_SCENE3D_API MaterialDefinition /** * @brief Encodes the alpha test reference @a value in flags. + * @SINCE_2_0.7 * @note A value of 0.f means no alpha testing. */ void SetAlphaCutoff(float value) @@ -224,7 +241,8 @@ struct DALI_SCENE3D_API MaterialDefinition } public: // DATA - uint32_t mFlags = 0x0; + std::shared_ptr mRawData; + uint32_t mFlags = 0x0; Index mEnvironmentIdx = 0; Vector4 mColor = Color::WHITE; @@ -234,6 +252,7 @@ public: // DATA float mNormalScale = 1.f; float mOcclusionStrength = 1.f; Vector3 mEmissiveFactor = Vector3::ZERO; + float mIor = -1.0f; float mDielectricSpecular = 0.04f; float mSpecularFactor = 1.0f; Vector3 mSpecularColorFactor = Vector3::ONE; @@ -244,14 +263,16 @@ public: // DATA bool mNeedNormalTexture = true; bool mDoubleSided = false; - bool mIsOpaque = true; - bool mIsMask = false; + Scene3D::Material::AlphaModeType mAlphaModeType = Scene3D::Material::AlphaModeType::OPAQUE; + bool mIsOpaque = true; + bool mIsMask = false; + + bool mShadowAvailable = false; std::vector mTextureStages; + Material mMaterial; }; -} // namespace Loader -} // namespace Scene3D -} // namespace Dali +} // namespace Dali::Scene3D::Loader #endif //DALI_SCENE3D_LOADER_MATERIAL_DEFINITION_H