Implement lod bias for user materials

A lod bias can be applied to textures when dynamic resolution is
enabled. A proper lod bias is calculated and applied for quality levels
HIGH and ULTRA.

Lod Bias is implemented in glslang, which mean it's ignored when
glslang is not used, which currently happens with OpenGL backends with
optimization turned off (which includes filament LITE). This may be
fixed in the future.
This commit is contained in:
Mathias Agopian
2021-09-15 17:19:40 -07:00
committed by Mathias Agopian
parent 1a8550e8e0
commit ceeccde92c
18 changed files with 151 additions and 3 deletions
+7
View File
@@ -30,6 +30,7 @@
#include "sca/GLSLTools.h"
#include <utils/Log.h>
#include <filament/MaterialEnums.h>
using namespace glslang;
using namespace spirv_cross;
@@ -203,6 +204,12 @@ bool GLSLPostProcessor::process(const std::string& inputShader, Config const& co
return false;
}
// add texture lod bias
if (config.shaderType == filament::backend::FRAGMENT &&
config.domain == filament::MaterialDomain::SURFACE) {
GLSLTools::textureLodBias(tShader);
}
program.addShader(&tShader);
// Even though we only have a single shader stage, linking is still necessary to finalize
// SPIR-V types