You can then bind this array to a specific attribute of your shader before each rendering, separately from your non redundant indexed array. You could the construct an array of 12 normals based on the normals for the 4 triangles repeated 3 times for each vertex involved in the triangle. Let's say you have a 4 triangle tetrahedron (4 vertices). This technique consist in storing per triangle normals in CPU memory and construct an array of these to send to the GPU before drawing the mesh. Still, there could be another more exotic technique that you could use. The most often used techniques to compute normals in an OpenGL shader (using dfx/dfy or geometry shader) are not available in gles 2.0. Unfortunately, when it comes to lighting, some way or another, you'll need some normals.Īs you mentioned, for flat shading, you need per triangle normals, which implies vertices duplication, compared to smooth shading.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |