Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17076

RenderTure + Material Blur = (Run On Android So Hard)

$
0
0

@rickystone wrote:

void EndlessScene::Blur()
{
auto s = Director::getInstance()->getWinSize();
// create a render texture, this is what we are going to draw into
auto _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
_target->setPosition(Vec2(s.width / 2, s.height / 2));

// note that the render texture is a Node, and contains a sprite of its texture for convience,
// so we can just parent it to the scene like any other Node
this->addChild(_target, -1);
_target->beginWithClear(1, 0, 0, 1);
this->visit();
_target->end();

auto spriteDraw = Sprite::createWithTexture(_target->getSprite()->getTexture());
addChild(spriteDraw,10);
spriteDraw->setRotation(180);
spriteDraw->setScaleX(-1);
spriteDraw->setPosition(Vec2(s.width/2, s.height/2));

auto properties = Properties::createNonRefCounted("Materials/2d_effects.material#sample");
Material *mat1 = Material::createWithProperties(properties);
spriteDraw->setGLProgramState(mat1->getTechniqueByName("blur")->getPassByIndex(0)->getGLProgramState());
spriteDraw->runAction(Sequence::create(FadeOut::create(2.0),RemoveSelf::create(),NULL));

}

very hard to run on android....

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17076

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>