summaryrefslogtreecommitdiff
path: root/scene/resources/material.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/material.h')
-rw-r--r--scene/resources/material.h425
1 files changed, 277 insertions, 148 deletions
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 8e66011bec..80e5e94466 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,15 +31,14 @@
#ifndef MATERIAL_H
#define MATERIAL_H
-#include "core/resource.h"
-#include "core/self_list.h"
+#include "core/io/resource.h"
+#include "core/templates/self_list.h"
#include "scene/resources/shader.h"
#include "scene/resources/texture.h"
-#include "servers/visual/shader_language.h"
-#include "servers/visual_server.h"
+#include "servers/rendering/shader_language.h"
+#include "servers/rendering_server.h"
class Material : public Resource {
-
GDCLASS(Material, Resource);
RES_BASE_EXTENSION("material")
OBJ_SAVE_TYPE(Material);
@@ -48,17 +47,19 @@ class Material : public Resource {
Ref<Material> next_pass;
int render_priority;
+ void inspect_native_shader_code();
+
protected:
_FORCE_INLINE_ RID _get_material() const { return material; }
static void _bind_methods();
virtual bool _can_do_next_pass() const { return false; }
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
public:
enum {
- RENDER_PRIORITY_MAX = VS::MATERIAL_RENDER_PRIORITY_MAX,
- RENDER_PRIORITY_MIN = VS::MATERIAL_RENDER_PRIORITY_MIN,
+ RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX,
+ RENDER_PRIORITY_MIN = RS::MATERIAL_RENDER_PRIORITY_MIN,
};
void set_next_pass(const Ref<Material> &p_pass);
Ref<Material> get_next_pass() const;
@@ -66,7 +67,8 @@ public:
void set_render_priority(int p_priority);
int get_render_priority() const;
- virtual RID get_rid() const;
+ virtual RID get_rid() const override;
+ virtual RID get_shader_rid() const = 0;
virtual Shader::Mode get_shader_mode() const = 0;
Material();
@@ -74,7 +76,6 @@ public:
};
class ShaderMaterial : public Material {
-
GDCLASS(ShaderMaterial, Material);
Ref<Shader> shader;
@@ -87,9 +88,9 @@ protected:
static void _bind_methods();
- void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
+ void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
- virtual bool _can_do_next_pass() const;
+ virtual bool _can_do_next_pass() const override;
void _shader_changed();
@@ -100,15 +101,18 @@ public:
void set_shader_param(const StringName &p_param, const Variant &p_value);
Variant get_shader_param(const StringName &p_param) const;
- virtual Shader::Mode get_shader_mode() const;
+ virtual Shader::Mode get_shader_mode() const override;
+
+ virtual RID get_shader_rid() const override;
ShaderMaterial();
~ShaderMaterial();
};
-class SpatialMaterial : public Material {
+class StandardMaterial3D;
- GDCLASS(SpatialMaterial, Material);
+class BaseMaterial3D : public Material {
+ GDCLASS(BaseMaterial3D, Material);
public:
enum TextureParam {
@@ -121,33 +125,69 @@ public:
TEXTURE_CLEARCOAT,
TEXTURE_FLOWMAP,
TEXTURE_AMBIENT_OCCLUSION,
- TEXTURE_DEPTH,
+ TEXTURE_HEIGHTMAP,
TEXTURE_SUBSURFACE_SCATTERING,
- TEXTURE_TRANSMISSION,
+ TEXTURE_SUBSURFACE_TRANSMITTANCE,
+ TEXTURE_BACKLIGHT,
TEXTURE_REFRACTION,
TEXTURE_DETAIL_MASK,
TEXTURE_DETAIL_ALBEDO,
TEXTURE_DETAIL_NORMAL,
+ TEXTURE_ORM,
TEXTURE_MAX
};
+ enum TextureFilter {
+ TEXTURE_FILTER_NEAREST,
+ TEXTURE_FILTER_LINEAR,
+ TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
+ TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
+ TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC,
+ TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC,
+ TEXTURE_FILTER_MAX
+ };
+
enum DetailUV {
DETAIL_UV_1,
- DETAIL_UV_2
+ DETAIL_UV_2,
+ DETAIL_UV_MAX
+ };
+
+ enum Transparency {
+ TRANSPARENCY_DISABLED,
+ TRANSPARENCY_ALPHA,
+ TRANSPARENCY_ALPHA_SCISSOR,
+ TRANSPARENCY_ALPHA_HASH,
+ TRANSPARENCY_ALPHA_DEPTH_PRE_PASS,
+ TRANSPARENCY_MAX,
+ };
+
+ enum AlphaAntiAliasing {
+ ALPHA_ANTIALIASING_OFF,
+ ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE,
+ ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE,
+ ALPHA_ANTIALIASING_MAX
+ };
+
+ enum ShadingMode {
+ SHADING_MODE_UNSHADED,
+ SHADING_MODE_PER_PIXEL,
+ SHADING_MODE_PER_VERTEX,
+ SHADING_MODE_MAX
};
enum Feature {
- FEATURE_TRANSPARENT,
FEATURE_EMISSION,
FEATURE_NORMAL_MAPPING,
FEATURE_RIM,
FEATURE_CLEARCOAT,
FEATURE_ANISOTROPY,
FEATURE_AMBIENT_OCCLUSION,
- FEATURE_DEPTH_MAPPING,
- FEATURE_SUBSURACE_SCATTERING,
- FEATURE_TRANSMISSION,
+ FEATURE_HEIGHT_MAPPING,
+ FEATURE_SUBSURFACE_SCATTERING,
+ FEATURE_SUBSURFACE_TRANSMITTANCE,
+ FEATURE_BACKLIGHT,
FEATURE_REFRACTION,
FEATURE_DETAIL,
FEATURE_MAX
@@ -158,25 +198,24 @@ public:
BLEND_MODE_ADD,
BLEND_MODE_SUB,
BLEND_MODE_MUL,
+ BLEND_MODE_MAX
};
enum DepthDrawMode {
DEPTH_DRAW_OPAQUE_ONLY,
DEPTH_DRAW_ALWAYS,
DEPTH_DRAW_DISABLED,
- DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
-
+ DEPTH_DRAW_MAX
};
enum CullMode {
CULL_BACK,
CULL_FRONT,
- CULL_DISABLED
+ CULL_DISABLED,
+ CULL_MAX
};
enum Flags {
- FLAG_UNSHADED,
- FLAG_USE_VERTEX_LIGHTING,
FLAG_DISABLE_DEPTH_TEST,
FLAG_ALBEDO_FROM_VERTEX_COLOR,
FLAG_SRGB_VERTEX_COLOR,
@@ -185,15 +224,18 @@ public:
FLAG_BILLBOARD_KEEP_SCALE,
FLAG_UV1_USE_TRIPLANAR,
FLAG_UV2_USE_TRIPLANAR,
- FLAG_TRIPLANAR_USE_WORLD,
+ FLAG_UV1_USE_WORLD_TRIPLANAR,
+ FLAG_UV2_USE_WORLD_TRIPLANAR,
FLAG_AO_ON_UV2,
FLAG_EMISSION_ON_UV2,
- FLAG_USE_ALPHA_SCISSOR,
FLAG_ALBEDO_TEXTURE_FORCE_SRGB,
FLAG_DONT_RECEIVE_SHADOWS,
- FLAG_ENSURE_CORRECT_NORMALS,
FLAG_DISABLE_AMBIENT_LIGHT,
FLAG_USE_SHADOW_TO_OPACITY,
+ FLAG_USE_TEXTURE_REPEAT,
+ FLAG_INVERT_HEIGHTMAP,
+ FLAG_SUBSURFACE_MODE_SKIN,
+ FLAG_PARTICLE_TRAILS_MODE,
FLAG_MAX
};
@@ -201,8 +243,8 @@ public:
DIFFUSE_BURLEY,
DIFFUSE_LAMBERT,
DIFFUSE_LAMBERT_WRAP,
- DIFFUSE_OREN_NAYAR,
DIFFUSE_TOON,
+ DIFFUSE_MAX
};
enum SpecularMode {
@@ -211,6 +253,7 @@ public:
SPECULAR_PHONG,
SPECULAR_TOON,
SPECULAR_DISABLED,
+ SPECULAR_MAX
};
enum BillboardMode {
@@ -218,6 +261,7 @@ public:
BILLBOARD_ENABLED,
BILLBOARD_FIXED_Y,
BILLBOARD_PARTICLES,
+ BILLBOARD_MAX
};
enum TextureChannel {
@@ -225,12 +269,14 @@ public:
TEXTURE_CHANNEL_GREEN,
TEXTURE_CHANNEL_BLUE,
TEXTURE_CHANNEL_ALPHA,
- TEXTURE_CHANNEL_GRAYSCALE
+ TEXTURE_CHANNEL_GRAYSCALE,
+ TEXTURE_CHANNEL_MAX
};
enum EmissionOperator {
EMISSION_OP_ADD,
- EMISSION_OP_MULTIPLY
+ EMISSION_OP_MULTIPLY,
+ EMISSION_OP_MAX
};
enum DistanceFadeMode {
@@ -238,42 +284,52 @@ public:
DISTANCE_FADE_PIXEL_ALPHA,
DISTANCE_FADE_PIXEL_DITHER,
DISTANCE_FADE_OBJECT_DITHER,
+ DISTANCE_FADE_MAX
};
private:
- union MaterialKey {
-
- struct {
- uint64_t feature_mask : 12;
- uint64_t detail_uv : 1;
- uint64_t blend_mode : 2;
- uint64_t depth_draw_mode : 2;
- uint64_t cull_mode : 2;
- uint64_t flags : 19;
- uint64_t detail_blend_mode : 2;
- uint64_t diffuse_mode : 3;
- uint64_t specular_mode : 3;
- uint64_t invalid_key : 1;
- uint64_t deep_parallax : 1;
- uint64_t billboard_mode : 2;
- uint64_t grow : 1;
- uint64_t proximity_fade : 1;
- uint64_t distance_fade : 2;
- uint64_t emission_op : 1;
- uint64_t texture_metallic : 1;
- uint64_t texture_roughness : 1;
- };
-
- uint64_t key;
+ struct MaterialKey {
+ // enum values
+ uint64_t texture_filter : get_num_bits(TEXTURE_FILTER_MAX - 1);
+ uint64_t detail_uv : get_num_bits(DETAIL_UV_MAX - 1);
+ uint64_t transparency : get_num_bits(TRANSPARENCY_MAX - 1);
+ uint64_t alpha_antialiasing_mode : get_num_bits(ALPHA_ANTIALIASING_MAX - 1);
+ uint64_t shading_mode : get_num_bits(SHADING_MODE_MAX - 1);
+ uint64_t blend_mode : get_num_bits(BLEND_MODE_MAX - 1);
+ uint64_t depth_draw_mode : get_num_bits(DEPTH_DRAW_MAX - 1);
+ uint64_t cull_mode : get_num_bits(CULL_MAX - 1);
+ uint64_t diffuse_mode : get_num_bits(DIFFUSE_MAX - 1);
+ uint64_t specular_mode : get_num_bits(SPECULAR_MAX - 1);
+ uint64_t billboard_mode : get_num_bits(BILLBOARD_MAX - 1);
+ uint64_t detail_blend_mode : get_num_bits(BLEND_MODE_MAX - 1);
+ uint64_t roughness_channel : get_num_bits(TEXTURE_CHANNEL_MAX - 1);
+ uint64_t emission_op : get_num_bits(EMISSION_OP_MAX - 1);
+ uint64_t distance_fade : get_num_bits(DISTANCE_FADE_MAX - 1);
+ // booleans
+ uint64_t deep_parallax : 1;
+ uint64_t grow : 1;
+ uint64_t proximity_fade : 1;
+
+ // flag bitfield
+ uint32_t feature_mask;
+ uint32_t flags;
+
+ MaterialKey() {
+ memset(this, 0, sizeof(MaterialKey));
+ }
+
+ bool operator==(const MaterialKey &p_key) const {
+ return memcmp(this, &p_key, sizeof(MaterialKey)) == 0;
+ }
bool operator<(const MaterialKey &p_key) const {
- return key < p_key.key;
+ return memcmp(this, &p_key, sizeof(MaterialKey)) < 0;
}
};
struct ShaderData {
RID shader;
- int users;
+ int users = 0;
};
static Map<MaterialKey, ShaderData> shader_map;
@@ -281,34 +337,38 @@ private:
MaterialKey current_key;
_FORCE_INLINE_ MaterialKey _compute_key() const {
-
MaterialKey mk;
- mk.key = 0;
- for (int i = 0; i < FEATURE_MAX; i++) {
- if (features[i]) {
- mk.feature_mask |= ((uint64_t)1 << i);
- }
- }
+
mk.detail_uv = detail_uv;
mk.blend_mode = blend_mode;
mk.depth_draw_mode = depth_draw_mode;
mk.cull_mode = cull_mode;
- for (int i = 0; i < FLAG_MAX; i++) {
- if (flags[i]) {
- mk.flags |= ((uint64_t)1 << i);
- }
- }
+ mk.texture_filter = texture_filter;
+ mk.transparency = transparency;
+ mk.shading_mode = shading_mode;
+ mk.roughness_channel = roughness_texture_channel;
mk.detail_blend_mode = detail_blend_mode;
mk.diffuse_mode = diffuse_mode;
mk.specular_mode = specular_mode;
mk.billboard_mode = billboard_mode;
- mk.deep_parallax = deep_parallax ? 1 : 0;
+ mk.deep_parallax = deep_parallax;
mk.grow = grow_enabled;
mk.proximity_fade = proximity_fade_enabled;
mk.distance_fade = distance_fade;
mk.emission_op = emission_op;
- mk.texture_metallic = textures[TEXTURE_METALLIC].is_valid() ? 1 : 0;
- mk.texture_roughness = textures[TEXTURE_ROUGHNESS].is_valid() ? 1 : 0;
+ mk.alpha_antialiasing_mode = alpha_antialiasing_mode;
+
+ for (int i = 0; i < FEATURE_MAX; i++) {
+ if (features[i]) {
+ mk.feature_mask |= ((uint64_t)1 << i);
+ }
+ }
+
+ for (int i = 0; i < FLAG_MAX; i++) {
+ if (flags[i]) {
+ mk.flags |= ((uint64_t)1 << i);
+ }
+ }
return mk;
}
@@ -326,9 +386,12 @@ private:
StringName clearcoat;
StringName clearcoat_gloss;
StringName anisotropy;
- StringName depth_scale;
+ StringName heightmap_scale;
StringName subsurface_scattering_strength;
- StringName transmission;
+ StringName transmittance_color;
+ StringName transmittance_depth;
+ StringName transmittance_boost;
+ StringName backlight;
StringName refraction;
StringName point_size;
StringName uv1_scale;
@@ -338,9 +401,9 @@ private:
StringName particles_anim_h_frames;
StringName particles_anim_v_frames;
StringName particles_anim_loop;
- StringName depth_min_layers;
- StringName depth_max_layers;
- StringName depth_flip;
+ StringName heightmap_min_layers;
+ StringName heightmap_max_layers;
+ StringName heightmap_flip;
StringName uv1_blend_sharpness;
StringName uv2_blend_sharpness;
StringName grow;
@@ -350,27 +413,33 @@ private:
StringName ao_light_affect;
StringName metallic_texture_channel;
- StringName roughness_texture_channel;
StringName ao_texture_channel;
StringName clearcoat_texture_channel;
StringName rim_texture_channel;
- StringName depth_texture_channel;
+ StringName heightmap_texture_channel;
StringName refraction_texture_channel;
- StringName alpha_scissor_threshold;
StringName texture_names[TEXTURE_MAX];
+
+ StringName alpha_scissor_threshold;
+ StringName alpha_hash_scale;
+
+ StringName alpha_antialiasing_edge;
+ StringName albedo_texture_size;
};
- static Mutex *material_mutex;
- static SelfList<SpatialMaterial>::List *dirty_materials;
+ static Mutex material_mutex;
+ static SelfList<BaseMaterial3D>::List *dirty_materials;
static ShaderNames *shader_names;
- SelfList<SpatialMaterial> element;
+ SelfList<BaseMaterial3D> element;
void _update_shader();
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
+ bool orm;
+
Color albedo;
float specular;
float metallic;
@@ -383,19 +452,29 @@ private:
float clearcoat;
float clearcoat_gloss;
float anisotropy;
- float depth_scale;
+ float heightmap_scale;
float subsurface_scattering_strength;
- Color transmission;
+ float transmittance_amount;
+ Color transmittance_color;
+ float transmittance_depth;
+ float transmittance_boost;
+
+ Color backlight;
float refraction;
- float line_width;
float point_size;
float alpha_scissor_threshold;
- bool grow_enabled;
+ float alpha_hash_scale;
+ float alpha_antialiasing_edge;
+ bool grow_enabled = false;
float ao_light_affect;
float grow;
int particles_anim_h_frames;
int particles_anim_v_frames;
bool particles_anim_loop;
+ Transparency transparency = TRANSPARENCY_DISABLED;
+ ShadingMode shading_mode = SHADING_MODE_PER_PIXEL;
+
+ TextureFilter texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
Vector3 uv1_scale;
Vector3 uv1_offset;
@@ -405,52 +484,54 @@ private:
Vector3 uv2_offset;
float uv2_triplanar_sharpness;
- DetailUV detail_uv;
+ DetailUV detail_uv = DETAIL_UV_1;
- bool deep_parallax;
+ bool deep_parallax = false;
int deep_parallax_min_layers;
int deep_parallax_max_layers;
- bool depth_parallax_flip_tangent;
- bool depth_parallax_flip_binormal;
+ bool heightmap_parallax_flip_tangent = false;
+ bool heightmap_parallax_flip_binormal = false;
- bool proximity_fade_enabled;
+ bool proximity_fade_enabled = false;
float proximity_fade_distance;
- DistanceFadeMode distance_fade;
+ DistanceFadeMode distance_fade = DISTANCE_FADE_DISABLED;
float distance_fade_max_distance;
float distance_fade_min_distance;
- BlendMode blend_mode;
- BlendMode detail_blend_mode;
- DepthDrawMode depth_draw_mode;
- CullMode cull_mode;
- bool flags[FLAG_MAX];
- SpecularMode specular_mode;
- DiffuseMode diffuse_mode;
+ BlendMode blend_mode = BLEND_MODE_MIX;
+ BlendMode detail_blend_mode = BLEND_MODE_MIX;
+ DepthDrawMode depth_draw_mode = DEPTH_DRAW_OPAQUE_ONLY;
+ CullMode cull_mode = CULL_BACK;
+ bool flags[FLAG_MAX] = {};
+ SpecularMode specular_mode = SPECULAR_SCHLICK_GGX;
+ DiffuseMode diffuse_mode = DIFFUSE_BURLEY;
BillboardMode billboard_mode;
- EmissionOperator emission_op;
+ EmissionOperator emission_op = EMISSION_OP_ADD;
TextureChannel metallic_texture_channel;
TextureChannel roughness_texture_channel;
TextureChannel ao_texture_channel;
TextureChannel refraction_texture_channel;
- bool features[FEATURE_MAX];
+ AlphaAntiAliasing alpha_antialiasing_mode = ALPHA_ANTIALIASING_OFF;
- Ref<Texture> textures[TEXTURE_MAX];
+ bool features[FEATURE_MAX] = {};
+
+ Ref<Texture2D> textures[TEXTURE_MAX];
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
static const int MAX_MATERIALS_FOR_2D = 128;
- static Ref<SpatialMaterial> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
+ static Ref<StandardMaterial3D> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
void _validate_high_end(const String &text, PropertyInfo &property) const;
protected:
static void _bind_methods();
- void _validate_property(PropertyInfo &property) const;
- virtual bool _can_do_next_pass() const { return true; }
+ void _validate_property(PropertyInfo &property) const override;
+ virtual bool _can_do_next_pass() const override { return true; }
public:
void set_albedo(const Color &p_albedo);
@@ -492,39 +573,57 @@ public:
void set_anisotropy(float p_anisotropy);
float get_anisotropy() const;
- void set_depth_scale(float p_depth_scale);
- float get_depth_scale() const;
+ void set_heightmap_scale(float p_heightmap_scale);
+ float get_heightmap_scale() const;
- void set_depth_deep_parallax(bool p_enable);
- bool is_depth_deep_parallax_enabled() const;
+ void set_heightmap_deep_parallax(bool p_enable);
+ bool is_heightmap_deep_parallax_enabled() const;
- void set_depth_deep_parallax_min_layers(int p_layer);
- int get_depth_deep_parallax_min_layers() const;
+ void set_heightmap_deep_parallax_min_layers(int p_layer);
+ int get_heightmap_deep_parallax_min_layers() const;
- void set_depth_deep_parallax_max_layers(int p_layer);
- int get_depth_deep_parallax_max_layers() const;
+ void set_heightmap_deep_parallax_max_layers(int p_layer);
+ int get_heightmap_deep_parallax_max_layers() const;
- void set_depth_deep_parallax_flip_tangent(bool p_flip);
- bool get_depth_deep_parallax_flip_tangent() const;
+ void set_heightmap_deep_parallax_flip_tangent(bool p_flip);
+ bool get_heightmap_deep_parallax_flip_tangent() const;
- void set_depth_deep_parallax_flip_binormal(bool p_flip);
- bool get_depth_deep_parallax_flip_binormal() const;
+ void set_heightmap_deep_parallax_flip_binormal(bool p_flip);
+ bool get_heightmap_deep_parallax_flip_binormal() const;
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
float get_subsurface_scattering_strength() const;
- void set_transmission(const Color &p_transmission);
- Color get_transmission() const;
+ void set_transmittance_color(const Color &p_color);
+ Color get_transmittance_color() const;
+
+ void set_transmittance_depth(float p_depth);
+ float get_transmittance_depth() const;
+
+ void set_transmittance_boost(float p_boost);
+ float get_transmittance_boost() const;
+
+ void set_backlight(const Color &p_backlight);
+ Color get_backlight() const;
void set_refraction(float p_refraction);
float get_refraction() const;
- void set_line_width(float p_line_width);
- float get_line_width() const;
-
void set_point_size(float p_point_size);
float get_point_size() const;
+ void set_transparency(Transparency p_transparency);
+ Transparency get_transparency() const;
+
+ void set_alpha_antialiasing(AlphaAntiAliasing p_alpha_aa);
+ AlphaAntiAliasing get_alpha_antialiasing() const;
+
+ void set_alpha_antialiasing_edge(float p_edge);
+ float get_alpha_antialiasing_edge() const;
+
+ void set_shading_mode(ShadingMode p_shading_mode);
+ ShadingMode get_shading_mode() const;
+
void set_detail_uv(DetailUV p_detail_uv);
DetailUV get_detail_uv() const;
@@ -549,10 +648,13 @@ public:
void set_flag(Flags p_flag, bool p_enabled);
bool get_flag(Flags p_flag) const;
- void set_texture(TextureParam p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_texture(TextureParam p_param) const;
+ void set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_texture(TextureParam p_param) const;
// Used only for shader material conversion
- Ref<Texture> get_texture_by_name(StringName p_name) const;
+ Ref<Texture2D> get_texture_by_name(StringName p_name) const;
+
+ void set_texture_filter(TextureFilter p_filter);
+ TextureFilter get_texture_filter() const;
void set_feature(Feature p_feature, bool p_enabled);
bool get_feature(Feature p_feature) const;
@@ -595,6 +697,9 @@ public:
void set_alpha_scissor_threshold(float p_threshold);
float get_alpha_scissor_threshold() const;
+ void set_alpha_hash_scale(float p_scale);
+ float get_alpha_hash_scale() const;
+
void set_on_top_of_alpha();
void set_proximity_fade(bool p_enable);
@@ -628,29 +733,53 @@ public:
static void finish_shaders();
static void flush_changes();
- static RID get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard = false, bool p_billboard_y = false);
+ static Ref<Material> get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard = false, bool p_billboard_y = false, RID *r_shader_rid = nullptr);
+
+ virtual RID get_shader_rid() const override;
- RID get_shader_rid() const;
+ virtual Shader::Mode get_shader_mode() const override;
- virtual Shader::Mode get_shader_mode() const;
+ BaseMaterial3D(bool p_orm);
+ virtual ~BaseMaterial3D();
+};
+
+VARIANT_ENUM_CAST(BaseMaterial3D::TextureParam)
+VARIANT_ENUM_CAST(BaseMaterial3D::TextureFilter)
+VARIANT_ENUM_CAST(BaseMaterial3D::ShadingMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::Transparency)
+VARIANT_ENUM_CAST(BaseMaterial3D::AlphaAntiAliasing)
+VARIANT_ENUM_CAST(BaseMaterial3D::DetailUV)
+VARIANT_ENUM_CAST(BaseMaterial3D::Feature)
+VARIANT_ENUM_CAST(BaseMaterial3D::BlendMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::DepthDrawMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::CullMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::Flags)
+VARIANT_ENUM_CAST(BaseMaterial3D::DiffuseMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::SpecularMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::BillboardMode)
+VARIANT_ENUM_CAST(BaseMaterial3D::TextureChannel)
+VARIANT_ENUM_CAST(BaseMaterial3D::EmissionOperator)
+VARIANT_ENUM_CAST(BaseMaterial3D::DistanceFadeMode)
+
+class StandardMaterial3D : public BaseMaterial3D {
+ GDCLASS(StandardMaterial3D, BaseMaterial3D)
+protected:
+#ifndef DISABLE_DEPRECATED
+ // Kept for compatibility from 3.x to 4.0.
+ bool _set(const StringName &p_name, const Variant &p_value);
+#endif
- SpatialMaterial();
- virtual ~SpatialMaterial();
+public:
+ StandardMaterial3D() :
+ BaseMaterial3D(false) {}
};
-VARIANT_ENUM_CAST(SpatialMaterial::TextureParam)
-VARIANT_ENUM_CAST(SpatialMaterial::DetailUV)
-VARIANT_ENUM_CAST(SpatialMaterial::Feature)
-VARIANT_ENUM_CAST(SpatialMaterial::BlendMode)
-VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode)
-VARIANT_ENUM_CAST(SpatialMaterial::CullMode)
-VARIANT_ENUM_CAST(SpatialMaterial::Flags)
-VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode)
-VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
-VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
-VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel)
-VARIANT_ENUM_CAST(SpatialMaterial::EmissionOperator)
-VARIANT_ENUM_CAST(SpatialMaterial::DistanceFadeMode)
+class ORMMaterial3D : public BaseMaterial3D {
+ GDCLASS(ORMMaterial3D, BaseMaterial3D)
+public:
+ ORMMaterial3D() :
+ BaseMaterial3D(true) {}
+};
//////////////////////