Class: Mittsu::OpenGLMaterial
- Inherits:
-
Object
- Object
- Mittsu::OpenGLMaterial
show all
- Defined in:
- lib/mittsu/renderers/opengl/materials/opengl_material.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(material, renderer) ⇒ OpenGLMaterial
Returns a new instance of OpenGLMaterial.
12
13
14
15
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 12
def initialize(material, renderer)
@material = material
@renderer = renderer
end
|
Instance Attribute Details
#shader ⇒ Object
Returns the value of attribute shader.
10
11
12
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 10
def shader
@shader
end
|
#shadow_pass ⇒ Object
TODO: init_shader for these material-types MeshDepthMaterial => :depth, # TODO… MeshNormalMaterial => :normal, # TODO… LineDashedMaterial => :dashed, # TODO… PointCloudMaterial => :particle_basic # TODO…
9
10
11
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 9
def shadow_pass
@shadow_pass
end
|
Returns the value of attribute uniforms_list.
10
11
12
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 10
def uniforms_list
@uniforms_list
end
|
Instance Method Details
#clear_custom_attributes ⇒ Object
46
47
48
49
50
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 46
def clear_custom_attributes
@material.attributes.each do |attribute|
attribute.needs_update = false
end
end
|
#custom_attributes_dirty? ⇒ Boolean
52
53
54
55
56
57
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 52
def custom_attributes_dirty?
@material.attributes.each do |attribute|
return true if attribute.needs_update
end
false
end
|
#init(lights, fog, object) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 17
def init(lights, fog, object)
@material.add_event_listener(:dispose, @renderer.method(:on_material_dispose))
init_shader
@material.program = find_or_create_program(lights, fog, object)
count_supported_morph_attributes(@material.program.attributes)
@uniforms_list = get_uniforms_list
end
|
63
64
65
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 63
def needs_camera_position_uniform?
@material.env_map
end
|
#needs_face_normals? ⇒ Boolean
42
43
44
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 42
def needs_face_normals?
@material.shading == FlatShading
end
|
#needs_lights? ⇒ Boolean
71
72
73
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 71
def needs_lights?
@material.lights
end
|
67
68
69
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 67
def needs_view_matrix_uniform?
@material.skinning
end
|
59
60
61
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 59
def refresh_uniforms(_)
end
|
#set ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/mittsu/renderers/opengl/materials/opengl_material.rb', line 29
def set
if @material.transparent
@renderer.state.set_blending(@material.blending, @material.blend_equation, @material.blend_src, @material.blend_dst, @material.blend_equation_alpha, @material.blend_src_alpha, @material.blend_dst_alpha)
else
@renderer.state.set_blending(NoBlending)
end
@renderer.state.set_depth_test(@material.depth_test)
@renderer.state.set_depth_write(@material.depth_write)
@renderer.state.set_color_write(@material.color_write)
@renderer.state.set_polygon_offset(@material.polygon_offset, @material.polygon_offset_factor, @material.polygon_offset_units)
end
|