mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Split material.h.
This commit is contained in:
parent
ee245511fd
commit
11945d7f1d
@ -65,6 +65,8 @@
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/shader.h"
|
||||
#include "scene/resources/style_box.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
@ -50,6 +50,8 @@
|
||||
#include "scene/resources/resource_format_text.h"
|
||||
#include "core/scene/resources/shapes/shape.h"
|
||||
#include "core/scene/resources/shapes/sphere_shape.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
uint32_t EditorSceneImporter::get_import_flags() const {
|
||||
if (get_script_instance()) {
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include "core/string/ustring.h"
|
||||
#include "core/containers/vector.h"
|
||||
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
class AnimationTrackEditor;
|
||||
class AnimationPlayerEditorPlugin;
|
||||
class AcceptDialog;
|
||||
|
@ -62,6 +62,7 @@
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/environment_3d.h"
|
||||
#include "scene/resources/material/particles_material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/sky.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "core/object/class_db.h"
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/resources/mesh/immediate_mesh.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
#include "scene/3d/navigation_obstacle.h"
|
||||
|
||||
|
@ -62,6 +62,8 @@
|
||||
#include "editor/spatial_editor_gizmos.h"
|
||||
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
|
@ -93,6 +93,8 @@
|
||||
#include "core/scene/resources/shapes/cylinder_shape.h"
|
||||
#include "core/scene/resources/shapes/height_map_shape.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/navigation/navigation_mesh.h"
|
||||
#include "scene/resources/occluder_shape.h"
|
||||
#include "scene/resources/occluder_shape_polygon.h"
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "scene/main/spatial.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include "extensions/gltf_document_extension.h"
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#include "../singletons/ess.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int ESSMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "scene/resources/navigation/navigation_mesh.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name = p_name;
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "editor/pane_drag.h"
|
||||
#include "grid_map.h"
|
||||
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
class UndoRedo;
|
||||
class Panel;
|
||||
class MenuButton;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "scene/gui/option_button.h"
|
||||
#include "scene/gui/texture_rect.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
MMGraphNode *MMGradientEditor::get_graph_node() {
|
||||
return graph_node;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "mesh_data_instance.h"
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
#include "core/io/image.h"
|
||||
|
||||
|
@ -28,6 +28,7 @@ SOFTWARE.
|
||||
|
||||
#include "../nodes/mesh_data_instance.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
Ref<MeshDataResource> PropDataMeshData::get_mesh() const {
|
||||
return _mesh;
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#include "../singleton/prop_cache.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int PropMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -32,6 +32,8 @@ SOFTWARE.
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
#include "singleton/prop_cache.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -25,6 +25,7 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#include "../singleton/prop_2d_cache.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int Prop2DMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -24,6 +24,8 @@ SOFTWARE.
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -26,6 +26,8 @@ SOFTWARE.
|
||||
#include "scene/resources/texture.h"
|
||||
#include "terrain_surface.h"
|
||||
#include "terrain_surface_merger.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int TerrainMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -33,6 +33,8 @@ SOFTWARE.
|
||||
#include "../default/terrain_chunk_default.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -31,6 +31,8 @@ SOFTWARE.
|
||||
|
||||
#include "../default/terrain_chunk_default.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -24,6 +24,7 @@ SOFTWARE.
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -26,6 +26,7 @@ SOFTWARE.
|
||||
#include "scene/resources/texture.h"
|
||||
#include "terrain_2d_surface.h"
|
||||
#include "terrain_2d_surface_merger.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int Terrain2DMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "servers/navigation_2d_server.h"
|
||||
#include "core/servers/physics_2d/physics_2d_server.h"
|
||||
#include "servers/rendering/rendering_server_canvas_helper.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
#include "servers/navigation_server.h"
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "scene/resources/navigation_2d/navigation_polygon.h"
|
||||
#include "core/scene/resources/shapes_2d/shape_2d.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
class TileSet : public Resource {
|
||||
GDCLASS(TileSet, Resource);
|
||||
|
@ -24,6 +24,8 @@ SOFTWARE.
|
||||
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -25,6 +25,8 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -26,6 +26,8 @@ SOFTWARE.
|
||||
#include "scene/resources/texture.h"
|
||||
#include "voxel_surface.h"
|
||||
#include "voxel_surface_merger.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
int VoxelMaterialCachePCM::get_texture_flags() const {
|
||||
return _packer->get_texture_flags();
|
||||
|
@ -34,6 +34,8 @@ SOFTWARE.
|
||||
#include "../default/voxel_chunk_default.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -31,6 +31,8 @@ SOFTWARE.
|
||||
#include "../../library/voxel_material_cache.h"
|
||||
#include "../default/voxel_chunk_default.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "core/scene/resources/gradient.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/material/particles_material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "core/servers/rendering/rendering_server.h"
|
||||
|
||||
AABB CPUParticles::get_aabb() const {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/resources/font/font.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
class TriangleMesh;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "core/core_string_names.h"
|
||||
#include "physics_body.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/main/scene_string_names.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "scene/3d/navigation.h"
|
||||
#include "scene/3d/navigation_link_3d.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "servers/navigation/navigation_path_query_result_3d.h"
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "servers/navigation_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
void NavigationLink3D::_update_debug_mesh() {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "servers/navigation/navigation_mesh_generator.h"
|
||||
#include "servers/navigation_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
void NavigationMeshInstance::set_enabled(bool p_enabled) {
|
||||
if (enabled == p_enabled) {
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/main/spatial.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "core/scene/resources/shapes/shape.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "core/config/engine.h"
|
||||
#include "mesh_instance.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "core/servers/physics/physics_server.h"
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "mesh_instance.h"
|
||||
#include "core/scene/resources/shapes/concave_polygon_shape.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "core/object/reference.h"
|
||||
#include "scene/3d/visual_instance.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
class TriangleMesh;
|
||||
class SpriteFrames;
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "root_motion_view.h"
|
||||
#include "scene/animation/animation_tree.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
void RootMotionView::set_animation_path(const NodePath &p_path) {
|
||||
path = p_path;
|
||||
first = true;
|
||||
|
@ -48,6 +48,8 @@
|
||||
#include "scene/main/control.h"
|
||||
#include "scene/resources/font/dynamic_font.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/main/scene_string_names.h"
|
||||
|
@ -156,6 +156,8 @@
|
||||
#include "scene/resources/mesh/immediate_mesh.h"
|
||||
#include "core/scene/resources/shapes_2d/line_shape_2d.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#include "scene/resources/material/shader_material.h"
|
||||
#include "scene/resources/mesh/mesh.h"
|
||||
#include "scene/resources/mesh/mesh_data_tool.h"
|
||||
#include "scene/resources/mesh/multimesh.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,8 +35,6 @@
|
||||
#include "scene/resources/shader.h"
|
||||
#include "core/servers/rendering/rendering_server.h"
|
||||
|
||||
class Texture;
|
||||
|
||||
class Material : public Resource {
|
||||
GDCLASS(Material, Resource);
|
||||
RES_BASE_EXTENSION("material")
|
||||
@ -71,594 +69,4 @@ public:
|
||||
virtual ~Material();
|
||||
};
|
||||
|
||||
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;
|
||||
bool property_can_revert(const String &p_name);
|
||||
Variant property_get_revert(const String &p_name);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String "e_style) const;
|
||||
|
||||
virtual bool _can_do_next_pass() const;
|
||||
|
||||
void _shader_changed();
|
||||
|
||||
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;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
ShaderMaterial();
|
||||
~ShaderMaterial();
|
||||
};
|
||||
|
||||
class SpatialMaterial : public Material {
|
||||
GDCLASS(SpatialMaterial, Material);
|
||||
|
||||
public:
|
||||
enum TextureParam {
|
||||
TEXTURE_ALBEDO,
|
||||
TEXTURE_METALLIC,
|
||||
TEXTURE_ROUGHNESS,
|
||||
TEXTURE_EMISSION,
|
||||
TEXTURE_NORMAL,
|
||||
TEXTURE_RIM,
|
||||
TEXTURE_CLEARCOAT,
|
||||
TEXTURE_FLOWMAP,
|
||||
TEXTURE_AMBIENT_OCCLUSION,
|
||||
TEXTURE_DEPTH,
|
||||
TEXTURE_SUBSURFACE_SCATTERING,
|
||||
TEXTURE_TRANSMISSION,
|
||||
TEXTURE_REFRACTION,
|
||||
TEXTURE_DETAIL_MASK,
|
||||
TEXTURE_DETAIL_ALBEDO,
|
||||
TEXTURE_DETAIL_NORMAL,
|
||||
TEXTURE_MAX
|
||||
|
||||
};
|
||||
|
||||
enum DetailUV {
|
||||
DETAIL_UV_1,
|
||||
DETAIL_UV_2
|
||||
};
|
||||
|
||||
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_REFRACTION,
|
||||
FEATURE_DETAIL,
|
||||
FEATURE_MAX
|
||||
};
|
||||
|
||||
enum BlendMode {
|
||||
BLEND_MODE_MIX,
|
||||
BLEND_MODE_ADD,
|
||||
BLEND_MODE_SUB,
|
||||
BLEND_MODE_MUL,
|
||||
};
|
||||
|
||||
enum DepthDrawMode {
|
||||
DEPTH_DRAW_OPAQUE_ONLY,
|
||||
DEPTH_DRAW_ALWAYS,
|
||||
DEPTH_DRAW_DISABLED,
|
||||
DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
|
||||
|
||||
};
|
||||
|
||||
enum CullMode {
|
||||
CULL_BACK,
|
||||
CULL_FRONT,
|
||||
CULL_DISABLED
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
FLAG_UNSHADED,
|
||||
FLAG_USE_VERTEX_LIGHTING,
|
||||
FLAG_DISABLE_DEPTH_TEST,
|
||||
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
||||
FLAG_SRGB_VERTEX_COLOR,
|
||||
FLAG_USE_POINT_SIZE,
|
||||
FLAG_FIXED_SIZE,
|
||||
FLAG_BILLBOARD_KEEP_SCALE,
|
||||
FLAG_UV1_USE_TRIPLANAR,
|
||||
FLAG_UV2_USE_TRIPLANAR,
|
||||
FLAG_TRIPLANAR_USE_WORLD,
|
||||
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_ALBEDO_TEXTURE_SDF,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
enum DiffuseMode {
|
||||
DIFFUSE_BURLEY,
|
||||
DIFFUSE_LAMBERT,
|
||||
DIFFUSE_LAMBERT_WRAP,
|
||||
DIFFUSE_OREN_NAYAR,
|
||||
DIFFUSE_TOON,
|
||||
};
|
||||
|
||||
enum SpecularMode {
|
||||
SPECULAR_SCHLICK_GGX,
|
||||
SPECULAR_BLINN,
|
||||
SPECULAR_PHONG,
|
||||
SPECULAR_TOON,
|
||||
SPECULAR_DISABLED,
|
||||
};
|
||||
|
||||
enum BillboardMode {
|
||||
BILLBOARD_DISABLED,
|
||||
BILLBOARD_ENABLED,
|
||||
BILLBOARD_FIXED_Y,
|
||||
BILLBOARD_PARTICLES,
|
||||
};
|
||||
|
||||
enum TextureChannel {
|
||||
TEXTURE_CHANNEL_RED,
|
||||
TEXTURE_CHANNEL_GREEN,
|
||||
TEXTURE_CHANNEL_BLUE,
|
||||
TEXTURE_CHANNEL_ALPHA,
|
||||
TEXTURE_CHANNEL_GRAYSCALE
|
||||
};
|
||||
|
||||
enum EmissionOperator {
|
||||
EMISSION_OP_ADD,
|
||||
EMISSION_OP_MULTIPLY
|
||||
};
|
||||
|
||||
enum DistanceFadeMode {
|
||||
DISTANCE_FADE_DISABLED,
|
||||
DISTANCE_FADE_PIXEL_ALPHA,
|
||||
DISTANCE_FADE_PIXEL_DITHER,
|
||||
DISTANCE_FADE_OBJECT_DITHER,
|
||||
};
|
||||
|
||||
enum AsyncMode {
|
||||
ASYNC_MODE_VISIBLE,
|
||||
ASYNC_MODE_HIDDEN,
|
||||
};
|
||||
|
||||
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 : 20;
|
||||
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 reserved : 6;
|
||||
};
|
||||
|
||||
uint64_t key;
|
||||
|
||||
bool operator<(const MaterialKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShaderData {
|
||||
RID shader;
|
||||
int users;
|
||||
};
|
||||
|
||||
static RBMap<MaterialKey, ShaderData> shader_map;
|
||||
|
||||
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.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.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;
|
||||
|
||||
return mk;
|
||||
}
|
||||
|
||||
struct ShaderNames {
|
||||
StringName albedo;
|
||||
StringName specular;
|
||||
StringName metallic;
|
||||
StringName roughness;
|
||||
StringName emission;
|
||||
StringName emission_energy;
|
||||
StringName normal_scale;
|
||||
StringName rim;
|
||||
StringName rim_tint;
|
||||
StringName clearcoat;
|
||||
StringName clearcoat_gloss;
|
||||
StringName anisotropy;
|
||||
StringName depth_scale;
|
||||
StringName subsurface_scattering_strength;
|
||||
StringName transmission;
|
||||
StringName refraction;
|
||||
StringName point_size;
|
||||
StringName uv1_scale;
|
||||
StringName uv1_offset;
|
||||
StringName uv2_scale;
|
||||
StringName uv2_offset;
|
||||
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 uv1_blend_sharpness;
|
||||
StringName uv2_blend_sharpness;
|
||||
StringName grow;
|
||||
StringName proximity_fade_distance;
|
||||
StringName distance_fade_min;
|
||||
StringName distance_fade_max;
|
||||
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 refraction_texture_channel;
|
||||
StringName alpha_scissor_threshold;
|
||||
|
||||
StringName texture_names[TEXTURE_MAX];
|
||||
};
|
||||
|
||||
static Mutex material_mutex;
|
||||
static SelfList<SpatialMaterial>::List *dirty_materials;
|
||||
static ShaderNames *shader_names;
|
||||
|
||||
SelfList<SpatialMaterial> element;
|
||||
|
||||
void _update_shader();
|
||||
_FORCE_INLINE_ void _queue_shader_change();
|
||||
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
||||
|
||||
bool is_initialized = false;
|
||||
Color albedo;
|
||||
float specular;
|
||||
float metallic;
|
||||
float roughness;
|
||||
Color emission;
|
||||
float emission_energy;
|
||||
float normal_scale;
|
||||
float rim;
|
||||
float rim_tint;
|
||||
float clearcoat;
|
||||
float clearcoat_gloss;
|
||||
float anisotropy;
|
||||
float depth_scale;
|
||||
float subsurface_scattering_strength;
|
||||
Color transmission;
|
||||
float refraction;
|
||||
float line_width;
|
||||
float point_size;
|
||||
float alpha_scissor_threshold;
|
||||
bool grow_enabled;
|
||||
float ao_light_affect;
|
||||
float grow;
|
||||
int particles_anim_h_frames;
|
||||
int particles_anim_v_frames;
|
||||
bool particles_anim_loop;
|
||||
|
||||
Vector3 uv1_scale;
|
||||
Vector3 uv1_offset;
|
||||
float uv1_triplanar_sharpness;
|
||||
|
||||
Vector3 uv2_scale;
|
||||
Vector3 uv2_offset;
|
||||
float uv2_triplanar_sharpness;
|
||||
|
||||
DetailUV detail_uv;
|
||||
|
||||
bool deep_parallax;
|
||||
int deep_parallax_min_layers;
|
||||
int deep_parallax_max_layers;
|
||||
bool depth_parallax_flip_tangent;
|
||||
bool depth_parallax_flip_binormal;
|
||||
|
||||
bool proximity_fade_enabled;
|
||||
float proximity_fade_distance;
|
||||
|
||||
DistanceFadeMode distance_fade;
|
||||
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;
|
||||
BillboardMode billboard_mode;
|
||||
EmissionOperator emission_op;
|
||||
AsyncMode async_mode;
|
||||
|
||||
TextureChannel metallic_texture_channel;
|
||||
TextureChannel roughness_texture_channel;
|
||||
TextureChannel ao_texture_channel;
|
||||
TextureChannel refraction_texture_channel;
|
||||
|
||||
bool features[FEATURE_MAX];
|
||||
|
||||
Ref<Texture> textures[TEXTURE_MAX];
|
||||
|
||||
bool force_vertex_shading = false;
|
||||
|
||||
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
|
||||
|
||||
static HashMap<uint64_t, Ref<SpatialMaterial>> 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; }
|
||||
|
||||
public:
|
||||
void set_albedo(const Color &p_albedo);
|
||||
Color get_albedo() const;
|
||||
|
||||
void set_specular(float p_specular);
|
||||
float get_specular() const;
|
||||
|
||||
void set_metallic(float p_metallic);
|
||||
float get_metallic() const;
|
||||
|
||||
void set_roughness(float p_roughness);
|
||||
float get_roughness() const;
|
||||
|
||||
void set_emission(const Color &p_emission);
|
||||
Color get_emission() const;
|
||||
|
||||
void set_emission_energy(float p_emission_energy);
|
||||
float get_emission_energy() const;
|
||||
|
||||
void set_normal_scale(float p_normal_scale);
|
||||
float get_normal_scale() const;
|
||||
|
||||
void set_rim(float p_rim);
|
||||
float get_rim() const;
|
||||
|
||||
void set_rim_tint(float p_rim_tint);
|
||||
float get_rim_tint() const;
|
||||
|
||||
void set_ao_light_affect(float p_ao_light_affect);
|
||||
float get_ao_light_affect() const;
|
||||
|
||||
void set_clearcoat(float p_clearcoat);
|
||||
float get_clearcoat() const;
|
||||
|
||||
void set_clearcoat_gloss(float p_clearcoat_gloss);
|
||||
float get_clearcoat_gloss() const;
|
||||
|
||||
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_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;
|
||||
|
||||
void set_depth_deep_parallax_flip_tangent(bool p_flip);
|
||||
bool get_depth_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_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_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_detail_uv(DetailUV p_detail_uv);
|
||||
DetailUV get_detail_uv() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_cull_mode(CullMode p_mode);
|
||||
CullMode get_cull_mode() const;
|
||||
|
||||
void set_diffuse_mode(DiffuseMode p_mode);
|
||||
DiffuseMode get_diffuse_mode() const;
|
||||
|
||||
void set_specular_mode(SpecularMode p_mode);
|
||||
SpecularMode get_specular_mode() const;
|
||||
|
||||
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;
|
||||
// Used only for shader material conversion
|
||||
Ref<Texture> get_texture_by_name(StringName p_name) const;
|
||||
|
||||
void set_feature(Feature p_feature, bool p_enabled);
|
||||
bool get_feature(Feature p_feature) const;
|
||||
|
||||
void set_uv1_scale(const Vector3 &p_scale);
|
||||
Vector3 get_uv1_scale() const;
|
||||
|
||||
void set_uv1_offset(const Vector3 &p_offset);
|
||||
Vector3 get_uv1_offset() const;
|
||||
|
||||
void set_uv1_triplanar_blend_sharpness(float p_sharpness);
|
||||
float get_uv1_triplanar_blend_sharpness() const;
|
||||
|
||||
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;
|
||||
|
||||
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(bool p_loop);
|
||||
bool get_particles_anim_loop() const;
|
||||
|
||||
void set_grow_enabled(bool p_enable);
|
||||
bool is_grow_enabled() const;
|
||||
|
||||
void set_grow(float p_grow);
|
||||
float get_grow() const;
|
||||
|
||||
void set_alpha_scissor_threshold(float p_threshold);
|
||||
float get_alpha_scissor_threshold() const;
|
||||
|
||||
void set_on_top_of_alpha();
|
||||
|
||||
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;
|
||||
|
||||
void set_distance_fade(DistanceFadeMode p_mode);
|
||||
DistanceFadeMode get_distance_fade() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_emission_operator(EmissionOperator p_op);
|
||||
EmissionOperator get_emission_operator() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_async_mode(AsyncMode p_mode);
|
||||
AsyncMode get_async_mode() const;
|
||||
|
||||
static void init_shaders();
|
||||
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, bool p_no_depth_test = false, bool p_fixed_size = false, bool p_sdf = false);
|
||||
|
||||
RID get_shader_rid() const;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
SpatialMaterial();
|
||||
virtual ~SpatialMaterial();
|
||||
};
|
||||
|
||||
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)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::AsyncMode)
|
||||
|
||||
//////////////////////
|
||||
|
||||
#endif
|
||||
|
196
scene/resources/material/shader_material.cpp
Normal file
196
scene/resources/material/shader_material.cpp
Normal file
@ -0,0 +1,196 @@
|
||||
/*************************************************************************/
|
||||
/* material.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 */
|
||||
/* "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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_material.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/version.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "servers/rendering/shader_language.h"
|
||||
|
||||
#include "scene/main/scene_string_names.h"
|
||||
|
||||
bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (!pr) {
|
||||
String n = p_name;
|
||||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_param/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_param/", "");
|
||||
}
|
||||
}
|
||||
if (pr) {
|
||||
RenderingServer::get_singleton()->material_set_param(_get_material(), pr, p_value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (!pr) {
|
||||
String n = p_name;
|
||||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_param/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_param/", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (pr) {
|
||||
r_ret = RenderingServer::get_singleton()->material_get_param(_get_material(), pr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
if (!shader.is_null()) {
|
||||
shader->get_param_list(p_list);
|
||||
}
|
||||
}
|
||||
|
||||
bool ShaderMaterial::property_can_revert(const String &p_name) {
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (pr) {
|
||||
Variant default_value = RenderingServer::get_singleton()->material_get_param_default(_get_material(), pr);
|
||||
Variant current_value;
|
||||
_get(p_name, current_value);
|
||||
return default_value.get_type() != Variant::NIL && default_value != current_value;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Variant ShaderMaterial::property_get_revert(const String &p_name) {
|
||||
Variant r_ret;
|
||||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (pr) {
|
||||
r_ret = RenderingServer::get_singleton()->material_get_param_default(_get_material(), pr);
|
||||
}
|
||||
}
|
||||
return r_ret;
|
||||
}
|
||||
|
||||
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
|
||||
// Only connect/disconnect the signal when running in the editor.
|
||||
// This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
|
||||
// does nothing in non-editor builds anyway. See GH-34741 for details.
|
||||
if (shader.is_valid() && Engine::get_singleton()->is_editor_hint()) {
|
||||
shader->disconnect("changed", this, "_shader_changed");
|
||||
}
|
||||
|
||||
shader = p_shader;
|
||||
|
||||
RID rid;
|
||||
if (shader.is_valid()) {
|
||||
rid = shader->get_rid();
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
shader->connect("changed", this, "_shader_changed");
|
||||
}
|
||||
}
|
||||
|
||||
RS::get_singleton()->material_set_shader(_get_material(), rid);
|
||||
_change_notify(); //properties for shader exposed
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<Shader> ShaderMaterial::get_shader() const {
|
||||
return shader;
|
||||
}
|
||||
|
||||
void ShaderMaterial::set_shader_param(const StringName &p_param, const Variant &p_value) {
|
||||
RS::get_singleton()->material_set_param(_get_material(), p_param, p_value);
|
||||
}
|
||||
|
||||
Variant ShaderMaterial::get_shader_param(const StringName &p_param) const {
|
||||
return RS::get_singleton()->material_get_param(_get_material(), p_param);
|
||||
}
|
||||
|
||||
void ShaderMaterial::_shader_changed() {
|
||||
_change_notify(); //update all properties
|
||||
}
|
||||
|
||||
void ShaderMaterial::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_shader", "shader"), &ShaderMaterial::set_shader);
|
||||
ClassDB::bind_method(D_METHOD("get_shader"), &ShaderMaterial::get_shader);
|
||||
ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param);
|
||||
ClassDB::bind_method(D_METHOD("get_shader_param", "param"), &ShaderMaterial::get_shader_param);
|
||||
ClassDB::bind_method(D_METHOD("_shader_changed"), &ShaderMaterial::_shader_changed);
|
||||
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ShaderMaterial::property_can_revert);
|
||||
ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ShaderMaterial::property_get_revert);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader");
|
||||
}
|
||||
|
||||
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String "e_style) const {
|
||||
String f = p_function.operator String();
|
||||
if ((f == "get_shader_param" || f == "set_shader_param") && p_idx == 0) {
|
||||
if (shader.is_valid()) {
|
||||
List<PropertyInfo> pl;
|
||||
shader->get_param_list(&pl);
|
||||
for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) {
|
||||
r_options->push_back(quote_style + E->get().name.replace_first("shader_param/", "") + quote_style);
|
||||
}
|
||||
}
|
||||
}
|
||||
Resource::get_argument_options(p_function, p_idx, r_options, quote_style);
|
||||
}
|
||||
|
||||
bool ShaderMaterial::_can_do_next_pass() const {
|
||||
return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL;
|
||||
}
|
||||
|
||||
Shader::Mode ShaderMaterial::get_shader_mode() const {
|
||||
if (shader.is_valid()) {
|
||||
return shader->get_mode();
|
||||
} else {
|
||||
return Shader::MODE_SPATIAL;
|
||||
}
|
||||
}
|
||||
|
||||
ShaderMaterial::ShaderMaterial() {
|
||||
}
|
||||
|
||||
ShaderMaterial::~ShaderMaterial() {
|
||||
}
|
76
scene/resources/material/shader_material.h
Normal file
76
scene/resources/material/shader_material.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef SHADER_MATERIAL_H
|
||||
#define SHADER_MATERIAL_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* material.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 */
|
||||
/* "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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/object/resource.h"
|
||||
#include "core/containers/self_list.h"
|
||||
|
||||
#include "scene/resources/material/material.h"
|
||||
|
||||
#include "scene/resources/shader.h"
|
||||
#include "core/servers/rendering/rendering_server.h"
|
||||
|
||||
class Texture;
|
||||
|
||||
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;
|
||||
bool property_can_revert(const String &p_name);
|
||||
Variant property_get_revert(const String &p_name);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options, const String "e_style) const;
|
||||
|
||||
virtual bool _can_do_next_pass() const;
|
||||
|
||||
void _shader_changed();
|
||||
|
||||
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;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
ShaderMaterial();
|
||||
~ShaderMaterial();
|
||||
};
|
||||
|
||||
#endif
|
2167
scene/resources/material/spatial_material.cpp
Normal file
2167
scene/resources/material/spatial_material.cpp
Normal file
File diff suppressed because it is too large
Load Diff
601
scene/resources/material/spatial_material.h
Normal file
601
scene/resources/material/spatial_material.h
Normal file
@ -0,0 +1,601 @@
|
||||
#ifndef SPATIAL_MATERIAL_H
|
||||
#define SPATIAL_MATERIAL_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* material.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 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 */
|
||||
/* "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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/containers/self_list.h"
|
||||
|
||||
#include "scene/resources/material/material.h"
|
||||
|
||||
#include "scene/resources/shader.h"
|
||||
#include "core/servers/rendering/rendering_server.h"
|
||||
|
||||
class Texture;
|
||||
|
||||
class SpatialMaterial : public Material {
|
||||
GDCLASS(SpatialMaterial, Material);
|
||||
|
||||
public:
|
||||
enum TextureParam {
|
||||
TEXTURE_ALBEDO,
|
||||
TEXTURE_METALLIC,
|
||||
TEXTURE_ROUGHNESS,
|
||||
TEXTURE_EMISSION,
|
||||
TEXTURE_NORMAL,
|
||||
TEXTURE_RIM,
|
||||
TEXTURE_CLEARCOAT,
|
||||
TEXTURE_FLOWMAP,
|
||||
TEXTURE_AMBIENT_OCCLUSION,
|
||||
TEXTURE_DEPTH,
|
||||
TEXTURE_SUBSURFACE_SCATTERING,
|
||||
TEXTURE_TRANSMISSION,
|
||||
TEXTURE_REFRACTION,
|
||||
TEXTURE_DETAIL_MASK,
|
||||
TEXTURE_DETAIL_ALBEDO,
|
||||
TEXTURE_DETAIL_NORMAL,
|
||||
TEXTURE_MAX
|
||||
|
||||
};
|
||||
|
||||
enum DetailUV {
|
||||
DETAIL_UV_1,
|
||||
DETAIL_UV_2
|
||||
};
|
||||
|
||||
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_REFRACTION,
|
||||
FEATURE_DETAIL,
|
||||
FEATURE_MAX
|
||||
};
|
||||
|
||||
enum BlendMode {
|
||||
BLEND_MODE_MIX,
|
||||
BLEND_MODE_ADD,
|
||||
BLEND_MODE_SUB,
|
||||
BLEND_MODE_MUL,
|
||||
};
|
||||
|
||||
enum DepthDrawMode {
|
||||
DEPTH_DRAW_OPAQUE_ONLY,
|
||||
DEPTH_DRAW_ALWAYS,
|
||||
DEPTH_DRAW_DISABLED,
|
||||
DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
|
||||
|
||||
};
|
||||
|
||||
enum CullMode {
|
||||
CULL_BACK,
|
||||
CULL_FRONT,
|
||||
CULL_DISABLED
|
||||
};
|
||||
|
||||
enum Flags {
|
||||
FLAG_UNSHADED,
|
||||
FLAG_USE_VERTEX_LIGHTING,
|
||||
FLAG_DISABLE_DEPTH_TEST,
|
||||
FLAG_ALBEDO_FROM_VERTEX_COLOR,
|
||||
FLAG_SRGB_VERTEX_COLOR,
|
||||
FLAG_USE_POINT_SIZE,
|
||||
FLAG_FIXED_SIZE,
|
||||
FLAG_BILLBOARD_KEEP_SCALE,
|
||||
FLAG_UV1_USE_TRIPLANAR,
|
||||
FLAG_UV2_USE_TRIPLANAR,
|
||||
FLAG_TRIPLANAR_USE_WORLD,
|
||||
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_ALBEDO_TEXTURE_SDF,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
enum DiffuseMode {
|
||||
DIFFUSE_BURLEY,
|
||||
DIFFUSE_LAMBERT,
|
||||
DIFFUSE_LAMBERT_WRAP,
|
||||
DIFFUSE_OREN_NAYAR,
|
||||
DIFFUSE_TOON,
|
||||
};
|
||||
|
||||
enum SpecularMode {
|
||||
SPECULAR_SCHLICK_GGX,
|
||||
SPECULAR_BLINN,
|
||||
SPECULAR_PHONG,
|
||||
SPECULAR_TOON,
|
||||
SPECULAR_DISABLED,
|
||||
};
|
||||
|
||||
enum BillboardMode {
|
||||
BILLBOARD_DISABLED,
|
||||
BILLBOARD_ENABLED,
|
||||
BILLBOARD_FIXED_Y,
|
||||
BILLBOARD_PARTICLES,
|
||||
};
|
||||
|
||||
enum TextureChannel {
|
||||
TEXTURE_CHANNEL_RED,
|
||||
TEXTURE_CHANNEL_GREEN,
|
||||
TEXTURE_CHANNEL_BLUE,
|
||||
TEXTURE_CHANNEL_ALPHA,
|
||||
TEXTURE_CHANNEL_GRAYSCALE
|
||||
};
|
||||
|
||||
enum EmissionOperator {
|
||||
EMISSION_OP_ADD,
|
||||
EMISSION_OP_MULTIPLY
|
||||
};
|
||||
|
||||
enum DistanceFadeMode {
|
||||
DISTANCE_FADE_DISABLED,
|
||||
DISTANCE_FADE_PIXEL_ALPHA,
|
||||
DISTANCE_FADE_PIXEL_DITHER,
|
||||
DISTANCE_FADE_OBJECT_DITHER,
|
||||
};
|
||||
|
||||
enum AsyncMode {
|
||||
ASYNC_MODE_VISIBLE,
|
||||
ASYNC_MODE_HIDDEN,
|
||||
};
|
||||
|
||||
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 : 20;
|
||||
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 reserved : 6;
|
||||
};
|
||||
|
||||
uint64_t key;
|
||||
|
||||
bool operator<(const MaterialKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShaderData {
|
||||
RID shader;
|
||||
int users;
|
||||
};
|
||||
|
||||
static RBMap<MaterialKey, ShaderData> shader_map;
|
||||
|
||||
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.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.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;
|
||||
|
||||
return mk;
|
||||
}
|
||||
|
||||
struct ShaderNames {
|
||||
StringName albedo;
|
||||
StringName specular;
|
||||
StringName metallic;
|
||||
StringName roughness;
|
||||
StringName emission;
|
||||
StringName emission_energy;
|
||||
StringName normal_scale;
|
||||
StringName rim;
|
||||
StringName rim_tint;
|
||||
StringName clearcoat;
|
||||
StringName clearcoat_gloss;
|
||||
StringName anisotropy;
|
||||
StringName depth_scale;
|
||||
StringName subsurface_scattering_strength;
|
||||
StringName transmission;
|
||||
StringName refraction;
|
||||
StringName point_size;
|
||||
StringName uv1_scale;
|
||||
StringName uv1_offset;
|
||||
StringName uv2_scale;
|
||||
StringName uv2_offset;
|
||||
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 uv1_blend_sharpness;
|
||||
StringName uv2_blend_sharpness;
|
||||
StringName grow;
|
||||
StringName proximity_fade_distance;
|
||||
StringName distance_fade_min;
|
||||
StringName distance_fade_max;
|
||||
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 refraction_texture_channel;
|
||||
StringName alpha_scissor_threshold;
|
||||
|
||||
StringName texture_names[TEXTURE_MAX];
|
||||
};
|
||||
|
||||
static Mutex material_mutex;
|
||||
static SelfList<SpatialMaterial>::List *dirty_materials;
|
||||
static ShaderNames *shader_names;
|
||||
|
||||
SelfList<SpatialMaterial> element;
|
||||
|
||||
void _update_shader();
|
||||
_FORCE_INLINE_ void _queue_shader_change();
|
||||
_FORCE_INLINE_ bool _is_shader_dirty() const;
|
||||
|
||||
bool is_initialized = false;
|
||||
Color albedo;
|
||||
float specular;
|
||||
float metallic;
|
||||
float roughness;
|
||||
Color emission;
|
||||
float emission_energy;
|
||||
float normal_scale;
|
||||
float rim;
|
||||
float rim_tint;
|
||||
float clearcoat;
|
||||
float clearcoat_gloss;
|
||||
float anisotropy;
|
||||
float depth_scale;
|
||||
float subsurface_scattering_strength;
|
||||
Color transmission;
|
||||
float refraction;
|
||||
float line_width;
|
||||
float point_size;
|
||||
float alpha_scissor_threshold;
|
||||
bool grow_enabled;
|
||||
float ao_light_affect;
|
||||
float grow;
|
||||
int particles_anim_h_frames;
|
||||
int particles_anim_v_frames;
|
||||
bool particles_anim_loop;
|
||||
|
||||
Vector3 uv1_scale;
|
||||
Vector3 uv1_offset;
|
||||
float uv1_triplanar_sharpness;
|
||||
|
||||
Vector3 uv2_scale;
|
||||
Vector3 uv2_offset;
|
||||
float uv2_triplanar_sharpness;
|
||||
|
||||
DetailUV detail_uv;
|
||||
|
||||
bool deep_parallax;
|
||||
int deep_parallax_min_layers;
|
||||
int deep_parallax_max_layers;
|
||||
bool depth_parallax_flip_tangent;
|
||||
bool depth_parallax_flip_binormal;
|
||||
|
||||
bool proximity_fade_enabled;
|
||||
float proximity_fade_distance;
|
||||
|
||||
DistanceFadeMode distance_fade;
|
||||
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;
|
||||
BillboardMode billboard_mode;
|
||||
EmissionOperator emission_op;
|
||||
AsyncMode async_mode;
|
||||
|
||||
TextureChannel metallic_texture_channel;
|
||||
TextureChannel roughness_texture_channel;
|
||||
TextureChannel ao_texture_channel;
|
||||
TextureChannel refraction_texture_channel;
|
||||
|
||||
bool features[FEATURE_MAX];
|
||||
|
||||
Ref<Texture> textures[TEXTURE_MAX];
|
||||
|
||||
bool force_vertex_shading = false;
|
||||
|
||||
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
|
||||
|
||||
static HashMap<uint64_t, Ref<SpatialMaterial>> 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; }
|
||||
|
||||
public:
|
||||
void set_albedo(const Color &p_albedo);
|
||||
Color get_albedo() const;
|
||||
|
||||
void set_specular(float p_specular);
|
||||
float get_specular() const;
|
||||
|
||||
void set_metallic(float p_metallic);
|
||||
float get_metallic() const;
|
||||
|
||||
void set_roughness(float p_roughness);
|
||||
float get_roughness() const;
|
||||
|
||||
void set_emission(const Color &p_emission);
|
||||
Color get_emission() const;
|
||||
|
||||
void set_emission_energy(float p_emission_energy);
|
||||
float get_emission_energy() const;
|
||||
|
||||
void set_normal_scale(float p_normal_scale);
|
||||
float get_normal_scale() const;
|
||||
|
||||
void set_rim(float p_rim);
|
||||
float get_rim() const;
|
||||
|
||||
void set_rim_tint(float p_rim_tint);
|
||||
float get_rim_tint() const;
|
||||
|
||||
void set_ao_light_affect(float p_ao_light_affect);
|
||||
float get_ao_light_affect() const;
|
||||
|
||||
void set_clearcoat(float p_clearcoat);
|
||||
float get_clearcoat() const;
|
||||
|
||||
void set_clearcoat_gloss(float p_clearcoat_gloss);
|
||||
float get_clearcoat_gloss() const;
|
||||
|
||||
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_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;
|
||||
|
||||
void set_depth_deep_parallax_flip_tangent(bool p_flip);
|
||||
bool get_depth_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_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_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_detail_uv(DetailUV p_detail_uv);
|
||||
DetailUV get_detail_uv() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_cull_mode(CullMode p_mode);
|
||||
CullMode get_cull_mode() const;
|
||||
|
||||
void set_diffuse_mode(DiffuseMode p_mode);
|
||||
DiffuseMode get_diffuse_mode() const;
|
||||
|
||||
void set_specular_mode(SpecularMode p_mode);
|
||||
SpecularMode get_specular_mode() const;
|
||||
|
||||
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;
|
||||
// Used only for shader material conversion
|
||||
Ref<Texture> get_texture_by_name(StringName p_name) const;
|
||||
|
||||
void set_feature(Feature p_feature, bool p_enabled);
|
||||
bool get_feature(Feature p_feature) const;
|
||||
|
||||
void set_uv1_scale(const Vector3 &p_scale);
|
||||
Vector3 get_uv1_scale() const;
|
||||
|
||||
void set_uv1_offset(const Vector3 &p_offset);
|
||||
Vector3 get_uv1_offset() const;
|
||||
|
||||
void set_uv1_triplanar_blend_sharpness(float p_sharpness);
|
||||
float get_uv1_triplanar_blend_sharpness() const;
|
||||
|
||||
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;
|
||||
|
||||
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(bool p_loop);
|
||||
bool get_particles_anim_loop() const;
|
||||
|
||||
void set_grow_enabled(bool p_enable);
|
||||
bool is_grow_enabled() const;
|
||||
|
||||
void set_grow(float p_grow);
|
||||
float get_grow() const;
|
||||
|
||||
void set_alpha_scissor_threshold(float p_threshold);
|
||||
float get_alpha_scissor_threshold() const;
|
||||
|
||||
void set_on_top_of_alpha();
|
||||
|
||||
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;
|
||||
|
||||
void set_distance_fade(DistanceFadeMode p_mode);
|
||||
DistanceFadeMode get_distance_fade() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_emission_operator(EmissionOperator p_op);
|
||||
EmissionOperator get_emission_operator() const;
|
||||
|
||||
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;
|
||||
|
||||
void set_async_mode(AsyncMode p_mode);
|
||||
AsyncMode get_async_mode() const;
|
||||
|
||||
static void init_shaders();
|
||||
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, bool p_no_depth_test = false, bool p_fixed_size = false, bool p_sdf = false);
|
||||
|
||||
RID get_shader_rid() const;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const;
|
||||
|
||||
SpatialMaterial();
|
||||
virtual ~SpatialMaterial();
|
||||
};
|
||||
|
||||
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)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::AsyncMode)
|
||||
|
||||
//////////////////////
|
||||
|
||||
#endif
|
@ -31,6 +31,7 @@
|
||||
#include "navigation_mesh.h"
|
||||
|
||||
#include "servers/navigation_server.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
|
||||
void NavigationMesh::create_from_mesh(const Ref<Mesh> &p_mesh) {
|
||||
ERR_FAIL_COND(p_mesh.is_null());
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "core/config/engine.h"
|
||||
#include "core/config/project_settings.h"
|
||||
#include "scene/resources/material/material.h"
|
||||
#include "scene/resources/material/spatial_material.h"
|
||||
#endif
|
||||
|
||||
NavigationServer *NavigationServer::singleton = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user