Passing vertex normals to shader

19 views
Skip to first unread message

Timon Tomás

unread,
Sep 14, 2016, 11:02:29 AM9/14/16
to Kivy users support
Hi guys, I need a little help with passing vertex normals to the shader.

When constructing the Kivy Mesh class, only the "vertices", "indices", "fmt" and "mode" parameters can be given as arguments. As far as I understand, the "vertices" argument is a list of coupled values e.g. [x, y, z, r, g, b, a] following the structure outlined in the "fmt" parameter. The mesh is constructed by Kivy through OpenGL ES 2.0 internally, by reading the "indeces" array, and drawing the shapes specified in "mode".

Now, if I only have vertex position data and assign each vertex the same color, the process is quite optimal. But if I want to pass vertex normals, than I have to add the same vertex multiple times to the "vertives" array - meaning that the x, y, z position values are the same, the only difference is in the normal vector coordinates -, which makes it way less efficient.

    e.g. vertices = [ x1, y1, z1, nx1, ny1, nz1, x2, y2, z2, nx2, ny2, nz2 ], where x1 = x2, y1 = y2, z1 = z2.

It would make sense to be able to pass the vertex position values and the normal vector coordinates separately, and pass along 2 indeces arrays sontaining the order in which the drawing should be performed.

Is there a way to do that? If so, could someone give me a simple, working example?

Thank you in advance!
Reply all
Reply to author
Forward
0 new messages