diff --git a/cocos2d-x/cocos/renderer/renderer/BaseRenderer.cpp b/cocos2d-x/cocos/renderer/renderer/BaseRenderer.cpp index 7d7889cb..a937c69e 100644 --- a/cocos2d-x/cocos/renderer/renderer/BaseRenderer.cpp +++ b/cocos2d-x/cocos/renderer/renderer/BaseRenderer.cpp @@ -57,6 +57,8 @@ const size_t BaseRenderer::cc_matViewProj = std::hash{}("cc_matView const size_t BaseRenderer::cc_cameraPos = std::hash{}("cc_cameraPos"); const size_t BaseRenderer::cc_time = std::hash{}("cc_time"); +Effect::Property* BaseRenderer::defaultTextureProperty = nullptr; + const size_t BaseRenderer::cc_shadow_map[4] = { std::hash{}("cc_shadow_map_0"), std::hash{}("cc_shadow_map_1"), @@ -212,11 +214,14 @@ void BaseRenderer::setProperty (const Effect::Property* prop) if (nullptr == prop->getValue()) { - Effect::Property tmp(propName, propType); - prop = &tmp; - if (Effect::Property::Type::TEXTURE_2D == propType) + if (Effect::Property::Type::TEXTURE_2D == propType) { - tmp.setTexture(_defaultTexture); + if (defaultTextureProperty == nullptr) + { + defaultTextureProperty = new Effect::Property(propName, propType); + defaultTextureProperty->setTexture(_defaultTexture); + } + prop = defaultTextureProperty; } } diff --git a/cocos2d-x/cocos/renderer/renderer/BaseRenderer.h b/cocos2d-x/cocos/renderer/renderer/BaseRenderer.h index d4e70f5f..1a4bff22 100644 --- a/cocos2d-x/cocos/renderer/renderer/BaseRenderer.h +++ b/cocos2d-x/cocos/renderer/renderer/BaseRenderer.h @@ -152,7 +152,9 @@ protected: static const size_t cc_matViewProj; static const size_t cc_cameraPos; static const size_t cc_time; - + + static Effect::Property* defaultTextureProperty; + static std::vector __tmp_defines__; };