Class: Stagecraft::Materials::PBR

Inherits:
Base
  • Object
show all
Defined in:
lib/stagecraft/materials/pbr_material.rb

Constant Summary collapse

TEXTURE_ATTRIBUTES =
%i[
  base_color_map metallic_roughness_map normal_map occlusion_map emissive_map
].freeze
TRANSFORM_ATTRIBUTES =
%i[
  base_color_uv_transform metallic_roughness_uv_transform normal_uv_transform
  occlusion_uv_transform emissive_uv_transform
].freeze
UV_SET_ATTRIBUTES =
%i[
  base_color_uv_set metallic_roughness_uv_set normal_uv_set
  occlusion_uv_set emissive_uv_set
].freeze

Constants inherited from Base

Base::ALPHA_MODES, Base::BLENDS, Base::SIDES

Instance Attribute Summary

Attributes inherited from Base

#version

Instance Method Summary collapse

Methods inherited from Base

#transparent?, versioned_attribute

Constructor Details

#initialize(base_color: Color.new(1.0), base_color_map: nil, metallic: 1.0, roughness: 1.0, metallic_roughness_map: nil, normal_map: nil, normal_scale: 1.0, occlusion_map: nil, occlusion_strength: 1.0, emissive: Color.new(0.0), emissive_map: nil, emissive_strength: 1.0, base_color_uv_transform: Larb::Mat3.new, metallic_roughness_uv_transform: Larb::Mat3.new, normal_uv_transform: Larb::Mat3.new, occlusion_uv_transform: Larb::Mat3.new, emissive_uv_transform: Larb::Mat3.new, base_color_uv_set: 0, metallic_roughness_uv_set: 0, normal_uv_set: 0, occlusion_uv_set: 0, emissive_uv_set: 0) ⇒ PBR

Returns a new instance of PBR.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/stagecraft/materials/pbr_material.rb', line 18

def initialize(base_color: Color.new(1.0), base_color_map: nil, metallic: 1.0,
               roughness: 1.0, metallic_roughness_map: nil, normal_map: nil,
               normal_scale: 1.0, occlusion_map: nil, occlusion_strength: 1.0,
               emissive: Color.new(0.0), emissive_map: nil, emissive_strength: 1.0,
               base_color_uv_transform: Larb::Mat3.new,
               metallic_roughness_uv_transform: Larb::Mat3.new,
               normal_uv_transform: Larb::Mat3.new,
               occlusion_uv_transform: Larb::Mat3.new,
               emissive_uv_transform: Larb::Mat3.new,
               base_color_uv_set: 0, metallic_roughness_uv_set: 0,
               normal_uv_set: 0, occlusion_uv_set: 0, emissive_uv_set: 0, **)
  super(**)
  self.base_color = base_color
  self.base_color_map = base_color_map
  self.metallic = metallic
  self.roughness = roughness
  self.metallic_roughness_map = metallic_roughness_map
  self.normal_map = normal_map
  self.normal_scale = normal_scale
  self.occlusion_map = occlusion_map
  self.occlusion_strength = occlusion_strength
  self.emissive = emissive
  self.emissive_map = emissive_map
  self.emissive_strength = emissive_strength
  TRANSFORM_ATTRIBUTES.each do |name|
    self.public_send(:"#{name}=", binding.local_variable_get(name))
  end
  UV_SET_ATTRIBUTES.each do |name|
    self.public_send(:"#{name}=", binding.local_variable_get(name))
  end
end