-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse and display chair with materials
- Loading branch information
Showing
15 changed files
with
425 additions
and
117 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
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,40 @@ | ||
#version 300 es | ||
|
||
precision highp float; | ||
|
||
in vec3 v_normal; | ||
in vec4 v_color; | ||
in vec3 v_surface_to_eye; | ||
|
||
uniform vec3 u_diffuse; | ||
uniform vec3 u_ambient; | ||
uniform vec3 u_emissive; | ||
uniform vec3 u_specular; | ||
uniform float u_shininess; | ||
uniform float u_opacity; | ||
uniform vec3 u_light_dir; | ||
uniform vec3 u_light_ambient; | ||
|
||
out vec4 out_color; | ||
|
||
void main() { | ||
// varying variables are interpolated | ||
vec3 normal = normalize(v_normal); | ||
vec3 surface_to_eye = normalize(v_surface_to_eye); | ||
vec3 half_vector = normalize(surface_to_eye + u_light_dir); | ||
|
||
float light_fake = dot(u_light_dir, normal) * .5 + .5; | ||
float light_specular = clamp(dot(normal, half_vector), 0.0, 1.0); | ||
|
||
vec3 effective_diffuse = u_diffuse * v_color.rgb; | ||
float effective_opacity = u_opacity * v_color.a; | ||
|
||
out_color = vec4( | ||
( | ||
u_emissive + | ||
u_ambient * u_light_ambient + | ||
effective_diffuse * light_fake + | ||
u_specular * pow(light_specular, u_shininess) | ||
), | ||
effective_opacity); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#version 300 es | ||
|
||
in vec3 a_position; | ||
in vec3 a_normal; | ||
in vec4 a_color; | ||
|
||
uniform mat4 u_view; | ||
uniform mat4 u_local; | ||
uniform vec3 u_eye_position; | ||
|
||
out vec3 v_normal; | ||
out vec4 v_color; | ||
out vec3 v_surface_to_eye; | ||
|
||
void main() { | ||
vec4 local_pos = u_local * vec4(a_position, 1.0); | ||
|
||
// project the position | ||
gl_Position = u_view * local_pos; | ||
|
||
/* | ||
orient the normals | ||
mat3() is the upper 3x3 - orientation, no translation | ||
*/ | ||
v_normal = mat3(u_local) * a_normal; | ||
|
||
v_surface_to_eye = u_eye_position - local_pos.xyz; | ||
|
||
v_color = a_color; | ||
} |
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.