mittsu 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-workflow.yml +3 -38
- data/Gemfile +0 -4
- data/README.md +16 -130
- data/bin/console +0 -4
- data/lib/mittsu/cameras/cube_camera.rb +1 -1
- data/lib/mittsu/core/uniform.rb +23 -0
- data/lib/mittsu/core.rb +1 -0
- data/lib/mittsu/loaders/stl_loader.rb +186 -0
- data/lib/mittsu/loaders.rb +1 -0
- data/lib/mittsu/textures/render_target.rb +93 -0
- data/lib/mittsu/textures/render_target_cube.rb +8 -0
- data/lib/mittsu/textures/texture.rb +1 -1
- data/lib/mittsu/textures.rb +2 -0
- data/lib/mittsu/version.rb +1 -1
- data/lib/mittsu.rb +0 -1
- data/mittsu.gemspec +8 -12
- metadata +28 -199
- data/install-glfw.ps1 +0 -13
- data/lib/mittsu/renderers/generic_lib.rb +0 -125
- data/lib/mittsu/renderers/glfw_lib.rb +0 -64
- data/lib/mittsu/renderers/glfw_window.rb +0 -233
- data/lib/mittsu/renderers/opengl/core/buffer_geometry.rb +0 -11
- data/lib/mittsu/renderers/opengl/core/geometry.rb +0 -346
- data/lib/mittsu/renderers/opengl/core/object_3d.rb +0 -134
- data/lib/mittsu/renderers/opengl/lights/ambient_light.rb +0 -26
- data/lib/mittsu/renderers/opengl/lights/directional_light.rb +0 -35
- data/lib/mittsu/renderers/opengl/lights/hemisphere_light.rb +0 -39
- data/lib/mittsu/renderers/opengl/lights/light.rb +0 -55
- data/lib/mittsu/renderers/opengl/lights/point_light.rb +0 -36
- data/lib/mittsu/renderers/opengl/lights/spot_light.rb +0 -47
- data/lib/mittsu/renderers/opengl/materials/line_basic_material.rb +0 -16
- data/lib/mittsu/renderers/opengl/materials/material.rb +0 -274
- data/lib/mittsu/renderers/opengl/materials/mesh_basic_material.rb +0 -21
- data/lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb +0 -33
- data/lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb +0 -44
- data/lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb +0 -57
- data/lib/mittsu/renderers/opengl/materials/point_cloud_material.rb +0 -27
- data/lib/mittsu/renderers/opengl/materials/shader_material.rb +0 -11
- data/lib/mittsu/renderers/opengl/objects/group.rb +0 -9
- data/lib/mittsu/renderers/opengl/objects/line.rb +0 -45
- data/lib/mittsu/renderers/opengl/objects/mesh.rb +0 -70
- data/lib/mittsu/renderers/opengl/objects/point_cloud.rb +0 -39
- data/lib/mittsu/renderers/opengl/objects/sprite.rb +0 -12
- data/lib/mittsu/renderers/opengl/opengl_buffer.rb +0 -13
- data/lib/mittsu/renderers/opengl/opengl_debug.rb +0 -81
- data/lib/mittsu/renderers/opengl/opengl_default_target.rb +0 -50
- data/lib/mittsu/renderers/opengl/opengl_geometry_group.rb +0 -758
- data/lib/mittsu/renderers/opengl/opengl_geometry_like.rb +0 -132
- data/lib/mittsu/renderers/opengl/opengl_helper.rb +0 -161
- data/lib/mittsu/renderers/opengl/opengl_implementations.rb +0 -37
- data/lib/mittsu/renderers/opengl/opengl_lib.rb +0 -19
- data/lib/mittsu/renderers/opengl/opengl_light_renderer.rb +0 -43
- data/lib/mittsu/renderers/opengl/opengl_mittsu_params.rb +0 -53
- data/lib/mittsu/renderers/opengl/opengl_program.rb +0 -250
- data/lib/mittsu/renderers/opengl/opengl_shader.rb +0 -58
- data/lib/mittsu/renderers/opengl/opengl_state.rb +0 -205
- data/lib/mittsu/renderers/opengl/plugins/shadow_map_plugin.rb +0 -417
- data/lib/mittsu/renderers/opengl/plugins/sprite_fragment.glsl +0 -38
- data/lib/mittsu/renderers/opengl/plugins/sprite_plugin.rb +0 -250
- data/lib/mittsu/renderers/opengl/plugins/sprite_vertex.glsl +0 -31
- data/lib/mittsu/renderers/opengl/scenes/scene.rb +0 -9
- data/lib/mittsu/renderers/opengl/textures/compressed_texture.rb +0 -20
- data/lib/mittsu/renderers/opengl/textures/cube_texture.rb +0 -77
- data/lib/mittsu/renderers/opengl/textures/data_texture.rb +0 -21
- data/lib/mittsu/renderers/opengl/textures/texture.rb +0 -107
- data/lib/mittsu/renderers/opengl_render_target.rb +0 -201
- data/lib/mittsu/renderers/opengl_renderer.rb +0 -1028
- data/lib/mittsu/renderers/shaders/rbsl_loader.rb +0 -166
- data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/alphamap_pars_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/alphatest_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl +0 -40
- data/lib/mittsu/renderers/shaders/shader_chunk/color_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/color_pars_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/color_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/common.glsl +0 -60
- data/lib/mittsu/renderers/shaders/shader_chunk/default_vertex.glsl +0 -15
- data/lib/mittsu/renderers/shaders/shader_chunk/defaultnormal_vertex.glsl +0 -21
- data/lib/mittsu/renderers/shaders/shader_chunk/envmap_fragment.glsl +0 -62
- data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_fragment.glsl +0 -21
- data/lib/mittsu/renderers/shaders/shader_chunk/envmap_pars_vertex.glsl +0 -7
- data/lib/mittsu/renderers/shaders/shader_chunk/envmap_vertex.glsl +0 -17
- data/lib/mittsu/renderers/shaders/shader_chunk/fog_fragment.glsl +0 -26
- data/lib/mittsu/renderers/shaders/shader_chunk/fog_pars_fragment.glsl +0 -15
- data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_fragment.glsl +0 -6
- data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_pars_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/lightmap_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_pars_vertex.glsl +0 -43
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_lambert_vertex.glsl +0 -196
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_fragment.glsl +0 -243
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_fragment.glsl +0 -58
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_pars_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/lights_phong_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/linear_to_gamma_fragment.glsl +0 -2
- data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_fragment.glsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_pars_vertex.glsl +0 -11
- data/lib/mittsu/renderers/shaders/shader_chunk/logdepthbuf_vertex.glsl +0 -15
- data/lib/mittsu/renderers/shaders/shader_chunk/map_fragment.glsl +0 -9
- data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_fragment.glsl +0 -11
- data/lib/mittsu/renderers/shaders/shader_chunk/map_pars_vertex.glsl +0 -6
- data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/map_particle_pars_fragment.glsl +0 -6
- data/lib/mittsu/renderers/shaders/shader_chunk/map_vertex.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/morphnormal_vertex.glsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_pars_vertex.glsl +0 -13
- data/lib/mittsu/renderers/shaders/shader_chunk/morphtarget_vertex.glsl +0 -20
- data/lib/mittsu/renderers/shaders/shader_chunk/normalmap_pars_fragment.glsl +0 -27
- data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_fragment.glsl +0 -216
- data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_fragment.glsl +0 -19
- data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_pars_vertex.glsl +0 -6
- data/lib/mittsu/renderers/shaders/shader_chunk/shadowmap_vertex.glsl +0 -9
- data/lib/mittsu/renderers/shaders/shader_chunk/skinbase_vertex.glsl +0 -8
- data/lib/mittsu/renderers/shaders/shader_chunk/skinning_pars_vertex.glsl +0 -47
- data/lib/mittsu/renderers/shaders/shader_chunk/skinning_vertex.glsl +0 -20
- data/lib/mittsu/renderers/shaders/shader_chunk/skinnormal_vertex.glsl +0 -20
- data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_fragment.glsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_chunk/specularmap_pars_fragment.glsl +0 -5
- data/lib/mittsu/renderers/shaders/shader_chunk/worldpos_vertex.glsl +0 -17
- data/lib/mittsu/renderers/shaders/shader_chunk.rb +0 -9
- data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_fragment.rbsl +0 -37
- data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_uniforms.rbslu +0 -3
- data/lib/mittsu/renderers/shaders/shader_lib/basic/basic_vertex.rbsl +0 -33
- data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_fragment.rbsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_uniforms.rbslu +0 -2
- data/lib/mittsu/renderers/shaders/shader_lib/cube/cube_vertex.rbsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_fragment.rbsl +0 -26
- data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_uniforms.rbslu +0 -0
- data/lib/mittsu/renderers/shaders/shader_lib/depth_rgba/depth_rgba_vertex.rbsl +0 -12
- data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_fragment.rbsl +0 -56
- data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_uniforms.rbslu +0 -7
- data/lib/mittsu/renderers/shaders/shader_lib/lambert/lambert_vertex.rbsl +0 -37
- data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_fragment.rbsl +0 -27
- data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_uniforms.rbslu +0 -2
- data/lib/mittsu/renderers/shaders/shader_lib/particle_basic/particle_basic_vertex.rbsl +0 -25
- data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_fragment.rbsl +0 -45
- data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_uniforms.rbslu +0 -11
- data/lib/mittsu/renderers/shaders/shader_lib/phong/phong_vertex.rbsl +0 -43
- data/lib/mittsu/renderers/shaders/shader_lib.rb +0 -43
- data/lib/mittsu/renderers/shaders/shader_templates/fragment.glsl.erb +0 -105
- data/lib/mittsu/renderers/shaders/shader_templates/vertex.glsl.erb +0 -143
- data/lib/mittsu/renderers/shaders/uniforms_lib.rb +0 -106
- data/lib/mittsu/renderers/shaders/uniforms_utils.rb +0 -31
- data/lib/mittsu/renderers.rb +0 -1
@@ -1,196 +0,0 @@
|
|
1
|
-
vLightFront = vec3( 0.0 );
|
2
|
-
|
3
|
-
#ifdef DOUBLE_SIDED
|
4
|
-
|
5
|
-
vLightBack = vec3( 0.0 );
|
6
|
-
|
7
|
-
#endif
|
8
|
-
|
9
|
-
transformedNormal = normalize( transformedNormal );
|
10
|
-
|
11
|
-
#if MAX_DIR_LIGHTS > 0
|
12
|
-
|
13
|
-
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
|
14
|
-
|
15
|
-
vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );
|
16
|
-
|
17
|
-
float dotProduct = dot( transformedNormal, dirVector );
|
18
|
-
vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
19
|
-
|
20
|
-
#ifdef DOUBLE_SIDED
|
21
|
-
|
22
|
-
vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
|
23
|
-
|
24
|
-
#ifdef WRAP_AROUND
|
25
|
-
|
26
|
-
vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
|
27
|
-
|
28
|
-
#endif
|
29
|
-
|
30
|
-
#endif
|
31
|
-
|
32
|
-
#ifdef WRAP_AROUND
|
33
|
-
|
34
|
-
vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
|
35
|
-
directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );
|
36
|
-
|
37
|
-
#ifdef DOUBLE_SIDED
|
38
|
-
|
39
|
-
directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );
|
40
|
-
|
41
|
-
#endif
|
42
|
-
|
43
|
-
#endif
|
44
|
-
|
45
|
-
vLightFront += directionalLightColor[ i ] * directionalLightWeighting;
|
46
|
-
|
47
|
-
#ifdef DOUBLE_SIDED
|
48
|
-
|
49
|
-
vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;
|
50
|
-
|
51
|
-
#endif
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
#endif
|
56
|
-
|
57
|
-
#if MAX_POINT_LIGHTS > 0
|
58
|
-
|
59
|
-
for( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
|
60
|
-
|
61
|
-
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
|
62
|
-
vec3 lVector = lPosition.xyz - mvPosition.xyz;
|
63
|
-
|
64
|
-
float attenuation = calcLightAttenuation( length( lVector ), pointLightDistance[ i ], pointLightDecay[ i ] );
|
65
|
-
|
66
|
-
lVector = normalize( lVector );
|
67
|
-
float dotProduct = dot( transformedNormal, lVector );
|
68
|
-
|
69
|
-
vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
70
|
-
|
71
|
-
#ifdef DOUBLE_SIDED
|
72
|
-
|
73
|
-
vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
|
74
|
-
|
75
|
-
#ifdef WRAP_AROUND
|
76
|
-
|
77
|
-
vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
|
78
|
-
|
79
|
-
#endif
|
80
|
-
|
81
|
-
#endif
|
82
|
-
|
83
|
-
#ifdef WRAP_AROUND
|
84
|
-
|
85
|
-
vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
|
86
|
-
pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );
|
87
|
-
|
88
|
-
#ifdef DOUBLE_SIDED
|
89
|
-
|
90
|
-
pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );
|
91
|
-
|
92
|
-
#endif
|
93
|
-
|
94
|
-
#endif
|
95
|
-
|
96
|
-
vLightFront += pointLightColor[ i ] * pointLightWeighting * attenuation;
|
97
|
-
|
98
|
-
#ifdef DOUBLE_SIDED
|
99
|
-
|
100
|
-
vLightBack += pointLightColor[ i ] * pointLightWeightingBack * attenuation;
|
101
|
-
|
102
|
-
#endif
|
103
|
-
|
104
|
-
}
|
105
|
-
|
106
|
-
#endif
|
107
|
-
|
108
|
-
#if MAX_SPOT_LIGHTS > 0
|
109
|
-
|
110
|
-
for( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
|
111
|
-
|
112
|
-
vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );
|
113
|
-
vec3 lVector = lPosition.xyz - mvPosition.xyz;
|
114
|
-
|
115
|
-
float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );
|
116
|
-
|
117
|
-
if ( spotEffect > spotLightAngleCos[ i ] ) {
|
118
|
-
|
119
|
-
spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );
|
120
|
-
|
121
|
-
float attenuation = calcLightAttenuation( length( lVector ), spotLightDistance[ i ], spotLightDecay[ i ] );
|
122
|
-
|
123
|
-
lVector = normalize( lVector );
|
124
|
-
|
125
|
-
float dotProduct = dot( transformedNormal, lVector );
|
126
|
-
vec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );
|
127
|
-
|
128
|
-
#ifdef DOUBLE_SIDED
|
129
|
-
|
130
|
-
vec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );
|
131
|
-
|
132
|
-
#ifdef WRAP_AROUND
|
133
|
-
|
134
|
-
vec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );
|
135
|
-
|
136
|
-
#endif
|
137
|
-
|
138
|
-
#endif
|
139
|
-
|
140
|
-
#ifdef WRAP_AROUND
|
141
|
-
|
142
|
-
vec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );
|
143
|
-
spotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );
|
144
|
-
|
145
|
-
#ifdef DOUBLE_SIDED
|
146
|
-
|
147
|
-
spotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );
|
148
|
-
|
149
|
-
#endif
|
150
|
-
|
151
|
-
#endif
|
152
|
-
|
153
|
-
vLightFront += spotLightColor[ i ] * spotLightWeighting * attenuation * spotEffect;
|
154
|
-
|
155
|
-
#ifdef DOUBLE_SIDED
|
156
|
-
|
157
|
-
vLightBack += spotLightColor[ i ] * spotLightWeightingBack * attenuation * spotEffect;
|
158
|
-
|
159
|
-
#endif
|
160
|
-
|
161
|
-
}
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
#endif
|
166
|
-
|
167
|
-
#if MAX_HEMI_LIGHTS > 0
|
168
|
-
|
169
|
-
for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
|
170
|
-
|
171
|
-
vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );
|
172
|
-
|
173
|
-
float dotProduct = dot( transformedNormal, lVector );
|
174
|
-
|
175
|
-
float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
|
176
|
-
float hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;
|
177
|
-
|
178
|
-
vLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
|
179
|
-
|
180
|
-
#ifdef DOUBLE_SIDED
|
181
|
-
|
182
|
-
vLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );
|
183
|
-
|
184
|
-
#endif
|
185
|
-
|
186
|
-
}
|
187
|
-
|
188
|
-
#endif
|
189
|
-
|
190
|
-
vLightFront += ambientLightColor;
|
191
|
-
|
192
|
-
#ifdef DOUBLE_SIDED
|
193
|
-
|
194
|
-
vLightBack += ambientLightColor;
|
195
|
-
|
196
|
-
#endif
|
@@ -1,243 +0,0 @@
|
|
1
|
-
#ifndef FLAT_SHADED
|
2
|
-
|
3
|
-
vec3 normal = normalize( vNormal );
|
4
|
-
|
5
|
-
#ifdef DOUBLE_SIDED
|
6
|
-
|
7
|
-
normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );
|
8
|
-
|
9
|
-
#endif
|
10
|
-
|
11
|
-
#else
|
12
|
-
|
13
|
-
vec3 fdx = dFdx( vViewPosition );
|
14
|
-
vec3 fdy = dFdy( vViewPosition );
|
15
|
-
vec3 normal = normalize( cross( fdx, fdy ) );
|
16
|
-
|
17
|
-
#endif
|
18
|
-
|
19
|
-
vec3 viewPosition = normalize( vViewPosition );
|
20
|
-
|
21
|
-
#ifdef USE_NORMALMAP
|
22
|
-
|
23
|
-
normal = perturbNormal2Arb( -vViewPosition, normal );
|
24
|
-
|
25
|
-
#elif defined( USE_BUMPMAP )
|
26
|
-
|
27
|
-
normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );
|
28
|
-
|
29
|
-
#endif
|
30
|
-
|
31
|
-
vec3 totalDiffuseLight = vec3( 0.0 );
|
32
|
-
vec3 totalSpecularLight = vec3( 0.0 );
|
33
|
-
|
34
|
-
#if MAX_POINT_LIGHTS > 0
|
35
|
-
|
36
|
-
for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {
|
37
|
-
|
38
|
-
vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );
|
39
|
-
vec3 lVector = lPosition.xyz + vViewPosition.xyz;
|
40
|
-
|
41
|
-
float attenuation = calcLightAttenuation( length( lVector ), pointLightDistance[ i ], pointLightDecay[ i ] );
|
42
|
-
|
43
|
-
lVector = normalize( lVector );
|
44
|
-
|
45
|
-
// diffuse
|
46
|
-
|
47
|
-
float dotProduct = dot( normal, lVector );
|
48
|
-
|
49
|
-
#ifdef WRAP_AROUND
|
50
|
-
|
51
|
-
float pointDiffuseWeightFull = max( dotProduct, 0.0 );
|
52
|
-
float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
|
53
|
-
|
54
|
-
vec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );
|
55
|
-
|
56
|
-
#else
|
57
|
-
|
58
|
-
float pointDiffuseWeight = max( dotProduct, 0.0 );
|
59
|
-
|
60
|
-
#endif
|
61
|
-
|
62
|
-
totalDiffuseLight += pointLightColor[ i ] * pointDiffuseWeight * attenuation;
|
63
|
-
|
64
|
-
// specular
|
65
|
-
|
66
|
-
vec3 pointHalfVector = normalize( lVector + viewPosition );
|
67
|
-
float pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );
|
68
|
-
float pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );
|
69
|
-
|
70
|
-
float specularNormalization = ( shininess + 2.0 ) / 8.0;
|
71
|
-
|
72
|
-
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );
|
73
|
-
totalSpecularLight += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * attenuation * specularNormalization;
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
#endif
|
78
|
-
|
79
|
-
#if MAX_SPOT_LIGHTS > 0
|
80
|
-
|
81
|
-
for ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {
|
82
|
-
|
83
|
-
vec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );
|
84
|
-
vec3 lVector = lPosition.xyz + vViewPosition.xyz;
|
85
|
-
|
86
|
-
float attenuation = calcLightAttenuation( length( lVector ), spotLightDistance[ i ], spotLightDecay[ i ] );
|
87
|
-
|
88
|
-
lVector = normalize( lVector );
|
89
|
-
|
90
|
-
float spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );
|
91
|
-
|
92
|
-
if ( spotEffect > spotLightAngleCos[ i ] ) {
|
93
|
-
|
94
|
-
spotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );
|
95
|
-
|
96
|
-
// diffuse
|
97
|
-
|
98
|
-
float dotProduct = dot( normal, lVector );
|
99
|
-
|
100
|
-
#ifdef WRAP_AROUND
|
101
|
-
|
102
|
-
float spotDiffuseWeightFull = max( dotProduct, 0.0 );
|
103
|
-
float spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
|
104
|
-
|
105
|
-
vec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );
|
106
|
-
|
107
|
-
#else
|
108
|
-
|
109
|
-
float spotDiffuseWeight = max( dotProduct, 0.0 );
|
110
|
-
|
111
|
-
#endif
|
112
|
-
|
113
|
-
totalDiffuseLight += spotLightColor[ i ] * spotDiffuseWeight * attenuation * spotEffect;
|
114
|
-
|
115
|
-
// specular
|
116
|
-
|
117
|
-
vec3 spotHalfVector = normalize( lVector + viewPosition );
|
118
|
-
float spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );
|
119
|
-
float spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );
|
120
|
-
|
121
|
-
float specularNormalization = ( shininess + 2.0 ) / 8.0;
|
122
|
-
|
123
|
-
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );
|
124
|
-
totalSpecularLight += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * attenuation * specularNormalization * spotEffect;
|
125
|
-
|
126
|
-
}
|
127
|
-
|
128
|
-
}
|
129
|
-
|
130
|
-
#endif
|
131
|
-
|
132
|
-
#if MAX_DIR_LIGHTS > 0
|
133
|
-
|
134
|
-
for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
|
135
|
-
|
136
|
-
vec3 dirVector = transformDirection( directionalLightDirection[ i ], viewMatrix );
|
137
|
-
|
138
|
-
// diffuse
|
139
|
-
|
140
|
-
float dotProduct = dot( normal, dirVector );
|
141
|
-
|
142
|
-
#ifdef WRAP_AROUND
|
143
|
-
|
144
|
-
float dirDiffuseWeightFull = max( dotProduct, 0.0 );
|
145
|
-
float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );
|
146
|
-
|
147
|
-
vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );
|
148
|
-
|
149
|
-
#else
|
150
|
-
|
151
|
-
float dirDiffuseWeight = max( dotProduct, 0.0 );
|
152
|
-
|
153
|
-
#endif
|
154
|
-
|
155
|
-
totalDiffuseLight += directionalLightColor[ i ] * dirDiffuseWeight;
|
156
|
-
|
157
|
-
// specular
|
158
|
-
|
159
|
-
vec3 dirHalfVector = normalize( dirVector + viewPosition );
|
160
|
-
float dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );
|
161
|
-
float dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );
|
162
|
-
|
163
|
-
/*
|
164
|
-
// fresnel term from skin shader
|
165
|
-
const float F0 = 0.128;
|
166
|
-
|
167
|
-
float base = 1.0 - dot( viewPosition, dirHalfVector );
|
168
|
-
float exponential = pow( base, 5.0 );
|
169
|
-
|
170
|
-
float fresnel = exponential + F0 * ( 1.0 - exponential );
|
171
|
-
*/
|
172
|
-
|
173
|
-
/*
|
174
|
-
// fresnel term from fresnel shader
|
175
|
-
const float mFresnelBias = 0.08;
|
176
|
-
const float mFresnelScale = 0.3;
|
177
|
-
const float mFresnelPower = 5.0;
|
178
|
-
|
179
|
-
float fresnel = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( -viewPosition ), normal ), mFresnelPower );
|
180
|
-
*/
|
181
|
-
|
182
|
-
float specularNormalization = ( shininess + 2.0 ) / 8.0;
|
183
|
-
|
184
|
-
// dirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization * fresnel;
|
185
|
-
|
186
|
-
vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );
|
187
|
-
totalSpecularLight += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;
|
188
|
-
|
189
|
-
|
190
|
-
}
|
191
|
-
|
192
|
-
#endif
|
193
|
-
|
194
|
-
#if MAX_HEMI_LIGHTS > 0
|
195
|
-
|
196
|
-
for( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {
|
197
|
-
|
198
|
-
vec3 lVector = transformDirection( hemisphereLightDirection[ i ], viewMatrix );
|
199
|
-
|
200
|
-
// diffuse
|
201
|
-
|
202
|
-
float dotProduct = dot( normal, lVector );
|
203
|
-
float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
|
204
|
-
|
205
|
-
vec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );
|
206
|
-
|
207
|
-
totalDiffuseLight += hemiColor;
|
208
|
-
|
209
|
-
// specular (sky light)
|
210
|
-
|
211
|
-
vec3 hemiHalfVectorSky = normalize( lVector + viewPosition );
|
212
|
-
float hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;
|
213
|
-
float hemiSpecularWeightSky = specularStrength * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );
|
214
|
-
|
215
|
-
// specular (ground light)
|
216
|
-
|
217
|
-
vec3 lVectorGround = -lVector;
|
218
|
-
|
219
|
-
vec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );
|
220
|
-
float hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;
|
221
|
-
float hemiSpecularWeightGround = specularStrength * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );
|
222
|
-
|
223
|
-
float dotProductGround = dot( normal, lVectorGround );
|
224
|
-
|
225
|
-
float specularNormalization = ( shininess + 2.0 ) / 8.0;
|
226
|
-
|
227
|
-
vec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );
|
228
|
-
vec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );
|
229
|
-
totalSpecularLight += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
#endif
|
234
|
-
|
235
|
-
#ifdef METAL
|
236
|
-
|
237
|
-
outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor ) * specular + totalSpecularLight + emissive;
|
238
|
-
|
239
|
-
#else
|
240
|
-
|
241
|
-
outgoingLight += diffuseColor.rgb * ( totalDiffuseLight + ambientLightColor ) + totalSpecularLight + emissive;
|
242
|
-
|
243
|
-
#endif
|
@@ -1,58 +0,0 @@
|
|
1
|
-
uniform vec3 ambientLightColor;
|
2
|
-
|
3
|
-
#if MAX_DIR_LIGHTS > 0
|
4
|
-
|
5
|
-
uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];
|
6
|
-
uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];
|
7
|
-
|
8
|
-
#endif
|
9
|
-
|
10
|
-
#if MAX_HEMI_LIGHTS > 0
|
11
|
-
|
12
|
-
uniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];
|
13
|
-
uniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];
|
14
|
-
uniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];
|
15
|
-
|
16
|
-
#endif
|
17
|
-
|
18
|
-
#if MAX_POINT_LIGHTS > 0
|
19
|
-
|
20
|
-
uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];
|
21
|
-
|
22
|
-
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
|
23
|
-
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
|
24
|
-
uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
|
25
|
-
|
26
|
-
#endif
|
27
|
-
|
28
|
-
#if MAX_SPOT_LIGHTS > 0
|
29
|
-
|
30
|
-
uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
|
31
|
-
uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
|
32
|
-
uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
|
33
|
-
uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
|
34
|
-
uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
|
35
|
-
uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
|
36
|
-
uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
|
37
|
-
|
38
|
-
#endif
|
39
|
-
|
40
|
-
#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )
|
41
|
-
|
42
|
-
in vec3 vWorldPosition;
|
43
|
-
|
44
|
-
#endif
|
45
|
-
|
46
|
-
#ifdef WRAP_AROUND
|
47
|
-
|
48
|
-
uniform vec3 wrapRGB;
|
49
|
-
|
50
|
-
#endif
|
51
|
-
|
52
|
-
in vec3 vViewPosition;
|
53
|
-
|
54
|
-
#ifndef FLAT_SHADED
|
55
|
-
|
56
|
-
in vec3 vNormal;
|
57
|
-
|
58
|
-
#endif
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#ifdef USE_LOGDEPTHBUF
|
2
|
-
|
3
|
-
gl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;
|
4
|
-
|
5
|
-
#ifdef USE_LOGDEPTHBUF_EXT
|
6
|
-
|
7
|
-
vFragDepth = 1.0 + gl_Position.w;
|
8
|
-
|
9
|
-
#else
|
10
|
-
|
11
|
-
gl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;
|
12
|
-
|
13
|
-
#endif
|
14
|
-
|
15
|
-
#endif
|
@@ -1,12 +0,0 @@
|
|
1
|
-
#ifdef USE_MORPHNORMALS
|
2
|
-
|
3
|
-
vec3 morphedNormal = vec3( 0.0 );
|
4
|
-
|
5
|
-
morphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];
|
6
|
-
morphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];
|
7
|
-
morphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];
|
8
|
-
morphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];
|
9
|
-
|
10
|
-
morphedNormal += normal;
|
11
|
-
|
12
|
-
#endif
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#ifdef USE_MORPHTARGETS
|
2
|
-
|
3
|
-
vec3 morphed = vec3( 0.0 );
|
4
|
-
morphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];
|
5
|
-
morphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];
|
6
|
-
morphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];
|
7
|
-
morphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];
|
8
|
-
|
9
|
-
#ifndef USE_MORPHNORMALS
|
10
|
-
|
11
|
-
morphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];
|
12
|
-
morphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];
|
13
|
-
morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];
|
14
|
-
morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];
|
15
|
-
|
16
|
-
#endif
|
17
|
-
|
18
|
-
morphed += position;
|
19
|
-
|
20
|
-
#endif
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#ifdef USE_NORMALMAP
|
2
|
-
|
3
|
-
uniform sampler2D normalMap;
|
4
|
-
uniform vec2 normalScale;
|
5
|
-
|
6
|
-
// Per-Pixel Tangent Space Normal Mapping
|
7
|
-
// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html
|
8
|
-
|
9
|
-
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {
|
10
|
-
|
11
|
-
vec3 q0 = dFdx( eye_pos.xyz );
|
12
|
-
vec3 q1 = dFdy( eye_pos.xyz );
|
13
|
-
vec2 st0 = dFdx( vUv.st );
|
14
|
-
vec2 st1 = dFdy( vUv.st );
|
15
|
-
|
16
|
-
vec3 S = normalize( q0 * st1.t - q1 * st0.t );
|
17
|
-
vec3 T = normalize( -q0 * st1.s + q1 * st0.s );
|
18
|
-
vec3 N = normalize( surf_norm );
|
19
|
-
|
20
|
-
vec3 mapN = texture( normalMap, vUv ).xyz * 2.0 - 1.0;
|
21
|
-
mapN.xy = normalScale * mapN.xy;
|
22
|
-
mat3 tsn = mat3( S, T, N );
|
23
|
-
return normalize( tsn * mapN );
|
24
|
-
|
25
|
-
}
|
26
|
-
|
27
|
-
#endif
|