Small man (Bill man) Personal Original, welcome to reprint, reprint please indicate the address, small man (Bill man) column address http://blog.csdn.net/bill_man
This article introduces the basic lighting knowledge in Android 3D OpenGL ES. In Android Java Development, GL is used. glable (gl10.gl _ lighting) enables the light source. However, it is worth noting that if we only add this sentence without making other settings, in this case, we will not see the effect of light. Relatively speaking, it is relatively simple to turn off the light source. Simply Add the following sentence to the sentence: Gl. gldisable (gl10.gl _ lighting ).
The OpenGL scenario contains eight light sources, gl_light0 to gl_light7, which can be different colors. Like opening a light, if you do not set a light after it is started, the light cannot be turned on.
OpenGL ES uses the gllightfv method to set the properties of light.
First, we will introduce how to set the directed light. The directed light is a parallel light source. We can think that the light of our illumination is parallel. Is the same as gllightfv settings. This function has four parameters. The first parameter is gl_light0 to gl_light7. The second parameter indicates that it is a directed light and should be set to gl_position. The third parameter is an array of Float classes, this array is composed of four parts. The first three vectors represent the direction of light. The last one should be set to 0 to indicate that this is a directed light. The last parameter indicates the offset of the first value in the array.
Position light is a light source scattered from a certain position. It is also set through gllightfv. The first parameter is gl_light0 to gl_light7. The second parameter indicates the positioning light. Like the positioning light, gl_position is also used. The third parameter is different. The first three positions of the array are the vectors between the given coordinate points and the origin point, the last parameter is set to 1. The last parameter indicates the offset of the first value in the array.
When setting ambient light, the first parameter is gl_light0 to gl_light7. The second parameter sets the ambient light to gl_ambient. The four elements of the third parameter array are R, G, B, and A. The last parameter is set to 0, the offset of the first color channel value in the array.
When setting the scattered light, the first parameter is gl_light0 to gl_light7. The second parameter sets the ambient light to gl_diffuse. The four elements of the third parameter array are R, G, B, and A. The last parameter is set to 0, the offset of the first color channel value in the array.
Reflected light refers to the light source from a specific direction, and tends to reflect from the surface to a specific direction. When setting the reflected light, the first parameter is gl_light0 to gl_light7. The second parameter sets the ambient light to gl_specular. The four elements of the third parameter array are R, G, B, and A. The last parameter is set to 0, the offset of the first color channel value in the array.
Refer to the detailed explanation and typical cases of Android 3D Game Development Technology. If there are any errors, I hope you can correct them more.
Next article describes the normal vectors and Materials