-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade Grade & Lesson ndk implements (#11)
* Upgrade Grade & Lesson two ndk implement * Lesson three ndk implement * Lesson four ndk implement * Lesson five ndk implements * Lesson six ndk implement * Lesson seven ndk implement * Lesson eight ndk implement
- Loading branch information
1 parent
8b19393
commit 641fcc2
Showing
64 changed files
with
6,966 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...roidOpenGLESLessonsCpp/app/src/main/assets/fragment/per_pixel_fragment_shader_no_tex.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
precision mediump float; // Set the default precision to medium. We don't need as high of a | ||
// precision in the fragment shader. | ||
uniform vec3 u_LightPos; // The position of the light in eye space. | ||
|
||
varying vec3 v_Position; // Interpolated position for this fragment. | ||
varying vec4 v_Color; // This is the color from the vertex shader interpolated across the | ||
// triangle per fragment. | ||
varying vec3 v_Normal; // Interpolated normal for this fragment. | ||
|
||
// The entry point for our fragment shader. | ||
void main() | ||
{ | ||
// Will be used for attenuation. | ||
float distance = length(u_LightPos - v_Position); | ||
|
||
// Get a lighting direction vector from the light to the vertex. | ||
vec3 lightVector = normalize(u_LightPos - v_Position); | ||
|
||
// Calculate the dot product of the light vector and vertex normal. If the normal and light vector are | ||
// pointing in the same direction then it will get max illumination. | ||
float diffuse; | ||
|
||
if (gl_FrontFacing) { | ||
diffuse = max(dot(v_Normal, lightVector), 0.0); | ||
} else { | ||
diffuse = max(dot(-v_Normal, lightVector), 0.0); | ||
} | ||
|
||
// Add attenuation. | ||
diffuse = diffuse * (1.0 / (1.0 + (0.10 * distance))); | ||
|
||
// Add ambient lighting | ||
diffuse = diffuse + 0.3; | ||
|
||
// Multiply the color by the diffuse illumination level to get final output color. | ||
gl_FragColor = (v_Color * diffuse); | ||
} | ||
|
27 changes: 27 additions & 0 deletions
27
.../AndroidOpenGLESLessonsCpp/app/src/main/assets/vertex/per_pixel_vertex_shader_no_tex.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
uniform mat4 u_MVPMatrix; // A constant representing the combined model/view/projection matrix. | ||
uniform mat4 u_MVMatrix; // A constant representing the combined model/view matrix. | ||
|
||
attribute vec4 a_Position; // Per-vertex position information we will pass in. | ||
attribute vec4 a_Color; // Per-vertex color information we will pass in. | ||
attribute vec3 a_Normal; // Per-vertex normal information we will pass in. | ||
|
||
varying vec3 v_Position; // This will be passed into the fragment shader. | ||
varying vec4 v_Color; // This will be passed into the fragment shader. | ||
varying vec3 v_Normal; // This will be passed into the fragment shader. | ||
|
||
// The entry point for our vertex shader. | ||
void main() | ||
{ | ||
// Transform the vertex into eye space. | ||
v_Position = vec3(u_MVMatrix * a_Position); | ||
|
||
// Pass through the color. | ||
v_Color = a_Color; | ||
|
||
// Transform the normal's orientation into eye space. | ||
v_Normal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); | ||
|
||
// gl_Position is a special variable used to store the final position. | ||
// Multiply the vertex by the matrix to get the final point in normalized screen coordinates. | ||
gl_Position = u_MVPMatrix * a_Position; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.