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

Implements impeller::scene::Material.

Definition at line 110 of file material.cc.

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

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

105 {
106 return MaterialType::kUnlit;
107 }

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

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

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

96 {
97 color_ = color;
98 }

References color.

## ◆ SetColorTexture()

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

Definition at line 100 of file material.cc.

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

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:73
impeller::scene::Material::MakeUnlit
static std::unique_ptr< UnlitMaterial > MakeUnlit()
Definition: material.cc:38
impeller::MipFilter::kLinear
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
color
DlColor color
Definition: dl_golden_blur_unittests.cc:23
impeller::scene::Material::vertex_color_weight_
Scalar vertex_color_weight_
Definition: material.h:67