11#include "impeller/scene/importer/scene_flatbuffers.h"
14#include "impeller/scene/shaders/unlit.frag.h"
28 const fb::Material& material,
29 const std::vector<std::shared_ptr<Texture>>& textures) {
30 switch (material.type()) {
31 case fb::MaterialType::kUnlit:
33 case fb::MaterialType::kPhysicallyBased:
39 return std::make_unique<UnlitMaterial>();
43 return std::make_unique<PhysicallyBasedMaterial>();
72 const fb::Material& material,
73 const std::vector<std::shared_ptr<Texture>>& textures) {
74 if (material.type() != fb::MaterialType::kUnlit) {
75 VALIDATION_LOG <<
"Cannot unpack unlit material because the ipscene "
76 "material type is not unlit.";
82 if (material.base_color_factor()) {
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()]);
101 color_texture_ = std::move(color_texture);
114 UnlitFragmentShader::FragInfo
info;
117 UnlitFragmentShader::BindFragInfo(pass,
buffer.EmplaceUniform(
info));
121 sampler_descriptor.
label =
"Trilinear";
125 UnlitFragmentShader::BindBaseColorTexture(
128 scene_context.
GetContext()->GetSamplerLibrary()->GetSampler(
129 sampler_descriptor));
136std::unique_ptr<PhysicallyBasedMaterial>
138 const fb::Material& material,
139 const std::vector<std::shared_ptr<Texture>>& textures) {
140 if (material.type() != fb::MaterialType::kPhysicallyBased) {
141 VALIDATION_LOG <<
"Cannot unpack unlit material because the ipscene "
142 "material type is not unlit.";
148 result->SetAlbedo(material.base_color_factor()
151 result->SetRoughness(material.roughness_factor());
152 result->SetMetallic(material.metallic_factor());
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);
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()]);
165 if (material.normal_texture() >= 0 &&
166 material.normal_texture() <
static_cast<int32_t
>(textures.size())) {
167 result->SetNormalTexture(textures[material.normal_texture()]);
169 if (material.occlusion_texture() >= 0 &&
170 material.occlusion_texture() <
static_cast<int32_t
>(textures.size())) {
171 result->SetOcclusionTexture(textures[material.occlusion_texture()]);
184 roughness_ = roughness;
188 metallic_ = metallic;
192 std::shared_ptr<Texture> albedo_texture) {
193 albedo_texture_ = std::move(albedo_texture);
197 std::shared_ptr<Texture> metallic_roughness_texture) {
198 metallic_roughness_texture_ = std::move(metallic_roughness_texture);
202 std::shared_ptr<Texture> normal_texture) {
203 normal_texture_ = std::move(normal_texture);
207 std::shared_ptr<Texture> occlusion_texture) {
208 occlusion_texture_ = std::move(occlusion_texture);
212 std::shared_ptr<Texture> environment_map) {
213 environment_map_ = std::move(environment_map);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Render passes encode render commands directed as one specific render target into an underlying comman...
const RenderTarget & GetRenderTarget() const
SampleCount GetSampleCount() const
static std::unique_ptr< Material > MakeFromFlatbuffer(const fb::Material &material, const std::vector< std::shared_ptr< Texture > > &textures)
Scalar vertex_color_weight_
void SetVertexColorWeight(Scalar weight)
void SetStencilConfig(StencilConfig stencil_config)
void SetTranslucent(bool is_translucent)
SceneContextOptions GetContextOptions(const RenderPass &pass) const
static std::unique_ptr< PhysicallyBasedMaterial > MakePhysicallyBased()
StencilConfig stencil_config_
void SetBlendConfig(BlendConfig blend_config)
static std::unique_ptr< UnlitMaterial > MakeUnlit()
BlendConfig blend_config_
void SetEnvironmentMap(std::shared_ptr< Texture > environment_map)
void SetMetallicRoughnessTexture(std::shared_ptr< Texture > metallic_roughness_texture)
static std::unique_ptr< PhysicallyBasedMaterial > MakeFromFlatbuffer(const fb::Material &material, const std::vector< std::shared_ptr< Texture > > &textures)
MaterialType GetMaterialType() const override
void SetNormalTexture(std::shared_ptr< Texture > normal_texture)
void SetAlbedoTexture(std::shared_ptr< Texture > albedo_texture)
void SetOcclusionTexture(std::shared_ptr< Texture > occlusion_texture)
~PhysicallyBasedMaterial()
void SetRoughness(Scalar roughness)
void SetMetallic(Scalar metallic)
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, RenderPass &pass) const override
void SetAlbedo(Color albedo)
std::shared_ptr< Context > GetContext() const
std::shared_ptr< Texture > GetPlaceholderTexture() const
static std::unique_ptr< UnlitMaterial > MakeFromFlatbuffer(const fb::Material &material, const std::vector< std::shared_ptr< Texture > > &textures)
MaterialType GetMaterialType() const override
void BindToCommand(const SceneContext &scene_context, HostBuffer &buffer, RenderPass &pass) const override
void SetColorTexture(std::shared_ptr< Texture > color_texture)
void SetColor(Color color)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Color ToColor(const fb::Color &c)
@ kLinear
Sample from the two nearest mip levels and linearly interpolate.
static constexpr Color White()