2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* material.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2021-01-01 19:13:46 +00:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef MATERIAL_H
|
|
|
|
#define MATERIAL_H
|
|
|
|
|
2020-11-07 22:33:38 +00:00
|
|
|
#include "core/io/resource.h"
|
|
|
|
#include "core/templates/self_list.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/resources/shader.h"
|
|
|
|
#include "scene/resources/texture.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering/shader_language.h"
|
|
|
|
#include "servers/rendering_server.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
class Material : public Resource {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(Material, Resource);
|
2017-06-28 20:00:18 +00:00
|
|
|
RES_BASE_EXTENSION("material")
|
2020-01-26 10:24:14 +00:00
|
|
|
OBJ_SAVE_TYPE(Material);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
RID material;
|
2017-07-08 15:34:05 +00:00
|
|
|
Ref<Material> next_pass;
|
2017-09-01 15:56:52 +00:00
|
|
|
int render_priority;
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2021-01-05 23:01:50 +00:00
|
|
|
void inspect_native_shader_code();
|
|
|
|
|
2016-10-10 21:31:01 +00:00
|
|
|
protected:
|
2017-03-05 15:44:50 +00:00
|
|
|
_FORCE_INLINE_ RID _get_material() const { return material; }
|
2017-07-08 15:34:05 +00:00
|
|
|
static void _bind_methods();
|
2017-09-05 23:40:50 +00:00
|
|
|
virtual bool _can_do_next_pass() const { return false; }
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
void _validate_property(PropertyInfo &property) const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
public:
|
2017-09-01 15:56:52 +00:00
|
|
|
enum {
|
2020-03-27 18:21:27 +00:00
|
|
|
RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX,
|
|
|
|
RENDER_PRIORITY_MIN = RS::MATERIAL_RENDER_PRIORITY_MIN,
|
2017-09-01 15:56:52 +00:00
|
|
|
};
|
2017-07-08 15:34:05 +00:00
|
|
|
void set_next_pass(const Ref<Material> &p_pass);
|
|
|
|
Ref<Material> get_next_pass() const;
|
|
|
|
|
2017-09-01 15:56:52 +00:00
|
|
|
void set_render_priority(int p_priority);
|
|
|
|
int get_render_priority() const;
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual RID get_rid() const override;
|
2021-01-05 23:01:50 +00:00
|
|
|
virtual RID get_shader_rid() const = 0;
|
2017-12-06 22:43:22 +00:00
|
|
|
|
|
|
|
virtual Shader::Mode get_shader_mode() const = 0;
|
2016-10-03 19:33:42 +00:00
|
|
|
Material();
|
2014-02-10 01:10:30 +00:00
|
|
|
virtual ~Material();
|
|
|
|
};
|
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
class ShaderMaterial : public Material {
|
|
|
|
GDCLASS(ShaderMaterial, Material);
|
|
|
|
Ref<Shader> shader;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
2018-09-04 22:54:35 +00:00
|
|
|
bool property_can_revert(const String &p_name);
|
|
|
|
Variant property_get_revert(const String &p_name);
|
2017-04-07 02:36:37 +00:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2017-04-07 02:36:37 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual bool _can_do_next_pass() const override;
|
2017-09-05 23:40:50 +00:00
|
|
|
|
2018-07-14 21:15:42 +00:00
|
|
|
void _shader_changed();
|
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
public:
|
|
|
|
void set_shader(const Ref<Shader> &p_shader);
|
|
|
|
Ref<Shader> get_shader() const;
|
|
|
|
|
|
|
|
void set_shader_param(const StringName &p_param, const Variant &p_value);
|
|
|
|
Variant get_shader_param(const StringName &p_param) const;
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Shader::Mode get_shader_mode() const override;
|
2017-12-06 22:43:22 +00:00
|
|
|
|
2021-01-05 23:01:50 +00:00
|
|
|
virtual RID get_shader_rid() const override;
|
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
ShaderMaterial();
|
|
|
|
~ShaderMaterial();
|
|
|
|
};
|
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
class StandardMaterial3D;
|
2017-04-07 02:36:37 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
class BaseMaterial3D : public Material {
|
|
|
|
GDCLASS(BaseMaterial3D, Material);
|
2014-06-28 02:21:45 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
2016-10-27 14:50:26 +00:00
|
|
|
enum TextureParam {
|
|
|
|
TEXTURE_ALBEDO,
|
2017-05-31 23:16:38 +00:00
|
|
|
TEXTURE_METALLIC,
|
|
|
|
TEXTURE_ROUGHNESS,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_EMISSION,
|
|
|
|
TEXTURE_NORMAL,
|
2016-11-21 01:49:53 +00:00
|
|
|
TEXTURE_RIM,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_CLEARCOAT,
|
2016-11-21 01:49:53 +00:00
|
|
|
TEXTURE_FLOWMAP,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_AMBIENT_OCCLUSION,
|
2019-09-15 04:01:52 +00:00
|
|
|
TEXTURE_HEIGHTMAP,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_SUBSURFACE_SCATTERING,
|
2020-04-08 01:51:52 +00:00
|
|
|
TEXTURE_SUBSURFACE_TRANSMITTANCE,
|
|
|
|
TEXTURE_BACKLIGHT,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_REFRACTION,
|
|
|
|
TEXTURE_DETAIL_MASK,
|
|
|
|
TEXTURE_DETAIL_ALBEDO,
|
|
|
|
TEXTURE_DETAIL_NORMAL,
|
2019-09-15 04:01:52 +00:00
|
|
|
TEXTURE_ORM,
|
2016-10-27 14:50:26 +00:00
|
|
|
TEXTURE_MAX
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
enum TextureFilter {
|
|
|
|
TEXTURE_FILTER_NEAREST,
|
|
|
|
TEXTURE_FILTER_LINEAR,
|
2020-02-19 23:31:43 +00:00
|
|
|
TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
|
2019-09-15 04:01:52 +00:00
|
|
|
TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
|
2020-02-19 23:31:43 +00:00
|
|
|
TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC,
|
2019-09-15 04:01:52 +00:00
|
|
|
TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC,
|
|
|
|
TEXTURE_FILTER_MAX
|
|
|
|
};
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum DetailUV {
|
|
|
|
DETAIL_UV_1,
|
2020-07-13 08:27:01 +00:00
|
|
|
DETAIL_UV_2,
|
|
|
|
DETAIL_UV_MAX
|
2016-10-27 14:50:26 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
enum Transparency {
|
|
|
|
TRANSPARENCY_DISABLED,
|
|
|
|
TRANSPARENCY_ALPHA,
|
|
|
|
TRANSPARENCY_ALPHA_SCISSOR,
|
2020-07-13 08:27:01 +00:00
|
|
|
TRANSPARENCY_ALPHA_HASH,
|
2019-09-15 04:01:52 +00:00
|
|
|
TRANSPARENCY_ALPHA_DEPTH_PRE_PASS,
|
|
|
|
TRANSPARENCY_MAX,
|
|
|
|
};
|
|
|
|
|
2020-07-13 08:27:01 +00:00
|
|
|
enum AlphaAntiAliasing {
|
|
|
|
ALPHA_ANTIALIASING_OFF,
|
|
|
|
ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE,
|
|
|
|
ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE,
|
|
|
|
ALPHA_ANTIALIASING_MAX
|
|
|
|
};
|
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
enum ShadingMode {
|
|
|
|
SHADING_MODE_UNSHADED,
|
|
|
|
SHADING_MODE_PER_PIXEL,
|
|
|
|
SHADING_MODE_PER_VERTEX,
|
|
|
|
SHADING_MODE_MAX
|
|
|
|
};
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum Feature {
|
|
|
|
FEATURE_EMISSION,
|
|
|
|
FEATURE_NORMAL_MAPPING,
|
2016-11-21 01:49:53 +00:00
|
|
|
FEATURE_RIM,
|
2016-10-27 14:50:26 +00:00
|
|
|
FEATURE_CLEARCOAT,
|
|
|
|
FEATURE_ANISOTROPY,
|
|
|
|
FEATURE_AMBIENT_OCCLUSION,
|
2019-09-15 04:01:52 +00:00
|
|
|
FEATURE_HEIGHT_MAPPING,
|
2020-04-08 01:51:52 +00:00
|
|
|
FEATURE_SUBSURFACE_SCATTERING,
|
|
|
|
FEATURE_SUBSURFACE_TRANSMITTANCE,
|
|
|
|
FEATURE_BACKLIGHT,
|
2016-10-27 14:50:26 +00:00
|
|
|
FEATURE_REFRACTION,
|
|
|
|
FEATURE_DETAIL,
|
|
|
|
FEATURE_MAX
|
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum BlendMode {
|
|
|
|
BLEND_MODE_MIX,
|
|
|
|
BLEND_MODE_ADD,
|
|
|
|
BLEND_MODE_SUB,
|
|
|
|
BLEND_MODE_MUL,
|
2020-07-13 08:27:01 +00:00
|
|
|
BLEND_MODE_MAX
|
2016-10-27 14:50:26 +00:00
|
|
|
};
|
2014-06-28 02:21:45 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum DepthDrawMode {
|
|
|
|
DEPTH_DRAW_OPAQUE_ONLY,
|
|
|
|
DEPTH_DRAW_ALWAYS,
|
|
|
|
DEPTH_DRAW_DISABLED,
|
2020-07-13 08:27:01 +00:00
|
|
|
DEPTH_DRAW_MAX
|
2016-10-27 14:50:26 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum CullMode {
|
|
|
|
CULL_BACK,
|
|
|
|
CULL_FRONT,
|
2020-07-13 08:27:01 +00:00
|
|
|
CULL_DISABLED,
|
|
|
|
CULL_MAX
|
2016-10-27 14:50:26 +00:00
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum Flags {
|
2017-09-01 15:56:52 +00:00
|
|
|
FLAG_DISABLE_DEPTH_TEST,
|
2016-10-27 14:50:26 +00:00
|
|
|
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
2016-10-29 23:48:09 +00:00
|
|
|
FLAG_SRGB_VERTEX_COLOR,
|
|
|
|
FLAG_USE_POINT_SIZE,
|
2017-04-07 02:36:37 +00:00
|
|
|
FLAG_FIXED_SIZE,
|
2018-04-22 10:11:05 +00:00
|
|
|
FLAG_BILLBOARD_KEEP_SCALE,
|
2017-07-08 11:06:13 +00:00
|
|
|
FLAG_UV1_USE_TRIPLANAR,
|
|
|
|
FLAG_UV2_USE_TRIPLANAR,
|
2019-09-15 04:01:52 +00:00
|
|
|
FLAG_UV1_USE_WORLD_TRIPLANAR,
|
|
|
|
FLAG_UV2_USE_WORLD_TRIPLANAR,
|
2017-07-08 11:06:13 +00:00
|
|
|
FLAG_AO_ON_UV2,
|
2017-12-14 11:59:46 +00:00
|
|
|
FLAG_EMISSION_ON_UV2,
|
2017-12-04 18:55:20 +00:00
|
|
|
FLAG_ALBEDO_TEXTURE_FORCE_SRGB,
|
2018-03-29 16:46:42 +00:00
|
|
|
FLAG_DONT_RECEIVE_SHADOWS,
|
2018-07-17 19:30:43 +00:00
|
|
|
FLAG_DISABLE_AMBIENT_LIGHT,
|
2019-05-20 14:37:13 +00:00
|
|
|
FLAG_USE_SHADOW_TO_OPACITY,
|
2019-09-15 04:01:52 +00:00
|
|
|
FLAG_USE_TEXTURE_REPEAT,
|
|
|
|
FLAG_INVERT_HEIGHTMAP,
|
2020-04-04 02:42:26 +00:00
|
|
|
FLAG_SUBSURFACE_MODE_SKIN,
|
2016-10-27 14:50:26 +00:00
|
|
|
FLAG_MAX
|
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
enum DiffuseMode {
|
2017-10-01 22:08:49 +00:00
|
|
|
DIFFUSE_BURLEY,
|
2016-10-27 14:50:26 +00:00
|
|
|
DIFFUSE_LAMBERT,
|
2017-09-03 13:29:56 +00:00
|
|
|
DIFFUSE_LAMBERT_WRAP,
|
2016-10-27 14:50:26 +00:00
|
|
|
DIFFUSE_OREN_NAYAR,
|
2017-07-08 15:34:05 +00:00
|
|
|
DIFFUSE_TOON,
|
2020-07-13 08:27:01 +00:00
|
|
|
DIFFUSE_MAX
|
2017-07-08 15:34:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SpecularMode {
|
2017-10-23 05:42:36 +00:00
|
|
|
SPECULAR_SCHLICK_GGX,
|
2017-07-08 15:34:05 +00:00
|
|
|
SPECULAR_BLINN,
|
|
|
|
SPECULAR_PHONG,
|
|
|
|
SPECULAR_TOON,
|
2017-07-08 17:01:56 +00:00
|
|
|
SPECULAR_DISABLED,
|
2020-07-13 08:27:01 +00:00
|
|
|
SPECULAR_MAX
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
enum BillboardMode {
|
|
|
|
BILLBOARD_DISABLED,
|
|
|
|
BILLBOARD_ENABLED,
|
|
|
|
BILLBOARD_FIXED_Y,
|
|
|
|
BILLBOARD_PARTICLES,
|
2020-07-13 08:27:01 +00:00
|
|
|
BILLBOARD_MAX
|
2017-04-07 02:36:37 +00:00
|
|
|
};
|
|
|
|
|
2017-08-02 18:34:55 +00:00
|
|
|
enum TextureChannel {
|
|
|
|
TEXTURE_CHANNEL_RED,
|
|
|
|
TEXTURE_CHANNEL_GREEN,
|
|
|
|
TEXTURE_CHANNEL_BLUE,
|
|
|
|
TEXTURE_CHANNEL_ALPHA,
|
2020-07-13 08:27:01 +00:00
|
|
|
TEXTURE_CHANNEL_GRAYSCALE,
|
|
|
|
TEXTURE_CHANNEL_MAX
|
2017-08-02 18:34:55 +00:00
|
|
|
};
|
|
|
|
|
2017-11-15 15:39:24 +00:00
|
|
|
enum EmissionOperator {
|
|
|
|
EMISSION_OP_ADD,
|
2020-07-13 08:27:01 +00:00
|
|
|
EMISSION_OP_MULTIPLY,
|
|
|
|
EMISSION_OP_MAX
|
2017-11-15 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
2018-08-22 13:23:28 +00:00
|
|
|
enum DistanceFadeMode {
|
|
|
|
DISTANCE_FADE_DISABLED,
|
|
|
|
DISTANCE_FADE_PIXEL_ALPHA,
|
|
|
|
DISTANCE_FADE_PIXEL_DITHER,
|
|
|
|
DISTANCE_FADE_OBJECT_DITHER,
|
2020-07-13 08:27:01 +00:00
|
|
|
DISTANCE_FADE_MAX
|
2018-08-22 13:23:28 +00:00
|
|
|
};
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
private:
|
2020-07-13 08:27:01 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
// flag bitfield
|
|
|
|
uint64_t feature_mask : FEATURE_MAX - 1;
|
|
|
|
uint64_t flags : FLAG_MAX - 1;
|
|
|
|
|
|
|
|
// booleans
|
|
|
|
uint64_t deep_parallax : 1;
|
|
|
|
uint64_t grow : 1;
|
|
|
|
uint64_t proximity_fade : 1;
|
|
|
|
|
|
|
|
MaterialKey() {
|
|
|
|
memset(this, 0, sizeof(MaterialKey));
|
|
|
|
}
|
2016-10-27 14:50:26 +00:00
|
|
|
|
2020-04-08 01:51:52 +00:00
|
|
|
bool operator==(const MaterialKey &p_key) const {
|
2020-07-13 08:27:01 +00:00
|
|
|
return memcmp(this, &p_key, sizeof(MaterialKey)) == 0;
|
2020-04-08 01:51:52 +00:00
|
|
|
}
|
2020-07-13 08:27:01 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool operator<(const MaterialKey &p_key) const {
|
2020-07-13 08:27:01 +00:00
|
|
|
return memcmp(this, &p_key, sizeof(MaterialKey)) < 0;
|
2016-10-27 14:50:26 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
struct ShaderData {
|
|
|
|
RID shader;
|
2021-02-09 17:24:36 +00:00
|
|
|
int users = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static Map<MaterialKey, ShaderData> shader_map;
|
2016-10-27 14:50:26 +00:00
|
|
|
|
|
|
|
MaterialKey current_key;
|
|
|
|
|
|
|
|
_FORCE_INLINE_ MaterialKey _compute_key() const {
|
|
|
|
MaterialKey mk;
|
2020-07-13 08:27:01 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
mk.detail_uv = detail_uv;
|
|
|
|
mk.blend_mode = blend_mode;
|
|
|
|
mk.depth_draw_mode = depth_draw_mode;
|
|
|
|
mk.cull_mode = cull_mode;
|
2019-09-15 04:01:52 +00:00
|
|
|
mk.texture_filter = texture_filter;
|
|
|
|
mk.transparency = transparency;
|
|
|
|
mk.shading_mode = shading_mode;
|
|
|
|
mk.roughness_channel = roughness_texture_channel;
|
2017-03-05 15:44:50 +00:00
|
|
|
mk.detail_blend_mode = detail_blend_mode;
|
|
|
|
mk.diffuse_mode = diffuse_mode;
|
2017-07-08 15:34:05 +00:00
|
|
|
mk.specular_mode = specular_mode;
|
2017-04-07 02:36:37 +00:00
|
|
|
mk.billboard_mode = billboard_mode;
|
2020-07-13 08:27:01 +00:00
|
|
|
mk.deep_parallax = deep_parallax;
|
2017-07-08 15:34:05 +00:00
|
|
|
mk.grow = grow_enabled;
|
2017-09-21 18:20:00 +00:00
|
|
|
mk.proximity_fade = proximity_fade_enabled;
|
2018-08-22 13:23:28 +00:00
|
|
|
mk.distance_fade = distance_fade;
|
2017-11-15 15:39:24 +00:00
|
|
|
mk.emission_op = emission_op;
|
2020-07-13 08:27:01 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2016-10-27 14:50:26 +00:00
|
|
|
|
|
|
|
return mk;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ShaderNames {
|
|
|
|
StringName albedo;
|
|
|
|
StringName specular;
|
2017-05-31 23:16:38 +00:00
|
|
|
StringName metallic;
|
2016-10-27 14:50:26 +00:00
|
|
|
StringName roughness;
|
|
|
|
StringName emission;
|
2016-11-21 01:49:53 +00:00
|
|
|
StringName emission_energy;
|
2016-10-27 14:50:26 +00:00
|
|
|
StringName normal_scale;
|
2016-11-21 01:49:53 +00:00
|
|
|
StringName rim;
|
|
|
|
StringName rim_tint;
|
2016-10-27 14:50:26 +00:00
|
|
|
StringName clearcoat;
|
|
|
|
StringName clearcoat_gloss;
|
|
|
|
StringName anisotropy;
|
2019-09-15 04:01:52 +00:00
|
|
|
StringName heightmap_scale;
|
2016-12-03 01:23:16 +00:00
|
|
|
StringName subsurface_scattering_strength;
|
2020-04-08 01:51:52 +00:00
|
|
|
StringName transmittance_color;
|
|
|
|
StringName transmittance_curve;
|
|
|
|
StringName transmittance_depth;
|
|
|
|
StringName transmittance_boost;
|
|
|
|
StringName backlight;
|
2016-10-27 14:50:26 +00:00
|
|
|
StringName refraction;
|
2016-10-29 23:48:09 +00:00
|
|
|
StringName point_size;
|
2016-11-21 01:49:53 +00:00
|
|
|
StringName uv1_scale;
|
|
|
|
StringName uv1_offset;
|
|
|
|
StringName uv2_scale;
|
|
|
|
StringName uv2_offset;
|
2017-08-17 13:49:17 +00:00
|
|
|
StringName particles_anim_h_frames;
|
|
|
|
StringName particles_anim_v_frames;
|
2017-04-07 02:36:37 +00:00
|
|
|
StringName particles_anim_loop;
|
2019-09-15 04:01:52 +00:00
|
|
|
StringName heightmap_min_layers;
|
|
|
|
StringName heightmap_max_layers;
|
|
|
|
StringName heightmap_flip;
|
2017-07-08 11:06:13 +00:00
|
|
|
StringName uv1_blend_sharpness;
|
|
|
|
StringName uv2_blend_sharpness;
|
2017-07-08 15:34:05 +00:00
|
|
|
StringName grow;
|
2017-09-21 18:20:00 +00:00
|
|
|
StringName proximity_fade_distance;
|
|
|
|
StringName distance_fade_min;
|
|
|
|
StringName distance_fade_max;
|
2017-09-24 02:10:34 +00:00
|
|
|
StringName ao_light_affect;
|
2017-06-04 21:08:06 +00:00
|
|
|
|
2017-08-02 18:34:55 +00:00
|
|
|
StringName metallic_texture_channel;
|
|
|
|
StringName ao_texture_channel;
|
|
|
|
StringName clearcoat_texture_channel;
|
|
|
|
StringName rim_texture_channel;
|
2019-09-15 04:01:52 +00:00
|
|
|
StringName heightmap_texture_channel;
|
2017-08-02 18:34:55 +00:00
|
|
|
StringName refraction_texture_channel;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
StringName texture_names[TEXTURE_MAX];
|
2020-07-13 08:27:01 +00:00
|
|
|
|
|
|
|
StringName alpha_scissor_threshold;
|
|
|
|
StringName alpha_hash_scale;
|
|
|
|
|
|
|
|
StringName alpha_antialiasing_edge;
|
|
|
|
StringName albedo_texture_size;
|
2014-06-28 02:21:45 +00:00
|
|
|
};
|
|
|
|
|
2020-02-26 10:28:13 +00:00
|
|
|
static Mutex material_mutex;
|
2019-09-15 04:01:52 +00:00
|
|
|
static SelfList<BaseMaterial3D>::List *dirty_materials;
|
2017-03-05 15:44:50 +00:00
|
|
|
static ShaderNames *shader_names;
|
2016-10-27 14:50:26 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
SelfList<BaseMaterial3D> element;
|
2016-10-27 14:50:26 +00:00
|
|
|
|
|
|
|
void _update_shader();
|
|
|
|
_FORCE_INLINE_ void _queue_shader_change();
|
|
|
|
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
bool orm;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
Color albedo;
|
2017-05-31 23:16:38 +00:00
|
|
|
float specular;
|
|
|
|
float metallic;
|
2016-10-27 14:50:26 +00:00
|
|
|
float roughness;
|
|
|
|
Color emission;
|
2016-11-21 01:49:53 +00:00
|
|
|
float emission_energy;
|
2016-10-27 14:50:26 +00:00
|
|
|
float normal_scale;
|
2016-11-21 01:49:53 +00:00
|
|
|
float rim;
|
|
|
|
float rim_tint;
|
2016-10-27 14:50:26 +00:00
|
|
|
float clearcoat;
|
|
|
|
float clearcoat_gloss;
|
|
|
|
float anisotropy;
|
2019-09-15 04:01:52 +00:00
|
|
|
float heightmap_scale;
|
2016-12-03 01:23:16 +00:00
|
|
|
float subsurface_scattering_strength;
|
2020-04-08 01:51:52 +00:00
|
|
|
float transmittance_amount;
|
|
|
|
Color transmittance_color;
|
|
|
|
float transmittance_depth;
|
|
|
|
float transmittance_curve;
|
|
|
|
float transmittance_boost;
|
|
|
|
|
|
|
|
Color backlight;
|
2016-10-27 14:50:26 +00:00
|
|
|
float refraction;
|
2016-10-29 23:48:09 +00:00
|
|
|
float point_size;
|
2017-08-08 20:23:44 +00:00
|
|
|
float alpha_scissor_threshold;
|
2020-07-13 08:27:01 +00:00
|
|
|
float alpha_hash_scale;
|
|
|
|
float alpha_antialiasing_edge;
|
2021-02-09 17:24:36 +00:00
|
|
|
bool grow_enabled = false;
|
2017-09-24 02:10:34 +00:00
|
|
|
float ao_light_affect;
|
2017-07-08 15:34:05 +00:00
|
|
|
float grow;
|
2017-04-07 02:36:37 +00:00
|
|
|
int particles_anim_h_frames;
|
|
|
|
int particles_anim_v_frames;
|
|
|
|
bool particles_anim_loop;
|
2021-02-09 17:24:36 +00:00
|
|
|
Transparency transparency = TRANSPARENCY_DISABLED;
|
|
|
|
ShadingMode shading_mode = SHADING_MODE_PER_PIXEL;
|
2019-09-15 04:01:52 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
TextureFilter texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
Vector3 uv1_scale;
|
|
|
|
Vector3 uv1_offset;
|
|
|
|
float uv1_triplanar_sharpness;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
Vector3 uv2_scale;
|
|
|
|
Vector3 uv2_offset;
|
|
|
|
float uv2_triplanar_sharpness;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
DetailUV detail_uv = DETAIL_UV_1;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
bool deep_parallax = false;
|
2017-06-04 21:08:06 +00:00
|
|
|
int deep_parallax_min_layers;
|
|
|
|
int deep_parallax_max_layers;
|
2021-02-09 17:24:36 +00:00
|
|
|
bool heightmap_parallax_flip_tangent = false;
|
|
|
|
bool heightmap_parallax_flip_binormal = false;
|
2017-06-04 21:08:06 +00:00
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
bool proximity_fade_enabled = false;
|
2017-09-21 18:20:00 +00:00
|
|
|
float proximity_fade_distance;
|
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
DistanceFadeMode distance_fade = DISTANCE_FADE_DISABLED;
|
2017-09-21 18:20:00 +00:00
|
|
|
float distance_fade_max_distance;
|
|
|
|
float distance_fade_min_distance;
|
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
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;
|
2017-04-07 02:36:37 +00:00
|
|
|
BillboardMode billboard_mode;
|
2021-02-09 17:24:36 +00:00
|
|
|
EmissionOperator emission_op = EMISSION_OP_ADD;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-08-02 18:34:55 +00:00
|
|
|
TextureChannel metallic_texture_channel;
|
|
|
|
TextureChannel roughness_texture_channel;
|
|
|
|
TextureChannel ao_texture_channel;
|
|
|
|
TextureChannel refraction_texture_channel;
|
|
|
|
|
2021-02-09 17:24:36 +00:00
|
|
|
AlphaAntiAliasing alpha_antialiasing_mode = ALPHA_ANTIALIASING_OFF;
|
2020-07-13 08:27:01 +00:00
|
|
|
|
2021-02-13 23:12:30 +00:00
|
|
|
bool features[FEATURE_MAX] = {};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> textures[TEXTURE_MAX];
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-07-16 23:04:36 +00:00
|
|
|
static const int MAX_MATERIALS_FOR_2D = 128;
|
2017-08-08 20:23:44 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
static Ref<StandardMaterial3D> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
|
2017-08-08 20:23:44 +00:00
|
|
|
|
2018-09-28 23:32:40 +00:00
|
|
|
void _validate_high_end(const String &text, PropertyInfo &property) const;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
protected:
|
2014-02-10 01:10:30 +00:00
|
|
|
static void _bind_methods();
|
2020-07-10 10:34:39 +00:00
|
|
|
void _validate_property(PropertyInfo &property) const override;
|
|
|
|
virtual bool _can_do_next_pass() const override { return true; }
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
public:
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_albedo(const Color &p_albedo);
|
2016-10-27 14:50:26 +00:00
|
|
|
Color get_albedo() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-31 23:16:38 +00:00
|
|
|
void set_specular(float p_specular);
|
|
|
|
float get_specular() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-31 23:16:38 +00:00
|
|
|
void set_metallic(float p_metallic);
|
|
|
|
float get_metallic() const;
|
2014-06-28 02:21:45 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_roughness(float p_roughness);
|
|
|
|
float get_roughness() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_emission(const Color &p_emission);
|
2016-10-27 14:50:26 +00:00
|
|
|
Color get_emission() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-21 01:49:53 +00:00
|
|
|
void set_emission_energy(float p_emission_energy);
|
|
|
|
float get_emission_energy() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_normal_scale(float p_normal_scale);
|
|
|
|
float get_normal_scale() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-21 01:49:53 +00:00
|
|
|
void set_rim(float p_rim);
|
|
|
|
float get_rim() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-21 01:49:53 +00:00
|
|
|
void set_rim_tint(float p_rim_tint);
|
|
|
|
float get_rim_tint() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-09-24 02:10:34 +00:00
|
|
|
void set_ao_light_affect(float p_ao_light_affect);
|
|
|
|
float get_ao_light_affect() const;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_clearcoat(float p_clearcoat);
|
|
|
|
float get_clearcoat() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_clearcoat_gloss(float p_clearcoat_gloss);
|
|
|
|
float get_clearcoat_gloss() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_anisotropy(float p_anisotropy);
|
|
|
|
float get_anisotropy() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_scale(float p_heightmap_scale);
|
|
|
|
float get_heightmap_scale() const;
|
2017-06-04 21:08:06 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_deep_parallax(bool p_enable);
|
|
|
|
bool is_heightmap_deep_parallax_enabled() const;
|
2017-06-04 21:08:06 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_deep_parallax_min_layers(int p_layer);
|
|
|
|
int get_heightmap_deep_parallax_min_layers() const;
|
2017-06-04 21:08:06 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_deep_parallax_max_layers(int p_layer);
|
|
|
|
int get_heightmap_deep_parallax_max_layers() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_deep_parallax_flip_tangent(bool p_flip);
|
|
|
|
bool get_heightmap_deep_parallax_flip_tangent() const;
|
2018-11-14 13:15:15 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_heightmap_deep_parallax_flip_binormal(bool p_flip);
|
|
|
|
bool get_heightmap_deep_parallax_flip_binormal() const;
|
2018-11-14 13:15:15 +00:00
|
|
|
|
2017-08-11 19:10:05 +00:00
|
|
|
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
|
2016-12-03 01:23:16 +00:00
|
|
|
float get_subsurface_scattering_strength() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-08 01:51:52 +00:00
|
|
|
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_curve(float p_curve);
|
|
|
|
float get_transmittance_curve() const;
|
|
|
|
|
|
|
|
void set_transmittance_boost(float p_boost);
|
|
|
|
float get_transmittance_boost() const;
|
|
|
|
|
|
|
|
void set_backlight(const Color &p_backlight);
|
|
|
|
Color get_backlight() const;
|
2017-09-03 13:29:56 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_refraction(float p_refraction);
|
|
|
|
float get_refraction() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-29 23:48:09 +00:00
|
|
|
void set_point_size(float p_point_size);
|
|
|
|
float get_point_size() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_transparency(Transparency p_transparency);
|
|
|
|
Transparency get_transparency() const;
|
|
|
|
|
2020-07-13 08:27:01 +00:00
|
|
|
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;
|
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_shading_mode(ShadingMode p_shading_mode);
|
|
|
|
ShadingMode get_shading_mode() const;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_detail_uv(DetailUV p_detail_uv);
|
|
|
|
DetailUV get_detail_uv() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_blend_mode(BlendMode p_mode);
|
|
|
|
BlendMode get_blend_mode() const;
|
|
|
|
|
|
|
|
void set_detail_blend_mode(BlendMode p_mode);
|
|
|
|
BlendMode get_detail_blend_mode() const;
|
|
|
|
|
|
|
|
void set_depth_draw_mode(DepthDrawMode p_mode);
|
|
|
|
DepthDrawMode get_depth_draw_mode() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_cull_mode(CullMode p_mode);
|
|
|
|
CullMode get_cull_mode() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
void set_diffuse_mode(DiffuseMode p_mode);
|
|
|
|
DiffuseMode get_diffuse_mode() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-07-08 15:34:05 +00:00
|
|
|
void set_specular_mode(SpecularMode p_mode);
|
|
|
|
SpecularMode get_specular_mode() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_flag(Flags p_flag, bool p_enabled);
|
2016-10-27 14:50:26 +00:00
|
|
|
bool get_flag(Flags p_flag) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
void set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture);
|
|
|
|
Ref<Texture2D> get_texture(TextureParam p_param) const;
|
2017-10-16 09:14:39 +00:00
|
|
|
// Used only for shader material conversion
|
2019-06-11 18:43:37 +00:00
|
|
|
Ref<Texture2D> get_texture_by_name(StringName p_name) const;
|
2016-10-27 14:50:26 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
void set_texture_filter(TextureFilter p_filter);
|
|
|
|
TextureFilter get_texture_filter() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_feature(Feature p_feature, bool p_enabled);
|
2016-10-27 14:50:26 +00:00
|
|
|
bool get_feature(Feature p_feature) const;
|
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
void set_uv1_scale(const Vector3 &p_scale);
|
|
|
|
Vector3 get_uv1_scale() const;
|
2016-11-21 01:49:53 +00:00
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
void set_uv1_offset(const Vector3 &p_offset);
|
|
|
|
Vector3 get_uv1_offset() const;
|
2016-11-21 01:49:53 +00:00
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
void set_uv1_triplanar_blend_sharpness(float p_sharpness);
|
|
|
|
float get_uv1_triplanar_blend_sharpness() const;
|
2016-11-21 01:49:53 +00:00
|
|
|
|
2017-07-08 11:06:13 +00:00
|
|
|
void set_uv2_scale(const Vector3 &p_scale);
|
|
|
|
Vector3 get_uv2_scale() const;
|
|
|
|
|
|
|
|
void set_uv2_offset(const Vector3 &p_offset);
|
|
|
|
Vector3 get_uv2_offset() const;
|
|
|
|
|
|
|
|
void set_uv2_triplanar_blend_sharpness(float p_sharpness);
|
|
|
|
float get_uv2_triplanar_blend_sharpness() const;
|
2016-11-21 01:49:53 +00:00
|
|
|
|
2017-04-07 02:36:37 +00:00
|
|
|
void set_billboard_mode(BillboardMode p_mode);
|
|
|
|
BillboardMode get_billboard_mode() const;
|
|
|
|
|
|
|
|
void set_particles_anim_h_frames(int p_frames);
|
|
|
|
int get_particles_anim_h_frames() const;
|
|
|
|
void set_particles_anim_v_frames(int p_frames);
|
|
|
|
int get_particles_anim_v_frames() const;
|
|
|
|
|
2018-09-27 11:05:57 +00:00
|
|
|
void set_particles_anim_loop(bool p_loop);
|
|
|
|
bool get_particles_anim_loop() const;
|
2017-04-07 02:36:37 +00:00
|
|
|
|
2017-07-08 15:34:05 +00:00
|
|
|
void set_grow_enabled(bool p_enable);
|
|
|
|
bool is_grow_enabled() const;
|
|
|
|
|
|
|
|
void set_grow(float p_grow);
|
|
|
|
float get_grow() const;
|
|
|
|
|
2018-02-21 16:30:55 +00:00
|
|
|
void set_alpha_scissor_threshold(float p_threshold);
|
2017-08-08 20:23:44 +00:00
|
|
|
float get_alpha_scissor_threshold() const;
|
|
|
|
|
2020-07-13 08:27:01 +00:00
|
|
|
void set_alpha_hash_scale(float p_scale);
|
|
|
|
float get_alpha_hash_scale() const;
|
|
|
|
|
2017-09-01 15:56:52 +00:00
|
|
|
void set_on_top_of_alpha();
|
|
|
|
|
2017-09-21 18:20:00 +00:00
|
|
|
void set_proximity_fade(bool p_enable);
|
|
|
|
bool is_proximity_fade_enabled() const;
|
|
|
|
|
|
|
|
void set_proximity_fade_distance(float p_distance);
|
|
|
|
float get_proximity_fade_distance() const;
|
|
|
|
|
2018-08-22 13:23:28 +00:00
|
|
|
void set_distance_fade(DistanceFadeMode p_mode);
|
|
|
|
DistanceFadeMode get_distance_fade() const;
|
2017-09-21 18:20:00 +00:00
|
|
|
|
|
|
|
void set_distance_fade_max_distance(float p_distance);
|
|
|
|
float get_distance_fade_max_distance() const;
|
|
|
|
|
|
|
|
void set_distance_fade_min_distance(float p_distance);
|
|
|
|
float get_distance_fade_min_distance() const;
|
|
|
|
|
2017-11-15 15:39:24 +00:00
|
|
|
void set_emission_operator(EmissionOperator p_op);
|
|
|
|
EmissionOperator get_emission_operator() const;
|
|
|
|
|
2017-08-02 18:34:55 +00:00
|
|
|
void set_metallic_texture_channel(TextureChannel p_channel);
|
|
|
|
TextureChannel get_metallic_texture_channel() const;
|
|
|
|
void set_roughness_texture_channel(TextureChannel p_channel);
|
|
|
|
TextureChannel get_roughness_texture_channel() const;
|
|
|
|
void set_ao_texture_channel(TextureChannel p_channel);
|
|
|
|
TextureChannel get_ao_texture_channel() const;
|
|
|
|
void set_refraction_texture_channel(TextureChannel p_channel);
|
|
|
|
TextureChannel get_refraction_texture_channel() const;
|
|
|
|
|
2016-10-27 14:50:26 +00:00
|
|
|
static void init_shaders();
|
|
|
|
static void finish_shaders();
|
|
|
|
static void flush_changes();
|
|
|
|
|
2019-07-16 23:04:36 +00:00
|
|
|
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);
|
2017-08-08 20:23:44 +00:00
|
|
|
|
2021-01-05 23:01:50 +00:00
|
|
|
virtual RID get_shader_rid() const override;
|
2017-09-22 12:20:28 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Shader::Mode get_shader_mode() const override;
|
2017-12-06 22:43:22 +00:00
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
BaseMaterial3D(bool p_orm);
|
|
|
|
virtual ~BaseMaterial3D();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2019-09-15 04:01:52 +00:00
|
|
|
VARIANT_ENUM_CAST(BaseMaterial3D::TextureParam)
|
|
|
|
VARIANT_ENUM_CAST(BaseMaterial3D::TextureFilter)
|
|
|
|
VARIANT_ENUM_CAST(BaseMaterial3D::ShadingMode)
|
|
|
|
VARIANT_ENUM_CAST(BaseMaterial3D::Transparency)
|
2020-07-13 08:27:01 +00:00
|
|
|
VARIANT_ENUM_CAST(BaseMaterial3D::AlphaAntiAliasing)
|
2019-09-15 04:01:52 +00:00
|
|
|
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
|
2020-02-13 10:37:37 +00:00
|
|
|
// Kept for compatibility from 3.x to 4.0.
|
2019-09-15 04:01:52 +00:00
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public:
|
|
|
|
StandardMaterial3D() :
|
|
|
|
BaseMaterial3D(false) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ORMMaterial3D : public BaseMaterial3D {
|
|
|
|
GDCLASS(ORMMaterial3D, BaseMaterial3D)
|
|
|
|
public:
|
|
|
|
ORMMaterial3D() :
|
|
|
|
BaseMaterial3D(true) {}
|
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
#endif
|