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,201 +0,0 @@
|
|
1
|
-
module Mittsu
|
2
|
-
class OpenGLRenderTarget < Texture
|
3
|
-
include EventDispatcher
|
4
|
-
|
5
|
-
attr_accessor :width,
|
6
|
-
:height,
|
7
|
-
:wrap_s,
|
8
|
-
:wrap_t,
|
9
|
-
:mag_filter,
|
10
|
-
:min_filter,
|
11
|
-
:anisotropy,
|
12
|
-
:offset,
|
13
|
-
:repeat,
|
14
|
-
:format,
|
15
|
-
:type,
|
16
|
-
:depth_buffer,
|
17
|
-
:stencil_buffer,
|
18
|
-
:generate_mipmaps,
|
19
|
-
:share_depth_from
|
20
|
-
|
21
|
-
attr_reader :framebuffer
|
22
|
-
|
23
|
-
attr_writer :renderer
|
24
|
-
|
25
|
-
def initialize(width, height, options = {})
|
26
|
-
super(self, nil)
|
27
|
-
|
28
|
-
@width = width
|
29
|
-
@height = height
|
30
|
-
|
31
|
-
@wrap_s = options.fetch(:wrap_s, ClampToEdgeWrapping)
|
32
|
-
@wrap_t = options.fetch(:wrap_t, ClampToEdgeWrapping)
|
33
|
-
|
34
|
-
@mag_filter = options.fetch(:mag_filter, LinearFilter)
|
35
|
-
@min_filter = options.fetch(:min_filter, LinearMipMapLinearFilter)
|
36
|
-
|
37
|
-
@anisotropy = options.fetch(:anisotropy, 1.0);
|
38
|
-
|
39
|
-
@offset = Vector2.new(0.0, 0.0)
|
40
|
-
@repeat = Vector2.new(1.0, 1.0)
|
41
|
-
|
42
|
-
@format = options.fetch(:format, RGBAFormat)
|
43
|
-
@type = options.fetch(:type, UnsignedByteType)
|
44
|
-
|
45
|
-
@depth_buffer = options.fetch(:depth_buffer, true)
|
46
|
-
@stencil_buffer = options.fetch(:stencil_buffer, true)
|
47
|
-
|
48
|
-
@generate_mipmaps = true
|
49
|
-
|
50
|
-
@share_depth_from = options.fetch(:share_depth_from, nil)
|
51
|
-
end
|
52
|
-
|
53
|
-
def set_size(width, height)
|
54
|
-
@width = width
|
55
|
-
@height = height
|
56
|
-
end
|
57
|
-
|
58
|
-
def needs_update?
|
59
|
-
false
|
60
|
-
end
|
61
|
-
|
62
|
-
def clone
|
63
|
-
OpenGLRenderTarget.new(@width, @height).tap do |tmp|
|
64
|
-
tmp.renderer = @renderer
|
65
|
-
|
66
|
-
tmp.wrap_s = @wrap_s
|
67
|
-
tmp.wrap_t = @wrap_t
|
68
|
-
|
69
|
-
tmp.mag_filter = @mag_filter
|
70
|
-
tmp.min_filter = @min_filter
|
71
|
-
|
72
|
-
tmp.anisotropy = @anisotropy
|
73
|
-
|
74
|
-
tmp.offset.copy(@offset)
|
75
|
-
tmp.repeat.copy(@repeat)
|
76
|
-
|
77
|
-
tmp.format = @format
|
78
|
-
tmp.type = @type
|
79
|
-
|
80
|
-
tmp.depth_buffer = @depth_buffer
|
81
|
-
tmp.stencil_buffer = @stencil_buffer
|
82
|
-
|
83
|
-
tmp.generate_mipmaps = @generate_mipmaps
|
84
|
-
|
85
|
-
tmp.share_depth_from = @share_depth_from
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def setup_buffers
|
90
|
-
return unless @framebuffer.nil?
|
91
|
-
|
92
|
-
# TODO: when OpenGLRenderTargetCube exists
|
93
|
-
is_cube = false # render_target.is_a? OpenGLRenderTargetCube
|
94
|
-
|
95
|
-
@depth_buffer = true if @depth_buffer.nil?
|
96
|
-
@stencil_buffer = true if @stencil_buffer.nil?
|
97
|
-
|
98
|
-
add_event_listener(:dispose, @renderer.method(:on_render_target_dispose))
|
99
|
-
|
100
|
-
@opengl_texture = glCreateTexture
|
101
|
-
|
102
|
-
@renderer.info[:memory][:textures] += 1
|
103
|
-
|
104
|
-
# Setup texture, create render and frame buffers
|
105
|
-
|
106
|
-
is_target_power_of_two = Math.power_of_two?(@width) && Math.power_of_two?(@height)
|
107
|
-
gl_format = GL_MITTSU_PARAMS[@format]
|
108
|
-
gl_type = GL_MITTSU_PARAMS[@type]
|
109
|
-
|
110
|
-
if is_cube
|
111
|
-
# TODO
|
112
|
-
else
|
113
|
-
@framebuffer = glCreateFramebuffer
|
114
|
-
|
115
|
-
if @share_depth_from
|
116
|
-
@renderbuffer = share_depth_from.renderbuffer
|
117
|
-
else
|
118
|
-
@renderbuffer = glCreateRenderbuffer
|
119
|
-
end
|
120
|
-
|
121
|
-
glBindTexture(GL_TEXTURE_2D, @opengl_texture)
|
122
|
-
set_parameters(GL_TEXTURE_2D, is_target_power_of_two)
|
123
|
-
|
124
|
-
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, @width, @height, 0, gl_format, gl_type, nil)
|
125
|
-
|
126
|
-
setup_framebuffer(GL_TEXTURE_2D)
|
127
|
-
|
128
|
-
if @share_depth_from
|
129
|
-
if @depth_buffer && !@stencil_buffer
|
130
|
-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, @renderbuffer)
|
131
|
-
elsif @depth_buffer && @stencil_buffer
|
132
|
-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, @renderbuffer)
|
133
|
-
end
|
134
|
-
else
|
135
|
-
setup_renderbuffer
|
136
|
-
end
|
137
|
-
|
138
|
-
glGenerateMipmap(GL_TEXTURE_2D) if is_target_power_of_two
|
139
|
-
end
|
140
|
-
|
141
|
-
# Release everything
|
142
|
-
|
143
|
-
if is_cube
|
144
|
-
# TODO
|
145
|
-
else
|
146
|
-
glBindTexture(GL_TEXTURE_2D, 0)
|
147
|
-
end
|
148
|
-
|
149
|
-
glBindRenderbuffer(GL_RENDERBUFFER, 0)
|
150
|
-
glBindFramebuffer(GL_FRAMEBUFFER, 0)
|
151
|
-
end
|
152
|
-
|
153
|
-
def use
|
154
|
-
glBindFramebuffer(GL_FRAMEBUFFER, @framebuffer)
|
155
|
-
glViewport(0, 0, @width, @height)
|
156
|
-
end
|
157
|
-
|
158
|
-
def dispose
|
159
|
-
dispatch_event(type: :dispose)
|
160
|
-
end
|
161
|
-
|
162
|
-
def update_mipmap
|
163
|
-
return if !@generate_mipmaps || @min_filter == NearestFilter || @min_filter == LinearFilter
|
164
|
-
# TODO: when OpenGLRenderTargetCube exists
|
165
|
-
# glBindTexture(GL_TEXTURE_CUBE_MAP, @opengl_texture)
|
166
|
-
# glGenerateMipmap(GL_TEXTURE_CUBE_MAP)
|
167
|
-
# glBindTexture(GL_TEXTURE_CUBE_MAP, nil)
|
168
|
-
glBindTexture(GL_TEXTURE_2D, @opengl_texture)
|
169
|
-
glGenerateMipmap(GL_TEXTURE_2D)
|
170
|
-
glBindTexture(GL_TEXTURE_2D, nil)
|
171
|
-
end
|
172
|
-
|
173
|
-
private
|
174
|
-
|
175
|
-
def setup_framebuffer(texture_target)
|
176
|
-
glBindFramebuffer(GL_FRAMEBUFFER, @framebuffer)
|
177
|
-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture_target, @opengl_texture, 0)
|
178
|
-
end
|
179
|
-
|
180
|
-
def setup_renderbuffer
|
181
|
-
glBindRenderbuffer(GL_RENDERBUFFER, @renderbuffer)
|
182
|
-
|
183
|
-
if @depth_buffer && !@stencil_buffer
|
184
|
-
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, @width, @height)
|
185
|
-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, @renderbuffer)
|
186
|
-
|
187
|
-
# TODO: investigate this (?):
|
188
|
-
# THREE.js - For some reason this is not working. Defaulting to RGBA4.
|
189
|
-
# } else if ( ! renderTarget.depthBuffer && renderTarget.stencilBuffer ) {
|
190
|
-
#
|
191
|
-
# _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.STENCIL_INDEX8, renderTarget.width, renderTarget.height );
|
192
|
-
# _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );
|
193
|
-
elsif @depth_buffer && @stencil_buffer
|
194
|
-
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, @width, @height)
|
195
|
-
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, @renderbuffer)
|
196
|
-
else
|
197
|
-
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, @width, @height)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|