get rid of depth_main.vs
It's functionality is now handled in main.vs which, hopefully will be less error prone.
This commit is contained in:
committed by
Mathias Agopian
parent
10e7e7727a
commit
109c86aaf7
@@ -286,9 +286,8 @@ utils::io::sstream& CodeGenerator::generateOutput(utils::io::sstream& out, Shade
|
||||
|
||||
|
||||
io::sstream& CodeGenerator::generateDepthShaderMain(io::sstream& out, ShaderType type) const {
|
||||
if (type == ShaderType::VERTEX) {
|
||||
out << SHADERS_DEPTH_MAIN_VS_DATA;
|
||||
} else if (type == ShaderType::FRAGMENT) {
|
||||
assert(type != ShaderType::VERTEX);
|
||||
if (type == ShaderType::FRAGMENT) {
|
||||
out << SHADERS_DEPTH_MAIN_FS_DATA;
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -191,6 +191,10 @@ std::string ShaderGenerator::createVertexProgram(filament::backend::ShaderModel
|
||||
|
||||
const bool litVariants = lit || material.hasShadowMultiplier;
|
||||
|
||||
const bool useOptimizedDepthVertexShader =
|
||||
filament::Variant::isValidDepthVariant(variantKey) && mIsMaterialVertexShaderEmpty;
|
||||
|
||||
cg.generateDefine(vs, "USE_OPTIMIZED_DEPTH_VERTEX_SHADER", useOptimizedDepthVertexShader);
|
||||
cg.generateDefine(vs, "HAS_DIRECTIONAL_LIGHTING", litVariants && variant.hasDirectionalLighting());
|
||||
cg.generateDefine(vs, "HAS_DYNAMIC_LIGHTING", litVariants && variant.hasDynamicLighting());
|
||||
cg.generateDefine(vs, "HAS_SHADOWING", litVariants && variant.hasShadowReceiver());
|
||||
@@ -247,16 +251,9 @@ std::string ShaderGenerator::createVertexProgram(filament::backend::ShaderModel
|
||||
cg.generateGetters(vs, ShaderType::VERTEX);
|
||||
cg.generateCommonMaterial(vs, ShaderType::VERTEX);
|
||||
|
||||
const bool useOptimizedDepthVertexShader = mIsMaterialVertexShaderEmpty;
|
||||
if (filament::Variant::isValidDepthVariant(variantKey) && useOptimizedDepthVertexShader) {
|
||||
// these variants are special and are treated as DEPTH variants. Filament will never
|
||||
// request that variant for the color pass.
|
||||
cg.generateDepthShaderMain(vs, ShaderType::VERTEX);
|
||||
} else {
|
||||
// main entry point
|
||||
appendShader(vs, mMaterialVertexCode, mMaterialVertexLineOffset);
|
||||
cg.generateShaderMain(vs, ShaderType::VERTEX);
|
||||
}
|
||||
// main entry point
|
||||
appendShader(vs, mMaterialVertexCode, mMaterialVertexLineOffset);
|
||||
cg.generateShaderMain(vs, ShaderType::VERTEX);
|
||||
|
||||
cg.generateEpilog(vs);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ set(SHADERS
|
||||
src/common_shadowing.fs
|
||||
src/common_types.fs
|
||||
src/depth_main.fs
|
||||
src/depth_main.vs
|
||||
src/fog.fs
|
||||
src/getters.fs
|
||||
src/getters.vs
|
||||
|
||||
@@ -37,7 +37,7 @@ void main() {
|
||||
#endif
|
||||
|
||||
#if defined(HAS_VSM)
|
||||
// interpolated depth is stored in vertex_worldPosition.w (see depth_main.vs / main.vs)
|
||||
// interpolated depth is stored in vertex_worldPosition.w (see main.vs)
|
||||
highp float depth = exp(vertex_worldPosition.w);
|
||||
|
||||
// computes the moments
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
/*
|
||||
* This is the main vertex shader of surface materials. It can be invoked with
|
||||
* USE_OPTIMIZED_DEPTH_VERTEX_SHADER defined, and in this case we are guaranteed that the
|
||||
* DEPTH variant is active *AND* there is no custom vertex shader (i.e.: materialVertex() is
|
||||
* empty).
|
||||
* We can use this to remove all code that doesn't participate in the depth computation.
|
||||
*/
|
||||
|
||||
void main() {
|
||||
// Initialize the inputs to sensible default values, see material_inputs.vs
|
||||
#if defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER)
|
||||
|
||||
// In USE_OPTIMIZED_DEPTH_VERTEX_SHADER mode, we can even skip this if we're already in
|
||||
// VERTEX_DOMAIN_DEVICE and we don't have VSM.
|
||||
#if !defined(VERTEX_DOMAIN_DEVICE) || defined(HAS_VSM)
|
||||
// Run initMaterialVertex to compute material.worldPosition.
|
||||
MaterialVertexInputs material;
|
||||
initMaterialVertex(material);
|
||||
#endif
|
||||
|
||||
// materialVertex() is guaranteed to be empty here, but we keep it to workaround some problem
|
||||
// in NVIDA drivers related to depth invariance.
|
||||
materialVertex(material);
|
||||
|
||||
#else // defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER)
|
||||
|
||||
MaterialVertexInputs material;
|
||||
initMaterialVertex(material);
|
||||
|
||||
@@ -94,6 +118,9 @@ void main() {
|
||||
frameUniforms.lightDirection, frameUniforms.shadowBias.y, getLightFromWorldMatrix());
|
||||
#endif
|
||||
|
||||
#endif // !defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER)
|
||||
|
||||
|
||||
#if defined(VERTEX_DOMAIN_DEVICE)
|
||||
// The other vertex domains are handled in initMaterialVertex()->computeWorldPosition()
|
||||
gl_Position = getPosition();
|
||||
@@ -101,9 +128,11 @@ void main() {
|
||||
gl_Position = getClipFromWorldMatrix() * getWorldPosition(material);
|
||||
#endif
|
||||
|
||||
#if !defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER)
|
||||
#if defined(MATERIAL_HAS_CLIP_SPACE_TRANSFORM)
|
||||
gl_Position = getClipSpaceTransform(material) * gl_Position;
|
||||
#endif
|
||||
#endif // !USE_OPTIMIZED_DEPTH_VERTEX_SHADER
|
||||
|
||||
#if defined(VERTEX_DOMAIN_DEVICE)
|
||||
// GL convention to inverted DX convention (must happen after clipSpaceTransform)
|
||||
|
||||
Reference in New Issue
Block a user