Rendering multiple 3D meshes ( beyond Oliver Marks' example )

69 views
Skip to first unread message

Timon Tomás

unread,
Sep 16, 2016, 4:01:00 PM9/16/16
to Kivy users support
Hi guys,

Based on Oliver Marks' example (http://bazaar.launchpad.net/~oly/python-examples/trunk/files/head:/python-examples/kivy/kivy_with_opengl_multi_mesh/) I have created my own multi-mesh renderer with its own OBJ reader. It is available here: https://github.com/ttimon7/Kivy_OpenGLhttps://github.com/ttimon7/Kivy_OpenGL

In Oliver Marks' example, it seems, that the meshes are displayed correctly. In my example, if I render them with only one color as he did, it seems also fine. BUT, if I add directional lighting to the shaders, something unexpected happens. The attached screenshot  illustrates the problem.

According to the current configuration, the main screen is divided into 2 parts - well, 3 but the leftmost one is only cosmetic, so let's forget about that -, both displaying 2 meshes using the exact same shaders. On the left side, the meshes are displayed by creating RenderContexts for each, setting the individual shaders to each, and adding the meshes' RenderContexts to the main render context which is the widget's canvas (same technique that Oliver Marks used). On the right side, only one RenderContext - and only one shader (vs + fs) - is used, that of the canvas' to display the meshes.

If you run the app ((Python 3, Kivy 1.9.1), you will see, that even though using the exact same shader programs, the meshes are only rendered correctly on the right side (one-RenderContext-case). In the multiple RenderContext case, something goes wrong. To make sure, that the problem is not unique to my implementation, I have introduced minimal modifications to Oliver Mark' example, to get directional lighting, and I got the same - wrong - results.

If any of you, who is more proficient in Kivy and OpenGL took a look at this, that would be a great help. I greatly appreciate all helpful comments. Thanks!
Kivy_Multimesh_Error.png
Reply all
Reply to author
Forward
0 new messages