0
votes

I'm writing "for fun" my own graphic engine for Android with OpenGL ES 2.0.

After managing a whole scene with multiple objects mesh, I'm trying to implement Shadow Volumes.

The logic is (simplified) : first, I create an object (with vertices, faces, edges and all data) from a binary file. After that, I create a Vertex Buffer and draw elements.

Until now, I used transformation (scale, translation, rotation) with OpenGL functions on the model matrix (glRotate, etc..).

But for using Shadow Volume, I must, every time an object or light is transformed, calculate which faces are in front of light and the silhouette. So I use a loop on my vertex array.

My question is : Where to do transformations ? Do I have to transform the vertex array on every change and reload it in the Vertex Buffer ?

According to this, it's a bad thing : Android opengl modify vertex array after draw call

So, what is the best practice ?

Sorry for my poor english and thank you in advance ;)

1

1 Answers

1
votes

I only roughly remember shadow volumes, but if I remember correctly then you first determine face in front of the light, the border of these faces is the silhouette which spans the volume, right?

So you want to do something like this for every vertex normal n and the lightvector l:

front = (l dot M * n) < 0.0 ? true : false

where M is the inverse transposed of your vertex transformation matrix.

Instead of multiplying each normal with n, can't you compute a proper transformation for the lightvector...ie a matrix Ml with:

(Ml * l dot n) = (l dot M * n)

That would be my idea.