Multipass rendering Framework for Sprite and Sprite3D

71 views
Skip to first unread message

huabing.xu

unread,
May 28, 2014, 5:48:00 AM5/28/14
to Ricardo Quesada, cocos2d-js-devel, cocos3d-x-devel

Hi

Together with the release of cocos2d-x v3.1, a new multipass rendering framework has been added in our test case, one for Sprite, one for Sprite3D. We want you to give some suggestions and feedbacks for this feature. If you love them and it is useful for our developers, we will move them to the core of cocos2d-x.

Use case for multipass rendering

This framework will accelerate the speed of implementing these features:

1. If you have a character in game, his HP is very low, you want to show an red outline around him. Or a character has a skill, which will make him blurred.

2. You want to apply a special effect to a sprite, EG, making a grey scale sprite based on a color texture, scale RGB component of the sprite. etc

Multipass rendering for sprite

Test case: testcpp->Shader-Sprite.

Code: tests/cpp-tests/Classes/ShaderTest/ShaderTest2.cpp

The design structure of this framework is:

  1. A new class EffectSprite, subclassed from Sprite, it has interfaces like addEffect(), setEffect()

  2. A base class Effect, and its subclass such as EffectBlur, EffectOutline. etc, which containsGLProgramState together with some parameters.

  3. When rendering, iterate every effect, and draw sprite multiple times.

Multipass rendering for Sprite3D

Test case: testcpp->Node: Sprite3D->Sprite3D with effects.

Code: tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp

Generally, the framework is similar as EffectSprite/Effect, differences are:

  1. The names are EffectSprite3D/Effect3D.

  2. EffectSprite is rendered using a QuadCommand, but EffectSprite3D is rendered using a CustomCommand.


We appreciate your suggestions and comments for this framework.

Thanks

Reply all
Reply to author
Forward
0 new messages