2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-scene3d/public-api/loader/shader-definition-option.h>
24 namespace Dali::Scene3D::Loader
28 static constexpr std::string_view OPTION_KEYWORD[] =
33 "METALLIC_ROUGHNESS_TEX",
39 "MATERIAL_SPECULAR_TEXTURE",
40 "MATERIAL_SPECULAR_COLOR_TEXTURE",
50 static constexpr uint32_t NUMBER_OF_OPTIONS = sizeof(OPTION_KEYWORD) / sizeof(OPTION_KEYWORD[0]);
53 void ShaderDefinitionOption::SetTransparency()
55 mOptionHash |= (1 << NUMBER_OF_OPTIONS);
58 void ShaderDefinitionOption::AddOption(Type shaderDefinitionOptionType)
60 mOptionHash |= (1 << static_cast<uint32_t>(shaderDefinitionOptionType));
63 uint64_t ShaderDefinitionOption::GetOptionHash() const
68 void ShaderDefinitionOption::GetDefines(std::vector<std::string>& defines) const
71 for(uint32_t i = 0; i < NUMBER_OF_OPTIONS; ++i)
73 if(mOptionHash & 1 << i)
75 defines.push_back(OPTION_KEYWORD[i].data());
80 std::string_view ShaderDefinitionOption::GetDefineKeyword(Type shaderDefinitionOptionType)
82 return OPTION_KEYWORD[static_cast<uint32_t>(shaderDefinitionOptionType)];
85 } // namespace Dali::Scene3D::Loader