Skip to content

Commit

Permalink
Remove now-redundant feature level 0 materials
Browse files Browse the repository at this point in the history
  • Loading branch information
elizagamedev committed Sep 26, 2023
1 parent 3aee940 commit 9a6b8bf
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,7 @@ class MainActivity : Activity() {
}

private fun loadMaterial() {
var name = "materials/baked_color.filamat"
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
name = "materials/baked_color_es2.filamat"
}
readUncompressedAsset(name).let {
readUncompressedAsset("materials/baked_color.filamat").let {
material = Material.Builder().payload(it, it.remaining()).build(engine)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ material {
],

// This material disables all lighting
shadingModel : unlit
shadingModel : unlit,
featureLevel : 0
}

fragment {
Expand Down

This file was deleted.

22 changes: 0 additions & 22 deletions filament/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ set(MATERIAL_SRCS
src/materials/vsmMipmap.mat
)

set(MATERIAL_ES2_SRCS
src/materials/defaultMaterial0.mat
src/materials/skybox0.mat
)

# Embed the binary resource blob for materials.
get_resgen_vars(${RESOURCE_DIR} materials)
list(APPEND PRIVATE_HDRS ${RESGEN_HEADER})
Expand Down Expand Up @@ -315,23 +310,6 @@ foreach (mat_src ${MATERIAL_SRCS})
list(APPEND MATERIAL_BINS ${output_path})
endforeach()

if (IS_MOBILE_TARGET AND FILAMENT_SUPPORTS_OPENGL)
foreach (mat_src ${MATERIAL_ES2_SRCS})
get_filename_component(localname "${mat_src}" NAME_WE)
get_filename_component(fullname "${mat_src}" ABSOLUTE)
set(output_path "${MATERIAL_DIR}/${localname}.filamat")

add_custom_command(
OUTPUT ${output_path}
COMMAND matc -a opengl -p ${MATC_TARGET} ${MATC_OPT_FLAGS} -o ${output_path} ${fullname}
MAIN_DEPENDENCY ${fullname}
DEPENDS matc
COMMENT "Compiling material ${mat_src} to ${output_path}"
)
list(APPEND MATERIAL_BINS ${output_path})
endforeach ()
endif ()

# Additional dependencies on included files for materials

add_custom_command(
Expand Down
17 changes: 6 additions & 11 deletions filament/src/details/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,17 @@ void FEngine::init() {
driverApi.update3DImage(mDummyZeroTexture, 0, 0, 0, 0, 1, 1, 1,
{ zeroes, 4, Texture::Format::RGBA, Texture::Type::UBYTE });

FMaterial::DefaultMaterialBuilder defaultMaterialBuilder;
defaultMaterialBuilder.package(
MATERIALS_DEFAULTMATERIAL_DATA, MATERIALS_DEFAULTMATERIAL_SIZE);
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*const_cast<FEngine*>(this)));

#ifdef FILAMENT_TARGET_MOBILE
if (UTILS_UNLIKELY(mActiveFeatureLevel == FeatureLevel::FEATURE_LEVEL_0)) {
FMaterial::DefaultMaterialBuilder defaultMaterialBuilder;
defaultMaterialBuilder.package(
MATERIALS_DEFAULTMATERIAL0_DATA, MATERIALS_DEFAULTMATERIAL0_SIZE);
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*const_cast<FEngine*>(this)));
} else
if (UTILS_LIKELY(mActiveFeatureLevel > FeatureLevel::FEATURE_LEVEL_0))
#endif
{
mDefaultColorGrading = downcast(ColorGrading::Builder().build(*this));

FMaterial::DefaultMaterialBuilder defaultMaterialBuilder;
defaultMaterialBuilder.package(
MATERIALS_DEFAULTMATERIAL_DATA, MATERIALS_DEFAULTMATERIAL_SIZE);
mDefaultMaterial = downcast(defaultMaterialBuilder.build(*const_cast<FEngine*>(this)));

float3 dummyPositions[1] = {};
short4 dummyTangents[1] = {};
mDummyMorphTargetBuffer->setPositionsAt(*this, 0, dummyPositions, 1, 0);
Expand Down
9 changes: 1 addition & 8 deletions filament/src/details/Skybox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,7 @@ FSkybox::FSkybox(FEngine& engine, const Builder& builder) noexcept

FMaterial const* FSkybox::createMaterial(FEngine& engine) {
Material::Builder builder;
#ifdef FILAMENT_TARGET_MOBILE
if (UTILS_UNLIKELY(engine.getActiveFeatureLevel() == Engine::FeatureLevel::FEATURE_LEVEL_0)) {
builder.package(MATERIALS_SKYBOX0_DATA, MATERIALS_SKYBOX0_SIZE);
} else
#endif
{
builder.package(MATERIALS_SKYBOX_DATA, MATERIALS_SKYBOX_SIZE);
}
builder.package(MATERIALS_SKYBOX_DATA, MATERIALS_SKYBOX_SIZE);
auto material = builder.build(engine);
return downcast(material);
}
Expand Down
3 changes: 2 additions & 1 deletion filament/src/materials/defaultMaterial.mat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
material {
name : "Filament Default Material",
shadingModel : unlit
shadingModel : unlit,
featureLevel : 0
}

fragment {
Expand Down
12 changes: 0 additions & 12 deletions filament/src/materials/defaultMaterial0.mat

This file was deleted.

10 changes: 8 additions & 2 deletions filament/src/materials/skybox.mat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ material {
depthWrite : false,
shadingModel : unlit,
variantFilter : [ skinning, shadowReceiver, vsm ],
culling: none
culling : none,
featureLevel : 0
}

fragment {
Expand All @@ -35,10 +36,15 @@ fragment {
if (materialParams.constantColor != 0) {
sky = materialParams.color;
} else {
#if MATERIAL_FEATURE_LEVEL == 0
sky = vec4(textureCube(materialParams_skybox, variable_eyeDirection.xyz).rgb, 1.0);
#else
// textureLod() at 0.0 is more performant than texture().
sky = vec4(textureLod(materialParams_skybox, variable_eyeDirection.xyz, 0.0).rgb, 1.0);
#endif
sky.rgb *= frameUniforms.iblLuminance;
}
if (materialParams.showSun != 0 && frameUniforms.sun.w >= 0.0f) {
if (materialParams.showSun != 0 && frameUniforms.sun.w >= 0.0) {
vec3 direction = normalize(variable_eyeDirection.xyz);
// Assume the sun is a sphere
vec3 sun = frameUniforms.lightColorIntensity.rgb *
Expand Down
60 changes: 0 additions & 60 deletions filament/src/materials/skybox0.mat

This file was deleted.

0 comments on commit 9a6b8bf

Please sign in to comment.