Module: Mittsu::OpenGLMaterialBasics

Included in:
MeshBasicMaterial, MeshLambertMaterial, MeshPhongMaterial
Defined in:
lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb

Instance Method Summary collapse

Instance Method Details

#get_uv_scale_mapObject



49
50
51
52
53
54
55
# File 'lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb', line 49

def get_uv_scale_map
  map ||
  specular_map ||
  normal_map ||
  bump_map ||
  alpha_map
end

#refresh_env_map_uniforms(uniforms) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb', line 26

def refresh_env_map_uniforms(uniforms)
  uv_scale_map = get_uv_scale_map

  if uv_scale_map
    offset = uv_scale_map.offset
    repeat = uv_scale_map.repeat

    uniforms['offsetRepeat'].value.set(offset.x, offset.y, repeat.x, repeat.y)
  end

  uniforms['envMap'].value = env_map
  # TODO: when OpenGLRenderTargetCube exists
  # uniforms['flipEnvMap'].value = envMap.is_a?(OpenGLRenderTargetCube) ? 1 : - 1
end

#refresh_map_uniforms(uniforms) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb', line 9

def refresh_map_uniforms(uniforms)
  uniforms['map'].value = map
  uniforms['lightMap'].value = light_map
  uniforms['specularMap'].value = specular_map
  uniforms['alphaMap'].value = alpha_map

  if bump_map
    uniforms['bumpMap'].value = bump_map
    uniforms['bumpScale'].value = bump_scale
  end

  if normal_map
    uniforms['normalMap'].value = normal_map
    uniforms['normalScale'].value.copy(normal_scale)
  end
end

#refresh_other_uniforms(uniforms) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb', line 41

def refresh_other_uniforms(uniforms)
  uniforms['opacity'].value = opacity
  uniforms['diffuse'].value = color

  uniforms['reflectivity'].value = reflectivity
  uniforms['refractionRatio'].value = refraction_ratio
end

#refresh_uniforms_basic(uniforms) ⇒ Object



3
4
5
6
7
# File 'lib/mittsu/renderers/opengl/materials/opengl_material_basics.rb', line 3

def refresh_uniforms_basic(uniforms)
  refresh_map_uniforms(uniforms)
  refresh_env_map_uniforms(uniforms)
  refresh_other_uniforms(uniforms)
end