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,166 +0,0 @@
|
|
1
|
-
module Mittsu
|
2
|
-
module RBSLLoader
|
3
|
-
UNIFORM_RGX = /uniform\s+(\S+)\s+(\w+)(|\s+\=\s+(.+));/
|
4
|
-
COLOR_RGX = /color\(([^\)]*)\)/
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def load_shader(shader, chunks)
|
8
|
-
shader.lines.flat_map(&:chomp).map{ |line|
|
9
|
-
if line =~ /(\s*)#include\s+(\w+)/
|
10
|
-
indentation = $1
|
11
|
-
chunk_name = $2.to_sym
|
12
|
-
|
13
|
-
chunks[chunk_name].lines.map(&:chomp).map{ |l|
|
14
|
-
"#{indentation}#{l}"
|
15
|
-
}
|
16
|
-
else
|
17
|
-
line
|
18
|
-
end
|
19
|
-
}.join("\n") + "\n"
|
20
|
-
end
|
21
|
-
|
22
|
-
def extract_array_contents(str)
|
23
|
-
/\[([^\]]+)\]/.match(str)[1]
|
24
|
-
end
|
25
|
-
|
26
|
-
def parse_int(str)
|
27
|
-
str.to_i
|
28
|
-
end
|
29
|
-
|
30
|
-
(2..4).each do |n|
|
31
|
-
define_method("parse_ivec#{n}") do |str|
|
32
|
-
str =~ /ivec#{n}\(([^\)]+)\)/
|
33
|
-
$1.split(',').map(&:strip).map(&:to_i).take(n)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def parse_float(str)
|
38
|
-
str.to_f
|
39
|
-
end
|
40
|
-
|
41
|
-
def parse_single_color(values)
|
42
|
-
if values.length == 1
|
43
|
-
values = values.map(&:to_i)
|
44
|
-
else
|
45
|
-
values = values.map(&:to_f)
|
46
|
-
end
|
47
|
-
Color.new(*values)
|
48
|
-
end
|
49
|
-
|
50
|
-
def parse_color(str)
|
51
|
-
str =~ COLOR_RGX
|
52
|
-
values = $1.split(',').map(&:strip)
|
53
|
-
parse_single_color(values)
|
54
|
-
end
|
55
|
-
|
56
|
-
def parse_color_array(str)
|
57
|
-
str = extract_array_contents(str)
|
58
|
-
str.scan(COLOR_RGX).map{ |m|
|
59
|
-
values = m.first.split(',').map(&:strip)
|
60
|
-
parse_single_color(values)
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
def parse_int_array(str)
|
65
|
-
str = extract_array_contents(str)
|
66
|
-
str.split(',').map(&:strip).map(&:to_i)
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse_float_array(str)
|
70
|
-
str = extract_array_contents(str)
|
71
|
-
str.split(',').map(&:strip).map(&:to_f)
|
72
|
-
end
|
73
|
-
|
74
|
-
[Vector2, Vector3, Vector4].each do |vectorClass|
|
75
|
-
define_method("parse_vec#{vectorClass::DIMENSIONS}") do |str|
|
76
|
-
str =~ /vec#{vectorClass::DIMENSIONS}\(([^\)]+)\)/
|
77
|
-
values = $1.split(',').map(&:strip).map(&:to_f).take(vectorClass::DIMENSIONS)
|
78
|
-
vectorClass.new(*values)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
(2..4).each do |n|
|
83
|
-
define_method("parse_ivec#{n}_array") do |str|
|
84
|
-
str = extract_array_contents(str)
|
85
|
-
str.scan(/ivec#{n}\(([^\)]+)\)/).map{ |m| m.first.split(',').map(&:strip).map(&:to_i).take(n) }
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
[Vector2, Vector3, Vector4].each do |vectorClass|
|
90
|
-
define_method("parse_vec#{vectorClass::DIMENSIONS}_array") do |str|
|
91
|
-
str = extract_array_contents(str)
|
92
|
-
str.scan(/vec#{vectorClass::DIMENSIONS}\(([^\)]+)\)/).map{ |m|
|
93
|
-
values = m.first.split(',').map(&:strip).map(&:to_f).take(vectorClass::DIMENSIONS)
|
94
|
-
vectorClass.new(*values)
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
[Matrix3, Matrix4].each do |matrixClass|
|
100
|
-
define_method("parse_mat#{matrixClass::DIMENSIONS}") do |str|
|
101
|
-
str =~ /mat#{matrixClass::DIMENSIONS}\(([^\)]+)\)/
|
102
|
-
values = $1.split(',').map(&:strip).map(&:to_f).take(matrixClass::DIMENSIONS * matrixClass::DIMENSIONS)
|
103
|
-
matrixClass.new().tap { |mat| mat.set(*values) }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
[Matrix3, Matrix4].each do |matrixClass|
|
108
|
-
define_method("parse_mat#{matrixClass::DIMENSIONS}_array") do |str|
|
109
|
-
str = extract_array_contents(str)
|
110
|
-
str.scan(/mat#{matrixClass::DIMENSIONS}\(([^\)]+)\)/).map{ |m|
|
111
|
-
values = m.first.split(',').map(&:strip).map(&:to_f).take(matrixClass::DIMENSIONS * matrixClass::DIMENSIONS)
|
112
|
-
matrixClass.new().tap { |mat| mat.set(*values) }
|
113
|
-
}
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def parse_texture(_str)
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
|
121
|
-
def parse_texture_array(_str)
|
122
|
-
[]
|
123
|
-
end
|
124
|
-
|
125
|
-
def parse_uniform(uniform)
|
126
|
-
uniform =~ UNIFORM_RGX
|
127
|
-
type_str = $1
|
128
|
-
type = type_str.to_sym
|
129
|
-
is_array = type_str.end_with?('[]')
|
130
|
-
name = $2
|
131
|
-
value_str = $4
|
132
|
-
value = is_array ? [] : nil
|
133
|
-
if value_str && !value_str.empty?
|
134
|
-
value = send("parse_#{type.to_s.gsub(/\[\]/, '_array')}".to_s, value_str)
|
135
|
-
end
|
136
|
-
[name, Uniform.new(type, value)]
|
137
|
-
end
|
138
|
-
|
139
|
-
def load_uniforms(uniforms, uniforms_lib)
|
140
|
-
uniform_strings = nil;
|
141
|
-
in_uniform = false
|
142
|
-
|
143
|
-
uniforms.lines.map(&:strip).each_with_object({}) { |line, hash|
|
144
|
-
if in_uniform
|
145
|
-
uniform_strings << line
|
146
|
-
if line.end_with?(';')
|
147
|
-
in_uniform = false
|
148
|
-
name, value = parse_uniform(uniform_strings.join(' '))
|
149
|
-
hash[name] = value
|
150
|
-
end
|
151
|
-
elsif line =~ /#include\s+(\w+)/
|
152
|
-
uniforms_lib[$1.to_sym].map { |(k, v)| hash[k] = v.clone }
|
153
|
-
elsif line.start_with?('uniform')
|
154
|
-
if line.end_with?(';')
|
155
|
-
name, value = parse_uniform(line)
|
156
|
-
hash[name] = value
|
157
|
-
else
|
158
|
-
in_uniform = true
|
159
|
-
uniform_strings = [line]
|
160
|
-
end
|
161
|
-
end
|
162
|
-
}
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#ifdef USE_BUMPMAP
|
2
|
-
|
3
|
-
uniform sampler2D bumpMap;
|
4
|
-
uniform float bumpScale;
|
5
|
-
|
6
|
-
// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen
|
7
|
-
// http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html
|
8
|
-
|
9
|
-
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
|
10
|
-
|
11
|
-
vec2 dHdxy_fwd() {
|
12
|
-
|
13
|
-
vec2 dSTdx = dFdx( vUv );
|
14
|
-
vec2 dSTdy = dFdy( vUv );
|
15
|
-
|
16
|
-
float Hll = bumpScale * texture( bumpMap, vUv ).x;
|
17
|
-
float dBx = bumpScale * texture( bumpMap, vUv + dSTdx ).x - Hll;
|
18
|
-
float dBy = bumpScale * texture( bumpMap, vUv + dSTdy ).x - Hll;
|
19
|
-
|
20
|
-
return vec2( dBx, dBy );
|
21
|
-
|
22
|
-
}
|
23
|
-
|
24
|
-
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
|
25
|
-
|
26
|
-
vec3 vSigmaX = dFdx( surf_pos );
|
27
|
-
vec3 vSigmaY = dFdy( surf_pos );
|
28
|
-
vec3 vN = surf_norm; // normalized
|
29
|
-
|
30
|
-
vec3 R1 = cross( vSigmaY, vN );
|
31
|
-
vec3 R2 = cross( vN, vSigmaX );
|
32
|
-
|
33
|
-
float fDet = dot( vSigmaX, R1 );
|
34
|
-
|
35
|
-
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
36
|
-
return normalize( abs( fDet ) * surf_norm - vGrad );
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
#endif
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#define PI 3.14159
|
2
|
-
#define PI2 6.28318
|
3
|
-
#define RECIPROCAL_PI2 0.15915494
|
4
|
-
#define LOG2 1.442695
|
5
|
-
#define EPSILON 1e-6
|
6
|
-
|
7
|
-
float square( in float a ) { return a*a; }
|
8
|
-
vec2 square( in vec2 a ) { return vec2( a.x*a.x, a.y*a.y ); }
|
9
|
-
vec3 square( in vec3 a ) { return vec3( a.x*a.x, a.y*a.y, a.z*a.z ); }
|
10
|
-
vec4 square( in vec4 a ) { return vec4( a.x*a.x, a.y*a.y, a.z*a.z, a.w*a.w ); }
|
11
|
-
float saturate( in float a ) { return clamp( a, 0.0, 1.0 ); }
|
12
|
-
vec2 saturate( in vec2 a ) { return clamp( a, 0.0, 1.0 ); }
|
13
|
-
vec3 saturate( in vec3 a ) { return clamp( a, 0.0, 1.0 ); }
|
14
|
-
vec4 saturate( in vec4 a ) { return clamp( a, 0.0, 1.0 ); }
|
15
|
-
float average( in float a ) { return a; }
|
16
|
-
float average( in vec2 a ) { return ( a.x + a.y) * 0.5; }
|
17
|
-
float average( in vec3 a ) { return ( a.x + a.y + a.z) / 3.0; }
|
18
|
-
float average( in vec4 a ) { return ( a.x + a.y + a.z + a.w) * 0.25; }
|
19
|
-
float whiteCompliment( in float a ) { return saturate( 1.0 - a ); }
|
20
|
-
vec2 whiteCompliment( in vec2 a ) { return saturate( vec2(1.0) - a ); }
|
21
|
-
vec3 whiteCompliment( in vec3 a ) { return saturate( vec3(1.0) - a ); }
|
22
|
-
vec4 whiteCompliment( in vec4 a ) { return saturate( vec4(1.0) - a ); }
|
23
|
-
vec3 transformDirection( in vec3 normal, in mat4 matrix ) {
|
24
|
-
return normalize( ( matrix * vec4( normal, 0.0 ) ).xyz );
|
25
|
-
}
|
26
|
-
// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations
|
27
|
-
vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
|
28
|
-
return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
|
29
|
-
}
|
30
|
-
vec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {
|
31
|
-
float distance = dot( planeNormal, point-pointOnPlane );
|
32
|
-
return point - distance * planeNormal;
|
33
|
-
}
|
34
|
-
float sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
35
|
-
return sign( dot( point - pointOnPlane, planeNormal ) );
|
36
|
-
}
|
37
|
-
vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {
|
38
|
-
return pointOnLine + lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) );
|
39
|
-
}
|
40
|
-
float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {
|
41
|
-
if ( decayExponent > 0.0 ) {
|
42
|
-
return pow( saturate( 1.0 - lightDistance / cutoffDistance ), decayExponent );
|
43
|
-
}
|
44
|
-
return 1.0;
|
45
|
-
}
|
46
|
-
|
47
|
-
vec3 inputToLinear( in vec3 a ) {
|
48
|
-
#ifdef GAMMA_INPUT
|
49
|
-
return pow( a, vec3( float( GAMMA_FACTOR ) ) );
|
50
|
-
#else
|
51
|
-
return a;
|
52
|
-
#endif
|
53
|
-
}
|
54
|
-
vec3 linearToOutput( in vec3 a ) {
|
55
|
-
#ifdef GAMMA_OUTPUT
|
56
|
-
return pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );
|
57
|
-
#else
|
58
|
-
return a;
|
59
|
-
#endif
|
60
|
-
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#ifdef USE_SKINNING
|
2
|
-
|
3
|
-
vec4 mvPosition = modelViewMatrix * skinned;
|
4
|
-
|
5
|
-
#elif defined( USE_MORPHTARGETS )
|
6
|
-
|
7
|
-
vec4 mvPosition = modelViewMatrix * vec4( morphed, 1.0 );
|
8
|
-
|
9
|
-
#else
|
10
|
-
|
11
|
-
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
12
|
-
|
13
|
-
#endif
|
14
|
-
|
15
|
-
gl_Position = projectionMatrix * mvPosition;
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#ifdef USE_SKINNING
|
2
|
-
|
3
|
-
vec3 objectNormal = skinnedNormal.xyz;
|
4
|
-
|
5
|
-
#elif defined( USE_MORPHNORMALS )
|
6
|
-
|
7
|
-
vec3 objectNormal = morphedNormal;
|
8
|
-
|
9
|
-
#else
|
10
|
-
|
11
|
-
vec3 objectNormal = normal;
|
12
|
-
|
13
|
-
#endif
|
14
|
-
|
15
|
-
#ifdef FLIP_SIDED
|
16
|
-
|
17
|
-
objectNormal = -objectNormal;
|
18
|
-
|
19
|
-
#endif
|
20
|
-
|
21
|
-
vec3 transformedNormal = normalMatrix * objectNormal;
|
@@ -1,62 +0,0 @@
|
|
1
|
-
#ifdef USE_ENVMAP
|
2
|
-
|
3
|
-
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
4
|
-
|
5
|
-
vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
|
6
|
-
|
7
|
-
// Transforming Normal Vectors with the Inverse Transformation
|
8
|
-
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
9
|
-
|
10
|
-
#ifdef ENVMAP_MODE_REFLECTION
|
11
|
-
|
12
|
-
vec3 reflectVec = reflect( cameraToVertex, worldNormal );
|
13
|
-
|
14
|
-
#else
|
15
|
-
|
16
|
-
vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );
|
17
|
-
|
18
|
-
#endif
|
19
|
-
|
20
|
-
#else
|
21
|
-
|
22
|
-
vec3 reflectVec = vReflect;
|
23
|
-
|
24
|
-
#endif
|
25
|
-
|
26
|
-
#ifdef DOUBLE_SIDED
|
27
|
-
float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );
|
28
|
-
#else
|
29
|
-
float flipNormal = 1.0;
|
30
|
-
#endif
|
31
|
-
|
32
|
-
#ifdef ENVMAP_TYPE_CUBE
|
33
|
-
vec4 envColor = texture( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
34
|
-
|
35
|
-
#elif defined( ENVMAP_TYPE_EQUIREC )
|
36
|
-
vec2 sampleUV;
|
37
|
-
sampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );
|
38
|
-
sampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;
|
39
|
-
vec4 envColor = texture( envMap, sampleUV );
|
40
|
-
|
41
|
-
#elif defined( ENVMAP_TYPE_SPHERE )
|
42
|
-
vec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));
|
43
|
-
vec4 envColor = texture( envMap, reflectView.xy * 0.5 + 0.5 );
|
44
|
-
#endif
|
45
|
-
|
46
|
-
envColor.xyz = inputToLinear( envColor.xyz );
|
47
|
-
|
48
|
-
#ifdef ENVMAP_BLENDING_MULTIPLY
|
49
|
-
|
50
|
-
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
51
|
-
|
52
|
-
#elif defined( ENVMAP_BLENDING_MIX )
|
53
|
-
|
54
|
-
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
55
|
-
|
56
|
-
#elif defined( ENVMAP_BLENDING_ADD )
|
57
|
-
|
58
|
-
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
59
|
-
|
60
|
-
#endif
|
61
|
-
|
62
|
-
#endif
|
@@ -1,21 +0,0 @@
|
|
1
|
-
#ifdef USE_ENVMAP
|
2
|
-
|
3
|
-
uniform float reflectivity;
|
4
|
-
#ifdef ENVMAP_TYPE_CUBE
|
5
|
-
uniform samplerCube envMap;
|
6
|
-
#else
|
7
|
-
uniform sampler2D envMap;
|
8
|
-
#endif
|
9
|
-
uniform float flipEnvMap;
|
10
|
-
|
11
|
-
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
12
|
-
|
13
|
-
uniform float refractionRatio;
|
14
|
-
|
15
|
-
#else
|
16
|
-
|
17
|
-
in vec3 vReflect;
|
18
|
-
|
19
|
-
#endif
|
20
|
-
|
21
|
-
#endif
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )
|
2
|
-
|
3
|
-
vec3 worldNormal = transformDirection( objectNormal, modelMatrix );
|
4
|
-
|
5
|
-
vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
6
|
-
|
7
|
-
#ifdef ENVMAP_MODE_REFLECTION
|
8
|
-
|
9
|
-
vReflect = reflect( cameraToVertex, worldNormal );
|
10
|
-
|
11
|
-
#else
|
12
|
-
|
13
|
-
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
14
|
-
|
15
|
-
#endif
|
16
|
-
|
17
|
-
#endif
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#ifdef USE_FOG
|
2
|
-
|
3
|
-
#ifdef USE_LOGDEPTHBUF_EXT
|
4
|
-
|
5
|
-
float depth = gl_FragDepthEXT / gl_FragCoord.w;
|
6
|
-
|
7
|
-
#else
|
8
|
-
|
9
|
-
float depth = gl_FragCoord.z / gl_FragCoord.w;
|
10
|
-
|
11
|
-
#endif
|
12
|
-
|
13
|
-
#ifdef FOG_EXP2
|
14
|
-
|
15
|
-
float fogFactor = exp2( - square( fogDensity ) * square( depth ) * LOG2 );
|
16
|
-
fogFactor = whiteCompliment( fogFactor );
|
17
|
-
|
18
|
-
#else
|
19
|
-
|
20
|
-
float fogFactor = smoothstep( fogNear, fogFar, depth );
|
21
|
-
|
22
|
-
#endif
|
23
|
-
|
24
|
-
outgoingLight = mix( outgoingLight, fogColor, fogFactor );
|
25
|
-
|
26
|
-
#endif
|
@@ -1,43 +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
|
-
uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];
|
22
|
-
uniform float pointLightDistance[ MAX_POINT_LIGHTS ];
|
23
|
-
uniform float pointLightDecay[ MAX_POINT_LIGHTS ];
|
24
|
-
|
25
|
-
#endif
|
26
|
-
|
27
|
-
#if MAX_SPOT_LIGHTS > 0
|
28
|
-
|
29
|
-
uniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];
|
30
|
-
uniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];
|
31
|
-
uniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];
|
32
|
-
uniform float spotLightDistance[ MAX_SPOT_LIGHTS ];
|
33
|
-
uniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];
|
34
|
-
uniform float spotLightExponent[ MAX_SPOT_LIGHTS ];
|
35
|
-
uniform float spotLightDecay[ MAX_SPOT_LIGHTS ];
|
36
|
-
|
37
|
-
#endif
|
38
|
-
|
39
|
-
#ifdef WRAP_AROUND
|
40
|
-
|
41
|
-
uniform vec3 wrapRGB;
|
42
|
-
|
43
|
-
#endif
|