| Flutter Impeller |

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

`#include <material.h>`

Inheritance diagram for impeller::scene::UnlitMaterial:

## Public Member Functions
| ~UnlitMaterial ()
void | SetColor (Color color)
void | SetColorTexture (std::shared_ptr< Texture > color_texture)
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< UnlitMaterial > | 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 73 of file material.h.

## Constructor & Destructor Documentation

## ◆ ~UnlitMaterial()

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

## Member Function Documentation

## ◆ BindToCommand()

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

Implements impeller::scene::Material.

Definition at line 109 of file material.cc.

111 {
112 // Uniform buffer.
113 UnlitFragmentShader::FragInfo info;
114 info.color = color_;
115 info.vertex_color_weight = vertex_color_weight_;
116 UnlitFragmentShader::BindFragInfo(command, buffer.EmplaceUniform(info));
117
118 // Textures.
119 SamplerDescriptor sampler_descriptor;
120 sampler_descriptor.label = "Trilinear";
121 sampler_descriptor.min_filter = MinMagFilter::kLinear;
122 sampler_descriptor.mag_filter = MinMagFilter::kLinear;
123 sampler_descriptor.mip_filter = MipFilter::kLinear;
124 UnlitFragmentShader::BindBaseColorTexture(
125 command,
126 color_texture_ ? color_texture_ : scene_context.GetPlaceholderTexture(),
127 scene_context.GetContext()->GetSamplerLibrary()->GetSampler(
128 sampler_descriptor));
129 }

References impeller::HostBuffer::EmplaceUniform(), impeller::scene::SceneContext::GetContext(), impeller::scene::SceneContext::GetPlaceholderTexture(), impeller::kLinear, impeller::SamplerDescriptor::label, impeller::SamplerDescriptor::mag_filter, impeller::SamplerDescriptor::min_filter, impeller::SamplerDescriptor::mip_filter, and impeller::scene::Material::vertex_color_weight_.

## ◆ GetMaterialType()

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

Implements impeller::scene::Material.

Definition at line 104 of file material.cc.

104 {
105 return MaterialType::kUnlit;
106 }

References impeller::scene::kUnlit.

## ◆ MakeFromFlatbuffer()

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

UnlitMaterial

Definition at line 70 of file material.cc.

72 {
73 if (material.type() != fb::MaterialType::kUnlit) {
74 VALIDATION_LOG << "Cannot unpack unlit material because the ipscene "
75 "material type is not unlit.";
76 return nullptr;
77 }
78
79 auto result = Material::MakeUnlit();
80
81 if (material.base_color_factor()) {
82 result->SetColor(importer::ToColor(*material.base_color_factor()));
83 }
84
85 if (material.base_color_texture() >= 0 &&
86 material.base_color_texture() < static_cast<int32_t>(textures.size())) {
87 result->SetColorTexture(textures[material.base_color_texture()]);
88 }
89
90 return result;
91 }

References impeller::scene::Material::MakeUnlit(), impeller::scene::importer::ToColor(), and VALIDATION_LOG.

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

## ◆ SetColor()

void impeller::scene::UnlitMaterial::SetColor | ( | Color | color | ) |

Definition at line 95 of file material.cc.

95 {
96 color_ = color;
97 }

## ◆ SetColorTexture()

void impeller::scene::UnlitMaterial::SetColorTexture | ( | std::shared_ptr< Texture > | color_texture | ) |

Definition at line 99 of file material.cc.

99 {
100 color_texture_ = std::move(color_texture);
101 }

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

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

impeller::scene::importer::ToColor
Color ToColor(const fb::Color &c)
Definition: conversions.cc:46
impeller::MinMagFilter::kLinear
@ kLinear
impeller::scene::MaterialType::kUnlit
@ kUnlit
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::scene::Material::MakeUnlit
static std::unique_ptr< UnlitMaterial > MakeUnlit()
Definition: material.cc:37
impeller::MipFilter::kLinear
@ kLinear
impeller::scene::Material::vertex_color_weight_
Scalar vertex_color_weight_
Definition: material.h:67