2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* material.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01: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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef MATERIAL_H
|
|
|
|
#define MATERIAL_H
|
|
|
|
|
|
|
|
#include "resource.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/resources/shader.h"
|
|
|
|
#include "scene/resources/texture.h"
|
2016-10-27 16:50:26 +02:00
|
|
|
#include "self_list.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "servers/visual/shader_language.h"
|
|
|
|
#include "servers/visual_server.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
/**
|
|
|
|
@author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Material : public Resource {
|
|
|
|
|
2017-06-28 22:00:18 +02:00
|
|
|
GDCLASS(Material, Resource)
|
|
|
|
RES_BASE_EXTENSION("material")
|
|
|
|
OBJ_SAVE_TYPE(Material)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
RID material;
|
2017-07-08 17:34:05 +02:00
|
|
|
Ref<Material> next_pass;
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2016-10-10 23:31:01 +02:00
|
|
|
protected:
|
2017-03-05 16:44:50 +01:00
|
|
|
_FORCE_INLINE_ RID _get_material() const { return material; }
|
2017-07-08 17:34:05 +02:00
|
|
|
static void _bind_methods();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
public:
|
2017-07-08 17:34:05 +02:00
|
|
|
void set_next_pass(const Ref<Material> &p_pass);
|
|
|
|
Ref<Material> get_next_pass() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
virtual RID get_rid() const;
|
2016-10-03 21:33:42 +02:00
|
|
|
Material();
|
2014-02-10 02:10:30 +01:00
|
|
|
virtual ~Material();
|
|
|
|
};
|
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
class ShaderMaterial : public Material {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
ShaderMaterial();
|
|
|
|
~ShaderMaterial();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpatialMaterial : public Material {
|
|
|
|
|
|
|
|
GDCLASS(SpatialMaterial, Material)
|
2014-06-28 04:21:45 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2016-10-27 16:50:26 +02:00
|
|
|
enum TextureParam {
|
|
|
|
TEXTURE_ALBEDO,
|
2017-06-01 01:16:38 +02:00
|
|
|
TEXTURE_METALLIC,
|
|
|
|
TEXTURE_ROUGHNESS,
|
2016-10-27 16:50:26 +02:00
|
|
|
TEXTURE_EMISSION,
|
|
|
|
TEXTURE_NORMAL,
|
2016-11-21 02:49:53 +01:00
|
|
|
TEXTURE_RIM,
|
2016-10-27 16:50:26 +02:00
|
|
|
TEXTURE_CLEARCOAT,
|
2016-11-21 02:49:53 +01:00
|
|
|
TEXTURE_FLOWMAP,
|
2016-10-27 16:50:26 +02:00
|
|
|
TEXTURE_AMBIENT_OCCLUSION,
|
2017-06-04 23:08:06 +02:00
|
|
|
TEXTURE_DEPTH,
|
2016-10-27 16:50:26 +02:00
|
|
|
TEXTURE_SUBSURFACE_SCATTERING,
|
|
|
|
TEXTURE_REFRACTION,
|
|
|
|
TEXTURE_DETAIL_MASK,
|
|
|
|
TEXTURE_DETAIL_ALBEDO,
|
|
|
|
TEXTURE_DETAIL_NORMAL,
|
|
|
|
TEXTURE_MAX
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum DetailUV {
|
|
|
|
DETAIL_UV_1,
|
|
|
|
DETAIL_UV_2
|
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum Feature {
|
|
|
|
FEATURE_TRANSPARENT,
|
|
|
|
FEATURE_EMISSION,
|
|
|
|
FEATURE_NORMAL_MAPPING,
|
2016-11-21 02:49:53 +01:00
|
|
|
FEATURE_RIM,
|
2016-10-27 16:50:26 +02:00
|
|
|
FEATURE_CLEARCOAT,
|
|
|
|
FEATURE_ANISOTROPY,
|
|
|
|
FEATURE_AMBIENT_OCCLUSION,
|
2017-06-04 23:08:06 +02:00
|
|
|
FEATURE_DEPTH_MAPPING,
|
2016-10-27 16:50:26 +02:00
|
|
|
FEATURE_SUBSURACE_SCATTERING,
|
|
|
|
FEATURE_REFRACTION,
|
|
|
|
FEATURE_DETAIL,
|
|
|
|
FEATURE_MAX
|
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum BlendMode {
|
|
|
|
BLEND_MODE_MIX,
|
|
|
|
BLEND_MODE_ADD,
|
|
|
|
BLEND_MODE_SUB,
|
|
|
|
BLEND_MODE_MUL,
|
|
|
|
};
|
2014-06-28 04:21:45 +02:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum DepthDrawMode {
|
|
|
|
DEPTH_DRAW_OPAQUE_ONLY,
|
|
|
|
DEPTH_DRAW_ALWAYS,
|
|
|
|
DEPTH_DRAW_DISABLED,
|
|
|
|
DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum CullMode {
|
|
|
|
CULL_BACK,
|
|
|
|
CULL_FRONT,
|
|
|
|
CULL_DISABLED
|
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum Flags {
|
|
|
|
FLAG_UNSHADED,
|
2017-07-22 19:07:38 +02:00
|
|
|
FLAG_USE_VERTEX_LIGHTING,
|
2016-10-27 16:50:26 +02:00
|
|
|
FLAG_ONTOP,
|
|
|
|
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
2016-10-30 01:48:09 +02:00
|
|
|
FLAG_SRGB_VERTEX_COLOR,
|
|
|
|
FLAG_USE_POINT_SIZE,
|
2017-04-07 04:36:37 +02:00
|
|
|
FLAG_FIXED_SIZE,
|
2017-07-08 13:06:13 +02:00
|
|
|
FLAG_UV1_USE_TRIPLANAR,
|
|
|
|
FLAG_UV2_USE_TRIPLANAR,
|
|
|
|
FLAG_AO_ON_UV2,
|
2017-08-08 22:23:44 +02:00
|
|
|
FLAG_USE_ALPHA_SCISSOR,
|
2016-10-27 16:50:26 +02:00
|
|
|
FLAG_MAX
|
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
enum DiffuseMode {
|
|
|
|
DIFFUSE_LAMBERT,
|
2017-06-01 23:55:24 +02:00
|
|
|
DIFFUSE_HALF_LAMBERT,
|
2016-10-27 16:50:26 +02:00
|
|
|
DIFFUSE_OREN_NAYAR,
|
|
|
|
DIFFUSE_BURLEY,
|
2017-07-08 17:34:05 +02:00
|
|
|
DIFFUSE_TOON,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SpecularMode {
|
|
|
|
SPECULAR_SCHLICK_GGX,
|
|
|
|
SPECULAR_BLINN,
|
|
|
|
SPECULAR_PHONG,
|
|
|
|
SPECULAR_TOON,
|
2017-07-08 19:01:56 +02:00
|
|
|
SPECULAR_DISABLED,
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
enum BillboardMode {
|
|
|
|
BILLBOARD_DISABLED,
|
|
|
|
BILLBOARD_ENABLED,
|
|
|
|
BILLBOARD_FIXED_Y,
|
|
|
|
BILLBOARD_PARTICLES,
|
|
|
|
};
|
|
|
|
|
2017-08-02 20:34:55 +02:00
|
|
|
enum TextureChannel {
|
|
|
|
TEXTURE_CHANNEL_RED,
|
|
|
|
TEXTURE_CHANNEL_GREEN,
|
|
|
|
TEXTURE_CHANNEL_BLUE,
|
|
|
|
TEXTURE_CHANNEL_ALPHA,
|
|
|
|
TEXTURE_CHANNEL_GRAYSCALE
|
|
|
|
};
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
private:
|
|
|
|
union MaterialKey {
|
|
|
|
|
|
|
|
struct {
|
2017-07-08 13:06:13 +02:00
|
|
|
uint64_t feature_mask : 11;
|
|
|
|
uint64_t detail_uv : 1;
|
|
|
|
uint64_t blend_mode : 2;
|
|
|
|
uint64_t depth_draw_mode : 2;
|
|
|
|
uint64_t cull_mode : 2;
|
2017-08-08 22:23:44 +02:00
|
|
|
uint64_t flags : 11;
|
2017-07-08 13:06:13 +02:00
|
|
|
uint64_t detail_blend_mode : 2;
|
2017-07-08 17:34:05 +02:00
|
|
|
uint64_t diffuse_mode : 3;
|
|
|
|
uint64_t specular_mode : 2;
|
2017-07-08 13:06:13 +02:00
|
|
|
uint64_t invalid_key : 1;
|
|
|
|
uint64_t deep_parallax : 1;
|
|
|
|
uint64_t billboard_mode : 2;
|
2017-07-08 17:34:05 +02:00
|
|
|
uint64_t grow : 1;
|
2016-10-27 16:50:26 +02:00
|
|
|
};
|
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
uint64_t key;
|
2016-10-27 16:50:26 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool operator<(const MaterialKey &p_key) const {
|
2016-10-27 16:50:26 +02:00
|
|
|
return key < p_key.key;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
struct ShaderData {
|
|
|
|
RID shader;
|
|
|
|
int users;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
static Map<MaterialKey, ShaderData> shader_map;
|
2016-10-27 16:50:26 +02:00
|
|
|
|
|
|
|
MaterialKey current_key;
|
|
|
|
|
|
|
|
_FORCE_INLINE_ MaterialKey _compute_key() const {
|
|
|
|
|
|
|
|
MaterialKey mk;
|
2017-03-05 16:44:50 +01:00
|
|
|
mk.key = 0;
|
|
|
|
for (int i = 0; i < FEATURE_MAX; i++) {
|
2016-10-27 16:50:26 +02:00
|
|
|
if (features[i]) {
|
2017-03-05 16:44:50 +01:00
|
|
|
mk.feature_mask |= (1 << i);
|
2016-10-27 16:50:26 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
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++) {
|
2016-10-27 16:50:26 +02:00
|
|
|
if (flags[i]) {
|
2017-03-05 16:44:50 +01:00
|
|
|
mk.flags |= (1 << i);
|
2016-10-27 16:50:26 +02:00
|
|
|
}
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
mk.detail_blend_mode = detail_blend_mode;
|
|
|
|
mk.diffuse_mode = diffuse_mode;
|
2017-07-08 17:34:05 +02:00
|
|
|
mk.specular_mode = specular_mode;
|
2017-04-07 04:36:37 +02:00
|
|
|
mk.billboard_mode = billboard_mode;
|
2017-06-04 23:08:06 +02:00
|
|
|
mk.deep_parallax = deep_parallax ? 1 : 0;
|
2017-07-08 17:34:05 +02:00
|
|
|
mk.grow = grow_enabled;
|
2016-10-27 16:50:26 +02:00
|
|
|
|
|
|
|
return mk;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ShaderNames {
|
|
|
|
StringName albedo;
|
|
|
|
StringName specular;
|
2017-06-01 01:16:38 +02:00
|
|
|
StringName metallic;
|
2016-10-27 16:50:26 +02:00
|
|
|
StringName roughness;
|
|
|
|
StringName emission;
|
2016-11-21 02:49:53 +01:00
|
|
|
StringName emission_energy;
|
2016-10-27 16:50:26 +02:00
|
|
|
StringName normal_scale;
|
2016-11-21 02:49:53 +01:00
|
|
|
StringName rim;
|
|
|
|
StringName rim_tint;
|
2016-10-27 16:50:26 +02:00
|
|
|
StringName clearcoat;
|
|
|
|
StringName clearcoat_gloss;
|
|
|
|
StringName anisotropy;
|
2017-06-04 23:08:06 +02:00
|
|
|
StringName depth_scale;
|
2016-12-03 02:23:16 +01:00
|
|
|
StringName subsurface_scattering_strength;
|
2016-10-27 16:50:26 +02:00
|
|
|
StringName refraction;
|
2016-10-30 01:48:09 +02:00
|
|
|
StringName point_size;
|
2016-11-21 02:49:53 +01:00
|
|
|
StringName uv1_scale;
|
|
|
|
StringName uv1_offset;
|
|
|
|
StringName uv2_scale;
|
|
|
|
StringName uv2_offset;
|
2017-04-07 04:36:37 +02:00
|
|
|
StringName particle_h_frames;
|
|
|
|
StringName particle_v_frames;
|
|
|
|
StringName particles_anim_loop;
|
2017-06-04 23:08:06 +02:00
|
|
|
StringName depth_min_layers;
|
|
|
|
StringName depth_max_layers;
|
2017-07-08 13:06:13 +02:00
|
|
|
StringName uv1_blend_sharpness;
|
|
|
|
StringName uv2_blend_sharpness;
|
2017-07-08 17:34:05 +02:00
|
|
|
StringName grow;
|
2017-06-04 23:08:06 +02:00
|
|
|
|
2017-08-02 20:34:55 +02:00
|
|
|
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 refraction_texture_channel;
|
2017-08-08 22:23:44 +02:00
|
|
|
StringName alpha_scissor_threshold;
|
2017-08-02 20:34:55 +02:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
StringName texture_names[TEXTURE_MAX];
|
2014-06-28 04:21:45 +02:00
|
|
|
};
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
static Mutex *material_mutex;
|
2017-04-07 04:36:37 +02:00
|
|
|
static SelfList<SpatialMaterial>::List dirty_materials;
|
2017-03-05 16:44:50 +01:00
|
|
|
static ShaderNames *shader_names;
|
2016-10-27 16:50:26 +02:00
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
SelfList<SpatialMaterial> element;
|
2016-10-27 16:50:26 +02:00
|
|
|
|
|
|
|
void _update_shader();
|
|
|
|
_FORCE_INLINE_ void _queue_shader_change();
|
|
|
|
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
|
|
|
|
|
|
|
Color albedo;
|
2017-06-01 01:16:38 +02:00
|
|
|
float specular;
|
|
|
|
float metallic;
|
2016-10-27 16:50:26 +02:00
|
|
|
float roughness;
|
|
|
|
Color emission;
|
2016-11-21 02:49:53 +01:00
|
|
|
float emission_energy;
|
2016-10-27 16:50:26 +02:00
|
|
|
float normal_scale;
|
2016-11-21 02:49:53 +01:00
|
|
|
float rim;
|
|
|
|
float rim_tint;
|
2016-10-27 16:50:26 +02:00
|
|
|
float clearcoat;
|
|
|
|
float clearcoat_gloss;
|
|
|
|
float anisotropy;
|
2017-06-04 23:08:06 +02:00
|
|
|
float depth_scale;
|
2016-12-03 02:23:16 +01:00
|
|
|
float subsurface_scattering_strength;
|
2016-10-27 16:50:26 +02:00
|
|
|
float refraction;
|
2016-10-30 01:48:09 +02:00
|
|
|
float line_width;
|
|
|
|
float point_size;
|
2017-08-08 22:23:44 +02:00
|
|
|
float alpha_scissor_threshold;
|
2017-07-08 17:34:05 +02:00
|
|
|
bool grow_enabled;
|
|
|
|
float grow;
|
2017-04-07 04:36:37 +02:00
|
|
|
int particles_anim_h_frames;
|
|
|
|
int particles_anim_v_frames;
|
|
|
|
bool particles_anim_loop;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
Vector3 uv1_scale;
|
|
|
|
Vector3 uv1_offset;
|
|
|
|
float uv1_triplanar_sharpness;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
Vector3 uv2_scale;
|
|
|
|
Vector3 uv2_offset;
|
|
|
|
float uv2_triplanar_sharpness;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
DetailUV detail_uv;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-04 23:08:06 +02:00
|
|
|
bool deep_parallax;
|
|
|
|
int deep_parallax_min_layers;
|
|
|
|
int deep_parallax_max_layers;
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
BlendMode blend_mode;
|
|
|
|
BlendMode detail_blend_mode;
|
|
|
|
DepthDrawMode depth_draw_mode;
|
|
|
|
CullMode cull_mode;
|
|
|
|
bool flags[FLAG_MAX];
|
2017-07-08 17:34:05 +02:00
|
|
|
SpecularMode specular_mode;
|
2016-10-27 16:50:26 +02:00
|
|
|
DiffuseMode diffuse_mode;
|
2017-04-07 04:36:37 +02:00
|
|
|
BillboardMode billboard_mode;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-08-02 20:34:55 +02:00
|
|
|
TextureChannel metallic_texture_channel;
|
|
|
|
TextureChannel roughness_texture_channel;
|
|
|
|
TextureChannel ao_texture_channel;
|
|
|
|
TextureChannel refraction_texture_channel;
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
bool features[FEATURE_MAX];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
Ref<Texture> textures[TEXTURE_MAX];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-08-08 22:23:44 +02:00
|
|
|
enum {
|
|
|
|
MAX_MATERIALS_FOR_2D = 32
|
|
|
|
};
|
|
|
|
|
|
|
|
static Ref<SpatialMaterial> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
|
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
protected:
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
2017-03-05 16:44:50 +01:00
|
|
|
void _validate_property(PropertyInfo &property) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_albedo(const Color &p_albedo);
|
2016-10-27 16:50:26 +02:00
|
|
|
Color get_albedo() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-01 01:16:38 +02:00
|
|
|
void set_specular(float p_specular);
|
|
|
|
float get_specular() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-01 01:16:38 +02:00
|
|
|
void set_metallic(float p_metallic);
|
|
|
|
float get_metallic() const;
|
2014-06-28 04:21:45 +02:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_roughness(float p_roughness);
|
|
|
|
float get_roughness() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_emission(const Color &p_emission);
|
2016-10-27 16:50:26 +02:00
|
|
|
Color get_emission() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-11-21 02:49:53 +01:00
|
|
|
void set_emission_energy(float p_emission_energy);
|
|
|
|
float get_emission_energy() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_normal_scale(float p_normal_scale);
|
|
|
|
float get_normal_scale() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-11-21 02:49:53 +01:00
|
|
|
void set_rim(float p_rim);
|
|
|
|
float get_rim() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-11-21 02:49:53 +01:00
|
|
|
void set_rim_tint(float p_rim_tint);
|
|
|
|
float get_rim_tint() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_clearcoat(float p_clearcoat);
|
|
|
|
float get_clearcoat() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_clearcoat_gloss(float p_clearcoat_gloss);
|
|
|
|
float get_clearcoat_gloss() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_anisotropy(float p_anisotropy);
|
|
|
|
float get_anisotropy() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-06-04 23:08:06 +02:00
|
|
|
void set_depth_scale(float p_depth_scale);
|
|
|
|
float get_depth_scale() const;
|
|
|
|
|
|
|
|
void set_depth_deep_parallax(bool p_enable);
|
|
|
|
bool is_depth_deep_parallax_enabled() const;
|
|
|
|
|
|
|
|
void set_depth_deep_parallax_min_layers(int p_layer);
|
|
|
|
int get_depth_deep_parallax_min_layers() const;
|
|
|
|
|
|
|
|
void set_depth_deep_parallax_max_layers(int p_layer);
|
|
|
|
int get_depth_deep_parallax_max_layers() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-08-11 21:10:05 +02:00
|
|
|
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
|
2016-12-03 02:23:16 +01:00
|
|
|
float get_subsurface_scattering_strength() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_refraction(float p_refraction);
|
|
|
|
float get_refraction() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-30 01:48:09 +02:00
|
|
|
void set_line_width(float p_line_width);
|
|
|
|
float get_line_width() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-30 01:48:09 +02:00
|
|
|
void set_point_size(float p_point_size);
|
|
|
|
float get_point_size() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_detail_uv(DetailUV p_detail_uv);
|
|
|
|
DetailUV get_detail_uv() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02: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 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_cull_mode(CullMode p_mode);
|
|
|
|
CullMode get_cull_mode() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-10-27 16:50:26 +02:00
|
|
|
void set_diffuse_mode(DiffuseMode p_mode);
|
|
|
|
DiffuseMode get_diffuse_mode() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-07-08 17:34:05 +02:00
|
|
|
void set_specular_mode(SpecularMode p_mode);
|
|
|
|
SpecularMode get_specular_mode() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_flag(Flags p_flag, bool p_enabled);
|
2016-10-27 16:50:26 +02:00
|
|
|
bool get_flag(Flags p_flag) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_texture(TextureParam p_param, const Ref<Texture> &p_texture);
|
2016-10-27 16:50:26 +02:00
|
|
|
Ref<Texture> get_texture(TextureParam p_param) const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_feature(Feature p_feature, bool p_enabled);
|
2016-10-27 16:50:26 +02:00
|
|
|
bool get_feature(Feature p_feature) const;
|
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
void set_uv1_scale(const Vector3 &p_scale);
|
|
|
|
Vector3 get_uv1_scale() const;
|
2016-11-21 02:49:53 +01:00
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
void set_uv1_offset(const Vector3 &p_offset);
|
|
|
|
Vector3 get_uv1_offset() const;
|
2016-11-21 02:49:53 +01:00
|
|
|
|
2017-07-08 13:06:13 +02:00
|
|
|
void set_uv1_triplanar_blend_sharpness(float p_sharpness);
|
|
|
|
float get_uv1_triplanar_blend_sharpness() const;
|
2016-11-21 02:49:53 +01:00
|
|
|
|
2017-07-08 13:06:13 +02: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 02:49:53 +01:00
|
|
|
|
2017-04-07 04:36:37 +02: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;
|
|
|
|
|
|
|
|
void set_particles_anim_loop(int p_frames);
|
|
|
|
int get_particles_anim_loop() const;
|
|
|
|
|
2017-07-08 17:34:05 +02:00
|
|
|
void set_grow_enabled(bool p_enable);
|
|
|
|
bool is_grow_enabled() const;
|
|
|
|
|
|
|
|
void set_grow(float p_grow);
|
|
|
|
float get_grow() const;
|
|
|
|
|
2017-08-08 22:23:44 +02:00
|
|
|
void set_alpha_scissor_threshold(float p_treshold);
|
|
|
|
float get_alpha_scissor_threshold() const;
|
|
|
|
|
2017-08-02 20:34:55 +02: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 16:50:26 +02:00
|
|
|
static void init_shaders();
|
|
|
|
static void finish_shaders();
|
|
|
|
static void flush_changes();
|
|
|
|
|
2017-08-08 22:23:44 +02: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);
|
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
SpatialMaterial();
|
|
|
|
virtual ~SpatialMaterial();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-04-07 04:36:37 +02:00
|
|
|
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)
|
2017-07-08 17:34:05 +02:00
|
|
|
VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
|
2017-04-07 04:36:37 +02:00
|
|
|
VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
|
2017-08-02 20:34:55 +02:00
|
|
|
VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel)
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//////////////////////
|
|
|
|
|
|
|
|
#endif
|