MeshDefinition meshDefinition;
MaterialDefinition materialDefinition;
ShaderParameters shaderParameter{meshDefinition, materialDefinition, nodeDefinition};
+
// Only define skinning accessors for skinning test...
if(permutationSet.permutations.size() > 1)
{
{
option1.AddOption(optionType);
}
+ // No permutation uses extra joint weights.
+ option1.AddJointMacros(0);
rendererState = (rendererState | permutation->rendererStateSet) & ~permutation->rendererStateClear;
}
option1.AddOption(ShaderOption::Type::THREE_TEXTURE);
shaderOption.AddOption(Scene3D::Loader::ShaderOption::Type::SKINNING);
shaderOption.AddJointMacros(mNumberOfJointSets);
}
+ else
+ {
+ shaderOption.AddJointMacros(0);
+ }
if(mHasVertexColor)
{
shaderOption.AddOption(Scene3D::Loader::ShaderOption::Type::COLOR_ATTRIBUTE);
{
Property::Map oldMap = GetMap(mShader);
DALI_LOG_WRITE_FILE(tmpFilename("oldShader", ".txt"), "Vertex Shader:\n"
- << oldMap["vertex"] << "\n\nFragmentShader: " << oldMap["fragment"] << "\n");
+ << oldMap["vertex"] << "\n\nFragmentShader: " << oldMap["fragment"] << "\n");
}
if(newShader)
{
Property::Map newMap = GetMap(newShader);
DALI_LOG_WRITE_FILE(tmpFilename("newShader", ".txt"), "Vertex Shader:\n"
- << newMap["vertex"] << "\n\nFragmentShader: " << newMap["fragment"] << "\n");
+ << newMap["vertex"] << "\n\nFragmentShader: " << newMap["fragment"] << "\n");
}
#endif
}
void RedefineMacro(std::string& shaderCode, const std::string& macro, const std::string& value)
{
- std::string definition = "#define " + macro;
- std::size_t found = shaderCode.find(definition);
- if(found != std::string::npos)
+ if(!value.empty())
{
- std::size_t insertionPoint = found + definition.length();
+ std::string definition = "#define " + macro;
+ std::size_t found = shaderCode.find(definition);
+ if(found != std::string::npos)
+ {
+ std::size_t insertionPoint = found + definition.length();
- // Automatically insert line-continuation character into value
- std::regex re("\n");
- std::sregex_token_iterator first{value.begin(), value.end(), re, -1}, last;
- for(auto i = first; i != last; ++i)
+ // Automatically insert line-continuation character into value
+ std::regex re("\n");
+ std::sregex_token_iterator first{value.begin(), value.end(), re, -1}, last;
+ for(auto i = first; i != last; ++i)
+ {
+ std::string line = std::string(" \\\n") + (*i).str();
+ shaderCode.insert(insertionPoint, line);
+ insertionPoint += line.length();
+ }
+ }
+ }
+ else
+ {
+ std::size_t invocation = shaderCode.rfind(macro);
+ if(invocation != std::string::npos)
{
- std::string line = std::string(" \\\n") + (*i).str();
- shaderCode.insert(insertionPoint, line);
- insertionPoint += line.length();
+ std::size_t start = shaderCode.rfind("\n", invocation);
+ std::size_t end = shaderCode.find("\n", invocation);
+ shaderCode.erase(start, end - start);
}
}
}
AddMacroDefinition(ADD_EXTRA_SKINNING_ATTRIBUTES, attributes.str());
AddMacroDefinition(ADD_EXTRA_WEIGHTS, weights.str());
}
+ else
+ {
+ AddMacroDefinition(ADD_EXTRA_SKINNING_ATTRIBUTES, std::string{});
+ AddMacroDefinition(ADD_EXTRA_WEIGHTS, std::string{});
+ }
}
void ShaderOption::AddMacroDefinition(std::string macro, std::string definition)