Force vertex shading in SpatialMaterial when used

This commit is contained in:
clayjohn 2020-10-03 15:29:00 -07:00
parent 48d7eff3e3
commit 0445531ced
2 changed files with 8 additions and 2 deletions

View file

@ -31,6 +31,7 @@
#include "material.h"
#include "core/engine.h"
#include "core/project_settings.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
@ -473,7 +474,7 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_DISABLE_DEPTH_TEST]) {
code += ",depth_test_disable";
}
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
if (flags[FLAG_USE_VERTEX_LIGHTING] || force_vertex_shading) {
code += ",vertex_lighting";
}
if (flags[FLAG_TRIPLANAR_USE_WORLD] && (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR])) {
@ -623,7 +624,7 @@ void SpatialMaterial::_update_shader() {
code += "\tPOINT_SIZE=point_size;\n";
}
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
if (flags[FLAG_USE_VERTEX_LIGHTING] || force_vertex_shading) {
code += "\tROUGHNESS=roughness;\n";
}
@ -2300,6 +2301,9 @@ SpatialMaterial::SpatialMaterial() :
for (int i = 0; i < FLAG_MAX; i++) {
flags[i] = false;
}
force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading");
diffuse_mode = DIFFUSE_BURLEY;
specular_mode = SPECULAR_SCHLICK_GGX;

View file

@ -434,6 +434,8 @@ private:
Ref<Texture> textures[TEXTURE_MAX];
bool force_vertex_shading = false;
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
static const int MAX_MATERIALS_FOR_2D = 128;