This commit is contained in:
parent
6e9e25b41d
commit
8f30c52a37
|
@ -1100,15 +1100,15 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m
|
|||
state.current_line_width = p_material->line_width;
|
||||
}
|
||||
|
||||
if (state.current_depth_test != (!p_material->shader->spatial.ontop)) {
|
||||
if (p_material->shader->spatial.ontop) {
|
||||
if (state.current_depth_test != (!p_material->shader->spatial.no_depth_test)) {
|
||||
if (p_material->shader->spatial.no_depth_test) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
} else {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
state.current_depth_test = !p_material->shader->spatial.ontop;
|
||||
state.current_depth_test = !p_material->shader->spatial.no_depth_test;
|
||||
}
|
||||
|
||||
if (state.current_depth_draw != p_material->shader->spatial.depth_draw_mode) {
|
||||
|
@ -2195,7 +2195,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
|
|||
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow) {
|
||||
|
||||
bool has_base_alpha = (p_material->shader->spatial.uses_alpha && !p_material->shader->spatial.uses_alpha_scissor) || p_material->shader->spatial.uses_screen_texture;
|
||||
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || p_material->shader->spatial.ontop;
|
||||
bool has_blend_alpha = p_material->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX;
|
||||
bool has_alpha = has_base_alpha || has_blend_alpha;
|
||||
bool shadow = false;
|
||||
|
||||
|
@ -2267,7 +2267,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
|
|||
}
|
||||
|
||||
e->sort_key |= uint64_t(e->material->index) << RenderList::SORT_KEY_MATERIAL_INDEX_SHIFT;
|
||||
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_DEPTH_LAYER_SHIFT;
|
||||
e->sort_key |= uint64_t(e->instance->depth_layer) << RenderList::SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT;
|
||||
|
||||
if (!has_blend_alpha && has_alpha && p_material->shader->spatial.depth_draw_mode == RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
|
||||
|
||||
|
@ -2283,6 +2283,8 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
|
|||
if (e->instance->gi_probe_instances.size()) {
|
||||
e->sort_key |= SORT_KEY_GI_PROBES_FLAG;
|
||||
}
|
||||
|
||||
e->sort_key |= uint64_t(p_material->render_priority + 128) << RenderList::SORT_KEY_PRIORITY_SHIFT;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4282,7 +4284,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
render_list.sort_by_reverse_depth(true);
|
||||
render_list.sort_by_reverse_depth_and_priority(true);
|
||||
|
||||
if (state.directional_light_count == 0) {
|
||||
directional_light = NULL;
|
||||
|
|
|
@ -645,17 +645,25 @@ public:
|
|||
MAX_LIGHTS = 4096,
|
||||
MAX_REFLECTIONS = 1024,
|
||||
|
||||
SORT_KEY_DEPTH_LAYER_SHIFT = 60,
|
||||
SORT_KEY_PRIORITY_SHIFT = 56,
|
||||
SORT_KEY_PRIORITY_MASK = 0xFF,
|
||||
//depth layer for opaque (56-52)
|
||||
SORT_KEY_OPAQUE_DEPTH_LAYER_SHIFT = 52,
|
||||
SORT_KEY_OPAQUE_DEPTH_LAYER_MASK = 0xF,
|
||||
//64 bits unsupported in MSVC
|
||||
#define SORT_KEY_UNSHADED_FLAG (uint64_t(1) << 59)
|
||||
#define SORT_KEY_NO_DIRECTIONAL_FLAG (uint64_t(1) << 58)
|
||||
#define SORT_KEY_GI_PROBES_FLAG (uint64_t(1) << 57)
|
||||
#define SORT_KEY_VERTEX_LIT_FLAG (uint64_t(1) << 56)
|
||||
SORT_KEY_SHADING_SHIFT = 56,
|
||||
#define SORT_KEY_UNSHADED_FLAG (uint64_t(1) << 51)
|
||||
#define SORT_KEY_NO_DIRECTIONAL_FLAG (uint64_t(1) << 50)
|
||||
#define SORT_KEY_GI_PROBES_FLAG (uint64_t(1) << 49)
|
||||
#define SORT_KEY_VERTEX_LIT_FLAG (uint64_t(1) << 48)
|
||||
SORT_KEY_SHADING_SHIFT = 48,
|
||||
SORT_KEY_SHADING_MASK = 15,
|
||||
SORT_KEY_MATERIAL_INDEX_SHIFT = 40,
|
||||
SORT_KEY_GEOMETRY_INDEX_SHIFT = 20,
|
||||
SORT_KEY_GEOMETRY_TYPE_SHIFT = 15,
|
||||
//48-32 material index
|
||||
SORT_KEY_MATERIAL_INDEX_SHIFT = 32,
|
||||
//32-12 geometry index
|
||||
SORT_KEY_GEOMETRY_INDEX_SHIFT = 12,
|
||||
//bits 12-8 geometry type
|
||||
SORT_KEY_GEOMETRY_TYPE_SHIFT = 8,
|
||||
//bits 0-7 for flags
|
||||
SORT_KEY_CULL_DISABLED_FLAG = 4,
|
||||
SORT_KEY_SKELETON_FLAG = 2,
|
||||
SORT_KEY_MIRROR_FLAG = 1
|
||||
|
@ -721,16 +729,22 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
struct SortByReverseDepth {
|
||||
struct SortByReverseDepthAndPriority {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const {
|
||||
return A->instance->depth > B->instance->depth;
|
||||
uint32_t layer_A = uint32_t(A->sort_key >> SORT_KEY_PRIORITY_SHIFT);
|
||||
uint32_t layer_B = uint32_t(B->sort_key >> SORT_KEY_PRIORITY_SHIFT);
|
||||
if (layer_A == layer_B) {
|
||||
return A->instance->depth > B->instance->depth;
|
||||
} else {
|
||||
return layer_A < layer_B;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void sort_by_reverse_depth(bool p_alpha) { //used for alpha
|
||||
void sort_by_reverse_depth_and_priority(bool p_alpha) { //used for alpha
|
||||
|
||||
SortArray<Element *, SortByReverseDepth> sorter;
|
||||
SortArray<Element *, SortByReverseDepthAndPriority> sorter;
|
||||
if (p_alpha) {
|
||||
sorter.sort(&elements[max_elements - alpha_element_count], alpha_element_count);
|
||||
} else {
|
||||
|
|
|
@ -1599,7 +1599,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
|||
p_shader->spatial.uses_alpha_scissor = false;
|
||||
p_shader->spatial.uses_discard = false;
|
||||
p_shader->spatial.unshaded = false;
|
||||
p_shader->spatial.ontop = false;
|
||||
p_shader->spatial.no_depth_test = false;
|
||||
p_shader->spatial.uses_sss = false;
|
||||
p_shader->spatial.uses_vertex_lighting = false;
|
||||
p_shader->spatial.uses_screen_texture = false;
|
||||
|
@ -1621,7 +1621,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
|
|||
shaders.actions_scene.render_mode_values["cull_disabled"] = Pair<int *, int>(&p_shader->spatial.cull_mode, Shader::Spatial::CULL_MODE_DISABLED);
|
||||
|
||||
shaders.actions_scene.render_mode_flags["unshaded"] = &p_shader->spatial.unshaded;
|
||||
shaders.actions_scene.render_mode_flags["ontop"] = &p_shader->spatial.ontop;
|
||||
shaders.actions_scene.render_mode_flags["depth_test_disable"] = &p_shader->spatial.no_depth_test;
|
||||
|
||||
shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
|
||||
|
||||
|
@ -1948,6 +1948,17 @@ void RasterizerStorageGLES3::material_remove_instance_owner(RID p_material, Rast
|
|||
}
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::material_set_render_priority(RID p_material, int priority) {
|
||||
|
||||
ERR_FAIL_COND(priority < VS::MATERIAL_RENDER_PRIORITY_MIN);
|
||||
ERR_FAIL_COND(priority > VS::MATERIAL_RENDER_PRIORITY_MAX);
|
||||
|
||||
Material *material = material_owner.get(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
|
||||
material->render_priority = priority;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataType type, const Variant &value, uint8_t *data, bool p_linear_color) {
|
||||
switch (type) {
|
||||
case ShaderLanguage::TYPE_BOOL: {
|
||||
|
|
|
@ -444,7 +444,7 @@ public:
|
|||
bool uses_alpha;
|
||||
bool uses_alpha_scissor;
|
||||
bool unshaded;
|
||||
bool ontop;
|
||||
bool no_depth_test;
|
||||
bool uses_vertex;
|
||||
bool uses_discard;
|
||||
bool uses_sss;
|
||||
|
@ -502,6 +502,7 @@ public:
|
|||
SelfList<Material> dirty_list;
|
||||
Vector<RID> textures;
|
||||
float line_width;
|
||||
int render_priority;
|
||||
|
||||
RID next_pass;
|
||||
|
||||
|
@ -523,6 +524,7 @@ public:
|
|||
ubo_id = 0;
|
||||
ubo_size = 0;
|
||||
last_pass = 0;
|
||||
render_priority = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -550,6 +552,8 @@ public:
|
|||
virtual void material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance);
|
||||
virtual void material_remove_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance);
|
||||
|
||||
virtual void material_set_render_priority(RID p_material, int priority);
|
||||
|
||||
void _update_material(Material *material);
|
||||
|
||||
void update_dirty_materials();
|
||||
|
|
|
@ -3505,7 +3505,7 @@ void SpatialEditor::_init_indicators() {
|
|||
|
||||
gizmo_hl = Ref<SpatialMaterial>(memnew(SpatialMaterial));
|
||||
gizmo_hl->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
gizmo_hl->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
gizmo_hl->set_on_top_of_alpha();
|
||||
gizmo_hl->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
gizmo_hl->set_albedo(Color(1, 1, 1, gizmo_alph + 0.2f));
|
||||
gizmo_hl->set_cull_mode(SpatialMaterial::CULL_DISABLED);
|
||||
|
@ -3518,7 +3518,7 @@ void SpatialEditor::_init_indicators() {
|
|||
|
||||
Ref<SpatialMaterial> mat = memnew(SpatialMaterial);
|
||||
mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
mat->set_on_top_of_alpha();
|
||||
mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
Color col;
|
||||
col[i] = 1.0;
|
||||
|
@ -3613,7 +3613,7 @@ void SpatialEditor::_init_indicators() {
|
|||
|
||||
Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial);
|
||||
plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
plane_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
plane_mat->set_on_top_of_alpha();
|
||||
plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED);
|
||||
Color col;
|
||||
|
|
|
@ -580,7 +580,7 @@ Ref<SpatialMaterial> EditorSpatialGizmo::create_material(const String &p_name, c
|
|||
}
|
||||
|
||||
if (p_on_top && is_selected()) {
|
||||
line_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
line_material->set_on_top_of_alpha();
|
||||
}
|
||||
|
||||
line_material->set_albedo(color);
|
||||
|
@ -624,7 +624,7 @@ Ref<SpatialMaterial> EditorSpatialGizmo::create_icon_material(const String &p_na
|
|||
icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
|
||||
|
||||
if (p_on_top && is_selected()) {
|
||||
icon->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
icon->set_on_top_of_alpha();
|
||||
}
|
||||
|
||||
SpatialEditorGizmos::singleton->material_cache[name] = icon;
|
||||
|
@ -3411,7 +3411,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
|
||||
handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
|
||||
handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
handle_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
handle_material->set_on_top_of_alpha();
|
||||
handle_material->set_albedo(Color(0.8, 0.8, 0.8));
|
||||
handle_material_billboard = handle_material->duplicate();
|
||||
handle_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
|
||||
|
@ -3426,11 +3426,11 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
handle2_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
handle2_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
handle2_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
|
||||
handle2_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
handle2_material->set_on_top_of_alpha();
|
||||
handle2_material_billboard = handle2_material->duplicate();
|
||||
handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
|
||||
handle2_material_billboard->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED);
|
||||
handle2_material_billboard->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
handle2_material_billboard->set_on_top_of_alpha();
|
||||
|
||||
EDITOR_DEF("editors/3d_gizmos/gizmo_colors/light", Color(1, 1, 0.2));
|
||||
EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1));
|
||||
|
@ -3490,7 +3490,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
|
|||
skeleton_material = create_line_material(Color(0.6, 1.0, 0.3));
|
||||
skeleton_material->set_cull_mode(SpatialMaterial::CULL_DISABLED);
|
||||
skeleton_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
skeleton_material->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
skeleton_material->set_on_top_of_alpha();
|
||||
skeleton_material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED);
|
||||
|
||||
//position 3D Shared mesh
|
||||
|
|
|
@ -1159,14 +1159,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
|
|||
|
||||
outer_mat.instance();
|
||||
outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
|
||||
outer_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
outer_mat->set_on_top_of_alpha();
|
||||
outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
outer_mat->set_line_width(3.0);
|
||||
outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
|
||||
selection_floor_mat.instance();
|
||||
selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1));
|
||||
selection_floor_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
|
||||
selection_floor_mat->set_on_top_of_alpha();
|
||||
selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
|
||||
selection_floor_mat->set_line_width(3.0);
|
||||
//selection_floor_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
|
||||
|
|
|
@ -48,6 +48,19 @@ Ref<Material> Material::get_next_pass() const {
|
|||
return next_pass;
|
||||
}
|
||||
|
||||
void Material::set_render_priority(int p_priority) {
|
||||
|
||||
ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN);
|
||||
ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX);
|
||||
render_priority = p_priority;
|
||||
VS::get_singleton()->material_set_render_priority(material, p_priority);
|
||||
}
|
||||
|
||||
int Material::get_render_priority() const {
|
||||
|
||||
return render_priority;
|
||||
}
|
||||
|
||||
RID Material::get_rid() const {
|
||||
|
||||
return material;
|
||||
|
@ -58,12 +71,20 @@ void Material::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass"), &Material::set_next_pass);
|
||||
ClassDB::bind_method(D_METHOD("get_next_pass"), &Material::get_next_pass);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_render_priority", "priority"), &Material::set_render_priority);
|
||||
ClassDB::bind_method(D_METHOD("get_render_priority"), &Material::get_render_priority);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
|
||||
|
||||
BIND_CONSTANT(RENDER_PRIORITY_MAX);
|
||||
BIND_CONSTANT(RENDER_PRIORITY_MIN);
|
||||
}
|
||||
|
||||
Material::Material() {
|
||||
|
||||
material = VisualServer::get_singleton()->material_create();
|
||||
render_priority = 0;
|
||||
}
|
||||
|
||||
Material::~Material() {
|
||||
|
@ -347,8 +368,8 @@ void SpatialMaterial::_update_shader() {
|
|||
if (flags[FLAG_UNSHADED]) {
|
||||
code += ",unshaded";
|
||||
}
|
||||
if (flags[FLAG_ONTOP]) {
|
||||
code += ",ontop";
|
||||
if (flags[FLAG_DISABLE_DEPTH_TEST]) {
|
||||
code += ",depth_test_disable";
|
||||
}
|
||||
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
|
||||
code += ",vertex_lighting";
|
||||
|
@ -1459,6 +1480,12 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent,
|
|||
return materials_for_2d[version]->get_rid();
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_on_top_of_alpha() {
|
||||
set_feature(FEATURE_TRANSPARENT, true);
|
||||
set_render_priority(RENDER_PRIORITY_MAX);
|
||||
set_flag(FLAG_DISABLE_DEPTH_TEST, true);
|
||||
}
|
||||
|
||||
void SpatialMaterial::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
|
||||
|
@ -1606,7 +1633,7 @@ void SpatialMaterial::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_vertex_lighting"), "set_flag", "get_flag", FLAG_USE_VERTEX_LIGHTING);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_on_top"), "set_flag", "get_flag", FLAG_ONTOP);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_no_depth_test"), "set_flag", "get_flag", FLAG_DISABLE_DEPTH_TEST);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE);
|
||||
ADD_GROUP("Vertex Color", "vertex_color");
|
||||
|
@ -1768,7 +1795,7 @@ void SpatialMaterial::_bind_methods() {
|
|||
|
||||
BIND_ENUM_CONSTANT(FLAG_UNSHADED);
|
||||
BIND_ENUM_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
|
||||
BIND_ENUM_CONSTANT(FLAG_ONTOP);
|
||||
BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST);
|
||||
BIND_ENUM_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
|
||||
BIND_ENUM_CONSTANT(FLAG_SRGB_VERTEX_COLOR);
|
||||
BIND_ENUM_CONSTANT(FLAG_USE_POINT_SIZE);
|
||||
|
|
|
@ -48,15 +48,23 @@ class Material : public Resource {
|
|||
|
||||
RID material;
|
||||
Ref<Material> next_pass;
|
||||
int render_priority;
|
||||
|
||||
protected:
|
||||
_FORCE_INLINE_ RID _get_material() const { return material; }
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum {
|
||||
RENDER_PRIORITY_MAX = VS::MATERIAL_RENDER_PRIORITY_MAX,
|
||||
RENDER_PRIORITY_MIN = VS::MATERIAL_RENDER_PRIORITY_MIN,
|
||||
};
|
||||
void set_next_pass(const Ref<Material> &p_pass);
|
||||
Ref<Material> get_next_pass() const;
|
||||
|
||||
void set_render_priority(int p_priority);
|
||||
int get_render_priority() const;
|
||||
|
||||
virtual RID get_rid() const;
|
||||
Material();
|
||||
virtual ~Material();
|
||||
|
@ -156,7 +164,7 @@ public:
|
|||
enum Flags {
|
||||
FLAG_UNSHADED,
|
||||
FLAG_USE_VERTEX_LIGHTING,
|
||||
FLAG_ONTOP,
|
||||
FLAG_DISABLE_DEPTH_TEST,
|
||||
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
||||
FLAG_SRGB_VERTEX_COLOR,
|
||||
FLAG_USE_POINT_SIZE,
|
||||
|
@ -511,6 +519,8 @@ public:
|
|||
void set_alpha_scissor_threshold(float p_treshold);
|
||||
float get_alpha_scissor_threshold() const;
|
||||
|
||||
void set_on_top_of_alpha();
|
||||
|
||||
void set_metallic_texture_channel(TextureChannel p_channel);
|
||||
TextureChannel get_metallic_texture_channel() const;
|
||||
void set_roughness_texture_channel(TextureChannel p_channel);
|
||||
|
|
|
@ -213,6 +213,7 @@ public:
|
|||
|
||||
virtual RID material_create() = 0;
|
||||
|
||||
virtual void material_set_render_priority(RID p_material, int priority) = 0;
|
||||
virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
|
||||
virtual RID material_get_shader(RID p_shader_material) const = 0;
|
||||
|
||||
|
|
|
@ -128,12 +128,13 @@ ShaderTypes::ShaderTypes() {
|
|||
shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_never");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_draw_alpha_prepass");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("depth_test_disable");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_front");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_back");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("cull_disabled");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("unshaded");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("ontop");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_lambert");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert");
|
||||
|
|
|
@ -690,6 +690,7 @@ public:
|
|||
BIND3(material_set_param, RID, const StringName &, const Variant &)
|
||||
BIND2RC(Variant, material_get_param, RID, const StringName &)
|
||||
|
||||
BIND2(material_set_render_priority, RID, int)
|
||||
BIND2(material_set_line_width, RID, float)
|
||||
BIND2(material_set_next_pass, RID, RID)
|
||||
|
||||
|
|
|
@ -1434,7 +1434,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam
|
|||
}
|
||||
|
||||
ins->depth = near_plane.distance_to(ins->transform.origin);
|
||||
ins->depth_layer = CLAMP(int(ins->depth * 8 / z_far), 0, 7);
|
||||
ins->depth_layer = CLAMP(int(ins->depth * 16 / z_far), 0, 15);
|
||||
}
|
||||
|
||||
if (!keep) {
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
FUNC3(material_set_param, RID, const StringName &, const Variant &)
|
||||
FUNC2RC(Variant, material_get_param, RID, const StringName &)
|
||||
|
||||
FUNC2(material_set_render_priority, RID, int)
|
||||
FUNC2(material_set_line_width, RID, float)
|
||||
FUNC2(material_set_next_pass, RID, RID)
|
||||
|
||||
|
|
|
@ -166,6 +166,11 @@ public:
|
|||
|
||||
/* COMMON MATERIAL API */
|
||||
|
||||
enum {
|
||||
MATERIAL_RENDER_PRIORITY_MIN = -128,
|
||||
MATERIAL_RENDER_PRIORITY_MAX = 127,
|
||||
|
||||
};
|
||||
virtual RID material_create() = 0;
|
||||
|
||||
virtual void material_set_shader(RID p_shader_material, RID p_shader) = 0;
|
||||
|
@ -174,6 +179,8 @@ public:
|
|||
virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0;
|
||||
virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
|
||||
|
||||
virtual void material_set_render_priority(RID p_material, int priority) = 0;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width) = 0;
|
||||
virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue