| 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, RenderPass &pass) 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,
|  | RenderPass & | pass
| ) |  | const
| override virtual

Implements impeller::scene::Material.

Definition at line 223 of file material.cc.

225 {}

## ◆ GetMaterialType()

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

Implements impeller::scene::Material.

Definition at line 217 of file material.cc.

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

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 137 of file material.cc.

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

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 179 of file material.cc.

179 {
180 albedo_ = albedo;
181 }

## ◆ SetAlbedoTexture()

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

Definition at line 191 of file material.cc.

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

## ◆ SetEnvironmentMap()

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

Definition at line 211 of file material.cc.

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

## ◆ SetMetallic()

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

Definition at line 187 of file material.cc.

187 {
188 metallic_ = metallic;
189 }

## ◆ SetMetallicRoughnessTexture()

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

Definition at line 196 of file material.cc.

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

## ◆ SetNormalTexture()

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

Definition at line 201 of file material.cc.

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

## ◆ SetOcclusionTexture()

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

Definition at line 206 of file material.cc.

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

## ◆ SetRoughness()

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

Definition at line 183 of file material.cc.

183 {
184 roughness_ = roughness;
185 }

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:42
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:266
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73