Material system for 2D

Hi,

I found that there is a material system in cocos2d-x. But i can’t figure out how to apply it to 2d nodes. In tests it is used in a such way:

spriteBlur->setGLProgramState(mat1->getTechniqueByName(“blur”)->getPassByIndex(0)->getGLProgramState());

That doesn’t give any benefits.

And only for Sprite3D:

sprite->setMaterial(mat);

Is it possible to use them for 2D sprites? Or it still under development? or not intended for 2D at all?

Thanks

Any news? Is Material designed to be used only for 3D?

@slackmoehrle, could you check this question? Just choose one of the next answers:

  • material system is not intended for 2d and never will;
  • material system is under development for 2d;
  • material system will be extended to 2d at some far future;

I don’t know the answer to this. Let us ask @ricardo for help.

Material system was designed for 3D, but you can “abuse” it and use it for 2D.

As an example, take a look at the “Material test”, and you will see that 2d sprites are using it.

Thanks. I already found that i have access to shaders via material. But as i mentioned above it doesn’t give any benefits for 2d, just some additional complexity. What i really like in materials - multiple passes. Currently there is no build-in solution for that and the only way (as i know) is to use some wrapper with render textures. Though multiple passes are quite rare so it’s not very important.