How to make self-written RenderComponent work on all platforms?

I made an extension which implements it’s own component class inherited from RenderComponent. This class handles rendering of geometry, which is integrated deeply with Cocos Creator and uses it’s materials and textures.

It appeared that the extension works only on Web platform and when I try to start an application on Simulator from the Editor, I don’t see any rendering.

So, my question is, should it work right away, or I had to make some additional work to achieve that?

1 Like

Hi, I test your extension on master branch, but has some error, can you provide a finish version for me, so I could check you problem.

@huanxinyin I use latest stable version of the Cocos Creator. It’s 2.4.3. I re-checked on Windows 10 and with stock JavaScript engine which comes with the editor. Everything works fine and without errors.

Here is a sample working project with test particle effect: (6.9 MB)

There are installation instructions on the gitlab extension page, if you want to install it manually. Also there are comprehensive documentation and tutorials if you have any other question on how to use it.

If you still have the error, could you post it here please or on the Issues page on gitlab. I’ll check it as soon as possible.

Hi, native renderer have different render flow, such as the conversion of world coordinates,you can understand the problem with this test project. (282.9 KB)

@huanxinyin I spent some time to understand how Cocos JSB works. And I became frustrated a little because of that render flow differences and architecture as well. The project you sent shows some tips of custom renderer based on Sprite2D, which has static geometry. But I have much more complex case, where geometry can be very different fame after frame. So for WebGL I worked with MeshBuffer directly (obtained from ModelBatcher) to fill it with geometry. Provided sample doesn’t show how to intensively use MeshBuffers. And it actually breaks render flow of the application, because if you add 2d particle system right after the node with CustomComponent, particle effect is not rendered until you delete CustomComponent.
So, for now I’m trying to find any usable sample of component for native renderer which would clearly show how to work with buffers and correctly inject assembler into rendering pipeline. Without luck yet.

Yes, you can try to implement base on MeshRenderer class on native platform, it work base on renderer.MeshAssembler, you can refer jsb-adapter code, and check how a MeshBuffer work on native rendering, you can debug to trace the flow.