• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[VS]
2#include "g_attributes.glsl:VS"
3#include "u_uniforms.glsl"
4#include "skinning.glsl"
5#include "common.glsl:VS"
6
7// varying vec3 v_viewDir;
8varying vec3 v_reflect;
9
10void main() {
11	g_position = applySkinning(g_position);
12	g_normal = normalize(u_normalMatrix * applySkinning(g_normal));
13
14	g_position = u_worldTrans * g_position;
15	gl_Position = u_projViewTrans * g_position;
16
17//	mat3 worldToTangent;
18//	worldToTangent[0] = normalize(u_normalMatrix * g_tangent);
19//	worldToTangent[1] = normalize(u_normalMatrix * cross(g_tangent, g_normal));
20//	worldToTangent[2] = normalize(u_normalMatrix * g_normal);
21
22	vec3 viewDir = normalize(u_cameraPosition.xyz - g_position.xyz);
23
24	v_reflect = reflect(-viewDir, g_normal);
25
26	pushTexCoord0();
27}
28
29
30[FS]
31#ifdef GL_ES
32#define LOWP lowp
33#define MED mediump
34#define HIGH highp
35precision mediump float;
36#else
37#define MED
38#define LOWP
39#define HIGH
40#endif
41
42#include "g_attributes.glsl:FS"
43#include "u_uniforms.glsl"
44#include "common.glsl:FS"
45
46varying vec3 v_reflect;
47
48#ifdef environmentCubemapFlag
49uniform samplerCube u_environmentCubemap;
50#endif
51
52void main() {
53	pullTexCoord0();
54
55#ifdef normalTextureFlag
56	vec4 N = vec4(normalize(texture2D(u_normalTexture, g_texCoord0).xyz * 2.0 - 1.0), 1.0);
57#else
58	vec4 N = vec4(0.0, 0.0, 1.0, 1.0);
59#endif
60
61	vec3 reflectDir = normalize(v_reflect) + (vec3(0.0, 0.0, 1.0) - N.xyz);
62
63#ifdef environmentCubemapFlag
64	gl_FragColor = vec4(textureCube(u_environmentCubemap, reflectDir).rgb, 1.0);
65#else
66	gl_FragColor = vec4(reflectDir, 1.0);
67#endif
68}
69