| Flutter Impeller |

Public Member Functions | Static Public Member Functions | List of all members
impeller::scene::PhysicallyBasedMaterial Class Referencefinal

`#include <material.h>`

Inheritance diagram for impeller::scene::PhysicallyBasedMaterial:

## Public Member Functions
| ~PhysicallyBasedMaterial ()
void | SetAlbedo (Color albedo)
void | SetRoughness (Scalar roughness)
void | SetMetallic (Scalar metallic)
void | SetAlbedoTexture (std::shared_ptr< Texture > albedo_texture)
void | SetMetallicRoughnessTexture (std::shared_ptr< Texture > metallic_roughness_texture)
void | SetNormalTexture (std::shared_ptr< Texture > normal_texture)
void | SetOcclusionTexture (std::shared_ptr< Texture > occlusion_texture)
void | SetEnvironmentMap (std::shared_ptr< Texture > environment_map)
MaterialType | GetMaterialType () const override
void | BindToCommand (const SceneContext &scene_context, HostBuffer &buffer, Command &command) const override
Public Member Functions inherited from impeller::scene::Material
virtual | ~Material ()
void | SetVertexColorWeight (Scalar weight)
void | SetBlendConfig (BlendConfig blend_config)
void | SetStencilConfig (StencilConfig stencil_config)
void | SetTranslucent (bool is_translucent)
SceneContextOptions | GetContextOptions (const RenderPass &pass) const

## Static Public Member Functions
static std::unique_ptr< PhysicallyBasedMaterial > | MakeFromFlatbuffer (const fb::Material &material, const std::vector< std::shared_ptr< Texture >> &textures)
Static Public Member Functions inherited from impeller::scene::Material
static std::unique_ptr< Material > | MakeFromFlatbuffer (const fb::Material &material, const std::vector< std::shared_ptr< Texture >> &textures)
static std::unique_ptr< UnlitMaterial > | MakeUnlit ()
static std::unique_ptr< PhysicallyBasedMaterial > | MakePhysicallyBased ()

## Additional Inherited Members
Protected Attributes inherited from impeller::scene::Material
Scalar | vertex_color_weight_ = 1
BlendConfig | blend_config_
StencilConfig | stencil_config_
bool | is_translucent_ = false

## Detailed Description

Definition at line 98 of file material.h.

## Constructor & Destructor Documentation

## ◆ ~PhysicallyBasedMaterial()

impeller::scene::PhysicallyBasedMaterial::~PhysicallyBasedMaterial | ( |  | ) |
| default

## Member Function Documentation

## ◆ BindToCommand()

void impeller::scene::PhysicallyBasedMaterial::BindToCommand | ( | const SceneContext & | scene_context,
|  | HostBuffer & | buffer,
|  | Command & | command
| ) |  | const
| override virtual

Implements impeller::scene::Material.

Definition at line 222 of file material.cc.

224 {}

## ◆ GetMaterialType()

MaterialType impeller::scene::PhysicallyBasedMaterial::GetMaterialType | ( |  | ) | const
| override virtual

Implements impeller::scene::Material.

Definition at line 216 of file material.cc.

216 {
217 // TODO(bdero): Replace this once a PBR shader has landed.
218 return MaterialType::kUnlit;
219 }

References impeller::scene::kUnlit.

## ◆ MakeFromFlatbuffer()

std::unique_ptr< PhysicallyBasedMaterial > impeller::scene::PhysicallyBasedMaterial::MakeFromFlatbuffer | ( | const fb::Material & | material,
|  | const std::vector< std::shared_ptr< Texture >> & | textures
| ) |  |
| static

StandardMaterial

Definition at line 136 of file material.cc.

138 {
139 if (material.type() != fb::MaterialType::kPhysicallyBased) {
140 VALIDATION_LOG << "Cannot unpack unlit material because the ipscene "
141 "material type is not unlit.";
142 return nullptr;
143 }
144
145 auto result = Material::MakePhysicallyBased();
146
147 result->SetAlbedo(material.base_color_factor()
148 ? importer::ToColor(*material.base_color_factor())
149 : Color::White());
150 result->SetRoughness(material.roughness_factor());
151 result->SetMetallic(material.metallic_factor());
152
153 if (material.base_color_texture() >= 0 &&
154 material.base_color_texture() < static_cast<int32_t>(textures.size())) {
155 result->SetAlbedoTexture(textures[material.base_color_texture()]);
156 result->SetVertexColorWeight(0);
157 }
158 if (material.metallic_roughness_texture() >= 0 &&
159 material.metallic_roughness_texture() <
160 static_cast<int32_t>(textures.size())) {
161 result->SetMetallicRoughnessTexture(
162 textures[material.metallic_roughness_texture()]);
163 }
164 if (material.normal_texture() >= 0 &&
165 material.normal_texture() < static_cast<int32_t>(textures.size())) {
166 result->SetNormalTexture(textures[material.normal_texture()]);
167 }
168 if (material.occlusion_texture() >= 0 &&
169 material.occlusion_texture() < static_cast<int32_t>(textures.size())) {
170 result->SetOcclusionTexture(textures[material.occlusion_texture()]);
171 }
172
173 return result;
174 }

References impeller::scene::Material::MakePhysicallyBased(), impeller::scene::importer::ToColor(), VALIDATION_LOG, and impeller::Color::White().

Referenced by impeller::scene::Material::MakeFromFlatbuffer().

## ◆ SetAlbedo()

void impeller::scene::PhysicallyBasedMaterial::SetAlbedo | ( | Color | albedo | ) |

Definition at line 178 of file material.cc.

178 {
179 albedo_ = albedo;
180 }

## ◆ SetAlbedoTexture()

void impeller::scene::PhysicallyBasedMaterial::SetAlbedoTexture | ( | std::shared_ptr< Texture > | albedo_texture | ) |

Definition at line 190 of file material.cc.

191 {
192 albedo_texture_ = std::move(albedo_texture);
193 }

## ◆ SetEnvironmentMap()

void impeller::scene::PhysicallyBasedMaterial::SetEnvironmentMap | ( | std::shared_ptr< Texture > | environment_map | ) |

Definition at line 210 of file material.cc.

211 {
212 environment_map_ = std::move(environment_map);
213 }

## ◆ SetMetallic()

void impeller::scene::PhysicallyBasedMaterial::SetMetallic | ( | Scalar | metallic | ) |

Definition at line 186 of file material.cc.

186 {
187 metallic_ = metallic;
188 }

## ◆ SetMetallicRoughnessTexture()

void impeller::scene::PhysicallyBasedMaterial::SetMetallicRoughnessTexture | ( | std::shared_ptr< Texture > | metallic_roughness_texture | ) |

Definition at line 195 of file material.cc.

196 {
197 metallic_roughness_texture_ = std::move(metallic_roughness_texture);
198 }

## ◆ SetNormalTexture()

void impeller::scene::PhysicallyBasedMaterial::SetNormalTexture | ( | std::shared_ptr< Texture > | normal_texture | ) |

Definition at line 200 of file material.cc.

201 {
202 normal_texture_ = std::move(normal_texture);
203 }

## ◆ SetOcclusionTexture()

void impeller::scene::PhysicallyBasedMaterial::SetOcclusionTexture | ( | std::shared_ptr< Texture > | occlusion_texture | ) |

Definition at line 205 of file material.cc.

206 {
207 occlusion_texture_ = std::move(occlusion_texture);
208 }

## ◆ SetRoughness()

void impeller::scene::PhysicallyBasedMaterial::SetRoughness | ( | Scalar | roughness | ) |

Definition at line 182 of file material.cc.

182 {
183 roughness_ = roughness;
184 }

The documentation for this class was generated from the following files:

- impeller/scene/material.h
- impeller/scene/material.cc

impeller::scene::Material::MakePhysicallyBased
static std::unique_ptr< PhysicallyBasedMaterial > MakePhysicallyBased()
Definition: material.cc:41
impeller::scene::importer::ToColor
Color ToColor(const fb::Color &c)
Definition: conversions.cc:46
impeller::scene::MaterialType::kUnlit
@ kUnlit
impeller::Color::White
static constexpr Color White()
Definition: color.h:256
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67