ddguan

07-28-2014, 01:30 AM

Dear All：

I am learning to write a Phong shader using GLSL. I think the normal vector of each vertex should be computing correctly and provided to the vertex shader and fragment shader to simulating phong mode. How to computing vertex normal vector of a triangle mesh?

I refer to the codes in OpenGL SuperBible, in these codes, GLBatch class is used to represent a triangle mesh and draw the mesh.

I find that the example codes of SuperBible didnot compute the vertex normal, but in the vertex shader and fragment shader, vertex normal vector is used to calculate diffuse and specular components as a input , does the GLBatch class compute vertex normal automatically?

I am learning to write a Phong shader using GLSL. I think the normal vector of each vertex should be computing correctly and provided to the vertex shader and fragment shader to simulating phong mode. How to computing vertex normal vector of a triangle mesh?

I refer to the codes in OpenGL SuperBible, in these codes, GLBatch class is used to represent a triangle mesh and draw the mesh.

I find that the example codes of SuperBible didnot compute the vertex normal, but in the vertex shader and fragment shader, vertex normal vector is used to calculate diffuse and specular components as a input , does the GLBatch class compute vertex normal automatically?