1 #ifndef DALI_SCENE3D_LOADER_SHADER_OPTION_H_
2 #define DALI_SCENE3D_LOADER_SHADER_OPTION_H_
4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <dali/public-api/common/vector-wrapper.h>
24 #include <string_view>
27 #include <dali-scene3d/public-api/api.h>
29 namespace Dali::Scene3D::Loader
31 class DALI_SCENE3D_API ShaderOption
36 GLTF_CHANNELS = 0, // 00001
37 THREE_TEXTURE, // 00002
38 BASE_COLOR_TEXTURE, // 00004
39 METALLIC_ROUGHNESS_TEXTURE, // 00008
40 NORMAL_TEXTURE, // 00010
46 SPECULAR_COLOR, // 00400
48 FLIP_UVS_VERTICAL, // 01000
49 COLOR_ATTRIBUTE, // 02000
50 VEC4_TANGENT, // 04000
51 MORPH_POSITION, // 08000
52 MORPH_NORMAL, // 10000
53 MORPH_TANGENT, // 20000
54 MORPH_VERSION_2_0 // 40000
57 struct MacroDefinition
60 std::string definition;
63 ShaderOption() = default;
64 ShaderOption(const ShaderOption& rhs);
65 ShaderOption& operator=(const ShaderOption& rhs);
67 using HashType = uint64_t;
71 * @brief Sets transparency option.
73 void SetTransparency();
76 * @brief Adds new shader definition option.
77 * If the option is already added, nothin is changed.
79 * @param[in] shaderOptionType Option to be added,
81 void AddOption(Type shaderOptionType);
84 * Adds macro definitions for joints based on the number of joint sets.
86 void AddJointMacros(size_t numberOfJointSets);
89 * Enables empty preprocessor definitions to be defined to a value
91 void AddMacroDefinition(std::string macro, std::string definition);
94 * @brief Retrieves current shader option hash
96 * @return Hash value of currently added options.
98 HashType GetOptionHash() const;
101 * @brief Retrieves a list of define keywords.
103 * @param[out] defines A list of define keywords those are used in this option.
105 void GetDefines(std::vector<std::string>& defines) const;
108 * @brief Retrieves a single shader define keyword of input type.
110 * @param[in] shaderOptionType Shader definition option type to know its keyword.
111 * @return string keyword of shader define.
113 static std::string_view GetDefineKeyword(Type shaderOptionType);
116 * Get any macro definitions
118 const std::vector<MacroDefinition>& GetMacroDefinitions() const;
121 HashType mOptionHash{0u};
123 std::vector<MacroDefinition> mMacros;
126 } // namespace Dali::Scene3D::Loader
128 #endif // DALI_SCENE3D_LOADER_SHADER_OPTION_H_