From b9cbffd957a342d61a17c9a224c43aa9bb06c536 Mon Sep 17 00:00:00 2001 From: Ansraer Date: Thu, 8 Feb 2024 20:10:26 +0100 Subject: [PATCH] add ORMSpatialMaterial --- doc/classes/CPUParticles.xml | 8 +- doc/classes/EditorSpatialGizmoPlugin.xml | 4 +- doc/classes/Label3D.xml | 4 +- doc/classes/Material3D.xml | 668 +++++++++++++++++ doc/classes/MultiMesh.xml | 2 +- doc/classes/ORMSpatialMaterial.xml | 15 + doc/classes/ParticlesMaterial.xml | 12 +- doc/classes/PointMesh.xml | 2 +- doc/classes/PrimitiveMesh.xml | 2 +- doc/classes/ProjectSettings.xml | 6 +- doc/classes/SpatialMaterial.xml | 656 +---------------- doc/classes/SpriteBase3D.xml | 6 +- doc/classes/SurfaceTool.xml | 2 +- doc/classes/VisualServer.xml | 2 +- editor/editor_resource_picker.cpp | 17 +- editor/icons/icon_o_r_m_spatial_material.svg | 1 + editor/import/editor_import_collada.cpp | 32 +- editor/import/resource_importer_obj.cpp | 22 +- editor/import/resource_importer_scene.cpp | 8 +- .../collision_polygon_editor_plugin.cpp | 24 +- .../plugins/collision_polygon_editor_plugin.h | 4 +- editor/plugins/material_editor_plugin.cpp | 4 +- .../plugins/mesh_instance_editor_plugin.cpp | 2 +- editor/plugins/path_editor_plugin.cpp | 6 +- editor/plugins/spatial_editor_plugin.cpp | 124 ++-- editor/plugins/spatial_editor_plugin.h | 18 +- editor/spatial_editor_gizmos.cpp | 16 +- modules/bullet/space_bullet.cpp | 22 +- modules/csg/csg_shape.cpp | 12 +- modules/fbx/data/fbx_material.cpp | 91 +-- modules/fbx/data/fbx_material.h | 140 ++-- modules/fbx/data/fbx_mesh_data.cpp | 2 +- modules/fbx/data/import_state.h | 2 +- modules/fbx/editor_scene_importer_fbx.cpp | 2 +- modules/gltf/gltf_document.cpp | 138 ++-- modules/gltf/gltf_document.h | 8 +- modules/gridmap/grid_map_editor_plugin.cpp | 18 +- modules/gridmap/grid_map_editor_plugin.h | 8 +- scene/3d/baked_lightmap.cpp | 8 +- scene/3d/cpu_particles.cpp | 8 +- scene/3d/label_3d.cpp | 8 +- scene/3d/label_3d.h | 6 +- scene/3d/mesh_instance.cpp | 16 +- scene/3d/particles.cpp | 8 +- scene/3d/ray_cast.cpp | 12 +- scene/3d/ray_cast.h | 2 +- scene/3d/shape_cast.cpp | 12 +- scene/3d/shape_cast.h | 2 +- scene/3d/sprite_3d.cpp | 8 +- scene/3d/sprite_3d.h | 6 +- scene/3d/visual_instance.cpp | 4 +- scene/3d/voxel_light_baker.cpp | 18 +- scene/animation/root_motion_view.cpp | 2 +- scene/main/scene_tree.cpp | 40 +- scene/register_scene_types.cpp | 8 +- scene/resources/material.cpp | 672 ++++++++++-------- scene/resources/material.h | 58 +- scene/resources/mesh.cpp | 2 +- scene/resources/primitive_meshes.cpp | 2 +- 59 files changed, 1568 insertions(+), 1444 deletions(-) create mode 100644 doc/classes/Material3D.xml create mode 100644 doc/classes/ORMSpatialMaterial.xml create mode 100644 editor/icons/icon_o_r_m_spatial_material.svg diff --git a/doc/classes/CPUParticles.xml b/doc/classes/CPUParticles.xml index 376cc5102d5..d51db182471 100644 --- a/doc/classes/CPUParticles.xml +++ b/doc/classes/CPUParticles.xml @@ -128,15 +128,15 @@ Each particle's initial color. - [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. + [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. Each particle's initial color will vary along this [GradientTexture] (multiplied with [member color]). - [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. + [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). - [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. + [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. The rate at which particles lose velocity. @@ -158,7 +158,7 @@ Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. - [b]Note:[/b] [member emission_colors] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_colors] will have no visible effect. + [b]Note:[/b] [member emission_colors] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_colors] will have no visible effect. Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. diff --git a/doc/classes/EditorSpatialGizmoPlugin.xml b/doc/classes/EditorSpatialGizmoPlugin.xml index ce2efc98d0d..e6b231d8564 100644 --- a/doc/classes/EditorSpatialGizmoPlugin.xml +++ b/doc/classes/EditorSpatialGizmoPlugin.xml @@ -14,7 +14,7 @@ - + Adds a new material to the internal material list for the plugin. It can then be accessed with [method get_material]. Should not be overridden. @@ -90,7 +90,7 @@ - + diff --git a/doc/classes/Label3D.xml b/doc/classes/Label3D.xml index ebe57bf6e30..2750b33d5e1 100644 --- a/doc/classes/Label3D.xml +++ b/doc/classes/Label3D.xml @@ -41,8 +41,8 @@ If [code]true[/code], wraps the text to the [member width]. - - The billboard mode to use for the label. See [enum SpatialMaterial.BillboardMode] for possible values. + + The billboard mode to use for the label. See [enum Material3D.BillboardMode] for possible values. If [code]true[/code], text can be seen from the back as well, if [code]false[/code], it is invisible when looking at it from behind. diff --git a/doc/classes/Material3D.xml b/doc/classes/Material3D.xml new file mode 100644 index 00000000000..12fe4d9885e --- /dev/null +++ b/doc/classes/Material3D.xml @@ -0,0 +1,668 @@ + + + + + + + + + + + + + + Returns [code]true[/code], if the specified [enum Feature] is enabled. + + + + + + + Returns [code]true[/code], if the specified flag is enabled. See [enum Flags] enumerator for options. + + + + + + + Returns the [Texture] associated with the specified [enum TextureParam]. + + + + + + + + If [code]true[/code], enables the specified [enum Feature]. Many features that are available in [SpatialMaterial]s need to be enabled before use. This way the cost for using the feature is only incurred when specified. Features can also be enabled by setting the corresponding member to [code]true[/code]. + + + + + + + + If [code]true[/code], enables the specified flag. Flags are optional behavior that can be turned on and off. Only one flag can be enabled at a time with this function, the flag enumerators cannot be bit-masked together to enable or disable multiple flags at once. Flags can also be enabled by setting the corresponding member to [code]true[/code]. See [enum Flags] enumerator for options. + + + + + + + + Sets the [Texture] to be used by the specified [enum TextureParam]. This function is called when setting members ending in [code]*_texture[/code]. + + + + + + The material's base color. + + + Texture to multiply by [member albedo_color]. Used for basic texturing of objects. + + + The strength of the anisotropy effect. This is multiplied by [member anisotropy_flowmap]'s alpha channel if a texture is defined there and the texture contains an alpha channel. + + + If [code]true[/code], anisotropy is enabled. Anisotropy changes the shape of the specular blob and aligns it to tangent space. This is useful for brushed aluminium and hair reflections. + [b]Note:[/b] Mesh tangents are needed for anisotropy to work. If the mesh does not contain tangents, the anisotropy effect will appear broken. + [b]Note:[/b] Material anisotropy should not to be confused with anisotropic texture filtering. Anisotropic texture filtering can be enabled by selecting a texture in the FileSystem dock, going to the Import dock, checking the [b]Anisotropic[/b] checkbox then clicking [b]Reimport[/b]. The anisotropic filtering level can be changed by adjusting [member ProjectSettings.rendering/quality/filters/anisotropic_filter_level]. + + + Texture that offsets the tangent map for anisotropy calculations and optionally controls the anisotropy effect (if an alpha channel is present). The flowmap texture is expected to be a derivative map, with the red channel representing distortion on the X axis and green channel representing distortion on the Y axis. Values below 0.5 will result in negative distortion, whereas values above 0.5 will result in positive distortion. + If present, the texture's alpha channel will be used to multiply the strength of the [member anisotropy] effect. Fully opaque pixels will keep the anisotropy effect's original strength while fully transparent pixels will disable the anisotropy effect entirely. The flowmap texture's blue channel is ignored. + + + If [code]true[/code], ambient occlusion is enabled. Ambient occlusion darkens areas based on the [member ao_texture]. + + + Amount that ambient occlusion affects lighting from lights. If [code]0[/code], ambient occlusion only affects ambient light. If [code]1[/code], ambient occlusion affects lights just as much as it affects ambient light. This can be used to impact the strength of the ambient occlusion effect, but typically looks unrealistic. + + + If [code]true[/code], use [code]UV2[/code] coordinates to look up from the [member ao_texture]. + + + Texture that defines the amount of ambient occlusion for a given point on the object. + + + Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. + + + If [member ProjectSettings.rendering/gles3/shaders/shader_compilation_mode] is [code]Synchronous[/code] (with or without cache), this determines how this material must behave in regards to asynchronous shader compilation. + [constant ASYNC_MODE_VISIBLE] is the default and the best for most cases. + + + Sets the strength of the clearcoat effect. Setting to [code]0[/code] looks the same as disabling the clearcoat effect. + + + If [code]true[/code], clearcoat rendering is enabled. Adds a secondary transparent pass to the lighting calculation resulting in an added specular blob. This makes materials appear as if they have a clear layer on them that can be either glossy or rough. + [b]Note:[/b] Clearcoat rendering is not visible if the material has [member flags_unshaded] set to [code]true[/code]. + + + Sets the roughness of the clearcoat pass. A higher value results in a smoother clearcoat while a lower value results in a rougher clearcoat. + + + Texture that defines the strength of the clearcoat effect and the glossiness of the clearcoat. Strength is specified in the red channel while glossiness is specified in the green channel. + + + If [code]true[/code], the shader will read depth texture at multiple points along the view ray to determine occlusion and parrallax. This can be very performance demanding, but results in more realistic looking depth mapping. + + + If [code]true[/code], depth mapping is enabled (also called "parallax mapping" or "height mapping"). See also [member normal_enabled]. + [b]Note:[/b] Depth mapping is not supported if triplanar mapping is used on the same material. The value of [member depth_enabled] will be ignored if [member uv1_triplanar] is enabled. + + + If [code]true[/code], direction of the binormal is flipped before using in the depth effect. This may be necessary if you have encoded your binormals in a way that is conflicting with the depth effect. + + + If [code]true[/code], direction of the tangent is flipped before using in the depth effect. This may be necessary if you have encoded your tangents in a way that is conflicting with the depth effect. + + + Number of layers to use when using [member depth_deep_parallax] and the view direction is perpendicular to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp. + + + Number of layers to use when using [member depth_deep_parallax] and the view direction is parallel to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp. + + + Scales the depth offset effect. A higher number will create a larger depth. + + + Texture used to determine depth at a given pixel. Depth is always stored in the red channel. + + + Texture that specifies the color of the detail overlay. + + + Specifies how the [member detail_albedo] should blend with the current [code]ALBEDO[/code]. See [enum BlendMode] for options. + + + If [code]true[/code], enables the detail overlay. Detail is a second texture that gets mixed over the surface of the object based on [member detail_mask]. This can be used to add variation to objects, or to blend between two different albedo/normal textures. + + + Texture used to specify how the detail textures get blended with the base textures. + + + Texture that specifies the per-pixel normal of the detail overlay. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + + + Specifies whether to use [code]UV[/code] or [code]UV2[/code] for the detail layer. See [enum DetailUV] for options. + + + Distance at which the object appears fully opaque. + [b]Note:[/b] If [code]distance_fade_max_distance[/code] is less than [code]distance_fade_min_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. + + + Distance at which the object starts to become visible. If the object is less than this distance away, it will be invisible. + [b]Note:[/b] If [code]distance_fade_min_distance[/code] is greater than [code]distance_fade_max_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. + + + Specifies which type of fade to use. Can be any of the [enum DistanceFadeMode]s. + + + The emitted light's color. See [member emission_enabled]. + + + If [code]true[/code], the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a [GIProbe] or [BakedLightmap] is used and this object is used in baked lighting. + + + The emitted light's strength. See [member emission_enabled]. + + + Use [code]UV2[/code] to read from the [member emission_texture]. + + + Sets how [member emission] interacts with [member emission_texture]. Can either add or multiply. See [enum EmissionOperator] for options. + + + Texture that specifies how much surface emits light at a given point. + + + Forces a conversion of the [member albedo_texture] from sRGB space to linear space. + + + Enables signed distance field rendering shader. + + + If [code]true[/code], the object receives no ambient light. + + + If [code]true[/code], the object receives no shadow that would otherwise be cast onto it. + + + If [code]true[/code], the shader will compute extra operations to make sure the normal stays correct when using a non-uniform scale. Only enable if using non-uniform scaling. + + + If [code]true[/code], the object is rendered at the same size regardless of distance. + + + If [code]true[/code], depth testing is disabled and the object will be drawn in render order. + + + If [code]true[/code], transparency is enabled on the body. See also [member params_blend_mode]. + + + If [code]true[/code], the object is unaffected by lighting. + + + If [code]true[/code], render point size can be changed. + [b]Note:[/b] This is only effective for objects whose geometry is point-based rather than triangle-based. See also [member params_point_size]. + + + If [code]true[/code], enables the "shadow to opacity" render mode where lighting modifies the alpha so shadowed areas are opaque and non-shadowed areas are transparent. Useful for overlaying shadows onto a camera feed in AR. + + + If [code]true[/code], lighting is calculated per vertex rather than per pixel. This may increase performance on low-end devices, especially for meshes with a lower polygon count. The downside is that shading becomes much less accurate, with visible linear interpolation between vertices that are joined together. This can be compensated by ensuring meshes have a sufficient level of subdivision (but not too much, to avoid reducing performance). Some material features are also not supported when vertex shading is enabled. + See also [member ProjectSettings.rendering/quality/shading/force_vertex_shading] which can globally enable vertex shading on all materials. + [b]Note:[/b] By default, vertex shading is enforced on mobile platforms by [member ProjectSettings.rendering/quality/shading/force_vertex_shading]'s [code]mobile[/code] override. + [b]Note:[/b] [member flags_vertex_lighting] has no effect if [member flags_unshaded] is [code]true[/code]. + + + If [code]true[/code], triplanar mapping is calculated in world space rather than object local space. See also [member uv1_triplanar]. + + + A high value makes the material appear more like a metal. Non-metals use their albedo as the diffuse color and add diffuse to the specular reflection. With non-metals, the reflection appears on top of the albedo color. Metals use their albedo as a multiplier to the specular reflection and set the diffuse color to black resulting in a tinted reflection. Materials work better when fully metal or fully non-metal, values between [code]0[/code] and [code]1[/code] should only be used for blending between metal and non-metal sections. To alter the amount of reflection use [member roughness]. + + + Sets the size of the specular lobe. The specular lobe is the bright spot that is reflected from light sources. + [b]Note:[/b] Unlike [member metallic], this is not energy-conserving, so it should be left at [code]0.5[/code] in most cases. See also [member roughness]. + + + Texture used to specify metallic for an object. This is multiplied by [member metallic]. + + + Specifies the channel of the [member metallic_texture] in which the metallic information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. + + + If [code]true[/code], normal mapping is enabled. + + + The strength of the normal map's effect. + + + Texture used to specify the normal at a given pixel. The [code]normal_texture[/code] only uses the red and green channels; the blue and alpha channels are ignored. The normal read from [code]normal_texture[/code] is oriented around the surface normal provided by the [Mesh]. + [b]Note:[/b] The mesh must have both normals and tangents defined in its vertex data. Otherwise, the normal map won't render correctly and will only appear to darken the whole surface. If creating geometry with [SurfaceTool], you can use [method SurfaceTool.generate_normals] and [method SurfaceTool.generate_tangents] to automatically generate normals and tangents respectively. + [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. + + + A single texture that combines information about AO, roughness and metallic. AO is stored in the red channel, roughness in the green channel and metallic in the blue channel. + + + Threshold at which the alpha scissor will discard values. + + + If [code]true[/code], the shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when [member params_billboard_mode] is [constant BILLBOARD_ENABLED]. + + + Controls how the object faces the camera. See [enum BillboardMode]. + [b]Note:[/b] Billboard mode is not suitable for VR because the left-right vector of the camera is not horizontal when the screen is attached to your head instead of on the table. See [url=https://github.com/godotengine/godot/issues/41567]GitHub issue #41567[/url] for details. + + + The material's blend mode. + [b]Note:[/b] Values other than [code]Mix[/code] force the object into the transparent pipeline. See [enum BlendMode]. + + + Which side of the object is not drawn when backfaces are rendered. See [enum CullMode]. + + + Determines when depth rendering takes place. See [enum DepthDrawMode]. See also [member flags_transparent]. + + + The algorithm used for diffuse light scattering. See [enum DiffuseMode]. + + + If [code]true[/code], enables the vertex grow setting. See [member params_grow_amount]. + + + Grows object vertices in the direction of their normals. + + + Currently unimplemented in Godot. + + + The point size in pixels. See [member flags_use_point_size]. + + + The method for rendering the specular blob. See [enum SpecularMode]. + + + If [code]true[/code], the shader will discard all pixels that have an alpha value less than [member params_alpha_scissor_threshold]. + + + The number of horizontal frames in the particle sprite sheet. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. + + + If [code]true[/code], particle animations are looped. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. + + + The number of vertical frames in the particle sprite sheet. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. + + + Distance over which the fade effect takes place. The larger the distance the longer it takes for an object to fade. + + + If [code]true[/code], the proximity fade effect is enabled. The proximity fade effect fades out each pixel based on its distance to another object. + + + If [code]true[/code], the refraction effect is enabled. Refraction distorts transparency based on light from behind the object. When using the GLES3 backend, the material's roughness value will affect the blurriness of the refraction. Higher roughness values will make the refraction look blurrier. + + + The strength of the refraction effect. Higher values result in a more distorted appearance for the refraction. + + + Texture that controls the strength of the refraction per-pixel. Multiplied by [member refraction_scale]. + + + Specifies the channel of the [member refraction_texture] in which the refraction information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. + + + Sets the strength of the rim lighting effect. + + + If [code]true[/code], rim effect is enabled. Rim lighting increases the brightness at glancing angles on an object. + [b]Note:[/b] Rim lighting is not visible if the material has [member flags_unshaded] set to [code]true[/code]. + + + Texture used to set the strength of the rim lighting effect per-pixel. Multiplied by [member rim]. + + + The amount of to blend light and albedo color when rendering rim effect. If [code]0[/code] the light color is used, while [code]1[/code] means albedo color is used. An intermediate value generally works best. + + + Surface reflection. A value of [code]0[/code] represents a perfect mirror while a value of [code]1[/code] completely blurs the reflection. See also [member metallic]. + + + Texture used to control the roughness per-pixel. Multiplied by [member roughness]. + + + Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. + + + If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges. + + + The strength of the subsurface scattering effect. + + + Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by [member subsurf_scatter_strength]. + + + The color used by the transmission effect. Represents the light passing through an object. + + + If [code]true[/code], the transmission effect is enabled. + + + Texture used to control the transmission effect per-pixel. Added to [member transmission]. + + + How much to offset the [code]UV[/code] coordinates. This amount will be added to [code]UV[/code] in the vertex function. This can be used to offset a texture. + + + How much to scale the [code]UV[/code] coordinates. This is multiplied by [code]UV[/code] in the vertex function. + + + If [code]true[/code], instead of using [code]UV[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. + + + A lower number blends the texture more softly while a higher number blends the texture more sharply. + [b]Note:[/b] [member uv1_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh. + + + How much to offset the [code]UV2[/code] coordinates. This amount will be added to [code]UV2[/code] in the vertex function. This can be used to offset a texture. + + + How much to scale the [code]UV2[/code] coordinates. This is multiplied by [code]UV2[/code] in the vertex function. + + + If [code]true[/code], instead of using [code]UV2[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. + + + A lower number blends the texture more softly while a higher number blends the texture more sharply. + [b]Note:[/b] [member uv2_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh. + + + If [code]true[/code], the model's vertex colors are processed as sRGB mode. + + + If [code]true[/code], the vertex color is used as albedo color. + + + + + Texture specifying per-pixel color. + + + Texture specifying per-pixel metallic value. + + + Texture specifying per-pixel roughness value. + + + Texture specifying per-pixel emission color. + + + Texture specifying per-pixel normal vector. + + + Texture specifying per-pixel rim value. + + + Texture specifying per-pixel clearcoat value. + + + Texture specifying per-pixel flowmap direction for use with [member anisotropy]. + + + Texture specifying per-pixel ambient occlusion value. + + + Texture specifying per-pixel depth. + + + Texture specifying per-pixel subsurface scattering. + + + Texture specifying per-pixel transmission color. + + + Texture specifying per-pixel refraction strength. + + + Texture specifying per-pixel detail mask blending value. + + + Texture specifying per-pixel detail color. + + + Texture specifying per-pixel detail normal. + + + Represents the size of the [enum TextureParam] enum. + + + Use [code]UV[/code] with the detail texture. + + + Use [code]UV2[/code] with the detail texture. + + + Constant for setting [member flags_transparent]. + + + Constant for setting [member emission_enabled]. + + + Constant for setting [member normal_enabled]. + + + Constant for setting [member rim_enabled]. + + + Constant for setting [member clearcoat_enabled]. + + + Constant for setting [member anisotropy_enabled]. + + + Constant for setting [member ao_enabled]. + + + Constant for setting [member depth_enabled]. + + + Constant for setting [member subsurf_scatter_enabled]. + + + Constant for setting [member transmission_enabled]. + + + Constant for setting [member refraction_enabled]. + + + Constant for setting [member detail_enabled]. + + + Represents the size of the [enum Feature] enum. + + + Default blend mode. The color of the object is blended over the background based on the object's alpha value. + + + The color of the object is added to the background. + + + The color of the object is subtracted from the background. + + + The color of the object is multiplied by the background. + + + Default depth draw mode. Depth is drawn only for opaque objects. + + + Depth draw is calculated for both opaque and transparent objects. + + + No depth draw. + + + For transparent objects, an opaque pass is made first with the opaque parts, then transparency is drawn. + + + Default cull mode. The back of the object is culled when not visible. + + + The front of the object is culled when not visible. + + + No culling is performed. + + + No lighting is used on the object. Color comes directly from [code]ALBEDO[/code]. + + + Lighting is calculated per-vertex rather than per-pixel. This can be used to increase the speed of the shader at the cost of quality. + + + Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it. + + + Set [code]ALBEDO[/code] to the per-vertex color specified in the mesh. + + + Vertex color is in sRGB space and needs to be converted to linear. Only applies in the GLES3 renderer. + + + Uses point size to alter the size of primitive points. Also changes the albedo texture lookup to use [code]POINT_COORD[/code] instead of [code]UV[/code]. + + + Object is scaled by depth so that it always appears the same size on screen. + + + Shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when [member params_billboard_mode] is [constant BILLBOARD_ENABLED]. + + + Use triplanar texture lookup for all texture lookups that would normally use [code]UV[/code]. + + + Use triplanar texture lookup for all texture lookups that would normally use [code]UV2[/code]. + + + Use [code]UV2[/code] coordinates to look up from the [member ao_texture]. + + + Use [code]UV2[/code] coordinates to look up from the [member emission_texture]. + + + Use alpha scissor. Set by [member params_use_alpha_scissor]. + + + Use world coordinates in the triplanar texture lookup instead of local coordinates. + + + Forces the shader to convert albedo from sRGB space to linear space. + + + Disables receiving shadows from other objects. + + + Disables receiving ambient light. + + + Ensures that normals appear correct, even with non-uniform scaling. + + + Enables the shadow to opacity feature. + + + Enables signed distance field rendering shader. + + + Represents the size of the [enum Flags] enum. + + + Default diffuse scattering algorithm. + + + Diffuse scattering ignores roughness. + + + Extends Lambert to cover more than 90 degrees when roughness increases. + + + Attempts to use roughness to emulate microsurfacing. + + + Uses a hard cut for lighting, with smoothing affected by roughness. + + + Default specular blob. + + + Older specular algorithm, included for compatibility. + + + Older specular algorithm, included for compatibility. + + + Toon blob which changes size based on roughness. + + + No specular blob. + + + Billboard mode is disabled. + + + The object's Z axis will always face the camera. + + + The object's X axis will always face the camera. + + + Used for particle systems when assigned to [Particles] and [CPUParticles] nodes. Enables [code]particles_anim_*[/code] properties. + The [member ParticlesMaterial.anim_speed] or [member CPUParticles.anim_speed] should also be set to a positive value for the animation to play. + + + Used to read from the red channel of a texture. + + + Used to read from the green channel of a texture. + + + Used to read from the blue channel of a texture. + + + Used to read from the alpha channel of a texture. + + + Currently unused. + + + Adds the emission color to the color from the emission texture. + + + Multiplies the emission color by the color from the emission texture. + + + Do not use distance fade. + + + Smoothly fades the object out based on each pixel's distance from the camera using the alpha channel. + + + Smoothly fades the object out based on each pixel's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than [constant DISTANCE_FADE_PIXEL_ALPHA]. + + + Smoothly fades the object out based on the object's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than [constant DISTANCE_FADE_PIXEL_ALPHA]. + + + The real conditioned shader needed on each situation will be sent for background compilation. In the meantime, a very complex shader that adapts to every situation will be used ("ubershader"). This ubershader is much slower to render, but will keep the game running without stalling to compile. Once shader compilation is done, the ubershader is replaced by the traditional optimized shader. + + + Anything with this material applied won't be rendered while this material's shader is being compiled. + This is useful for optimization, in cases where the visuals won't suffer from having certain non-essential elements missing during the short time their shaders are being compiled. + + + diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 3ef57f4f1ff..8b4ced76756 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -81,7 +81,7 @@ Sets the color of a specific instance by [i]multiplying[/i] the mesh's existing vertex colors. - For the color to take effect, ensure that [member color_format] is non-[code]null[/code] on the [MultiMesh] and [member SpatialMaterial.vertex_color_use_as_albedo] is [code]true[/code] on the material. If the color doesn't look as expected, make sure the material's albedo color is set to pure white ([code]Color(1, 1, 1)[/code]). + For the color to take effect, ensure that [member color_format] is non-[code]null[/code] on the [MultiMesh] and [member Material3D.vertex_color_use_as_albedo] is [code]true[/code] on the material. If the color doesn't look as expected, make sure the material's albedo color is set to pure white ([code]Color(1, 1, 1)[/code]). diff --git a/doc/classes/ORMSpatialMaterial.xml b/doc/classes/ORMSpatialMaterial.xml new file mode 100644 index 00000000000..6d43551b47c --- /dev/null +++ b/doc/classes/ORMSpatialMaterial.xml @@ -0,0 +1,15 @@ + + + + ORM 3D rendering material, based on [Material3D]. + + + This is a variant of the SpatialMaterial that uses an ORM texture to store AO, roughness and metallic information. + + + + + + + + diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml index c9f1ec8941b..b47bda3d208 100644 --- a/doc/classes/ParticlesMaterial.xml +++ b/doc/classes/ParticlesMaterial.xml @@ -75,7 +75,7 @@ Initial rotation applied to each particle, in degrees. - [b]Note:[/b] Only applied when [member flag_disable_z] or [member flag_rotate_y] are [code]true[/code] or the [SpatialMaterial] being used to draw the particle is using [constant SpatialMaterial.BILLBOARD_PARTICLES]. + [b]Note:[/b] Only applied when [member flag_disable_z] or [member flag_rotate_y] are [code]true[/code] or the [Material3D] being used to draw the particle is using [constant Material3D.BILLBOARD_PARTICLES]. Each particle's rotation will be animated along this [CurveTexture]. @@ -85,7 +85,7 @@ Initial angular velocity applied to each particle in [i]degrees[/i] per second. Sets the speed of rotation of the particle. - [b]Note:[/b] Only applied when [member flag_disable_z] or [member flag_rotate_y] are [code]true[/code] or the [SpatialMaterial] being used to draw the particle is using [constant SpatialMaterial.BILLBOARD_PARTICLES]. + [b]Note:[/b] Only applied when [member flag_disable_z] or [member flag_rotate_y] are [code]true[/code] or the [Material3D] being used to draw the particle is using [constant Material3D.BILLBOARD_PARTICLES]. Each particle's angular velocity will vary along this [CurveTexture]. @@ -113,15 +113,15 @@ Each particle's initial color. If the [Particles2D]'s or [Particles]'s [code]texture[/code] is defined, it will be multiplied by this color. - [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. + [b]Note:[/b] [member color] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color] will have no visible effect. Each particle's initial color will vary along this [GradientTexture] (multiplied with [member color]). - [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. + [b]Note:[/b] [member color_initial_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_initial_ramp] will have no visible effect. Each particle's color will vary along this [GradientTexture] over its lifetime (multiplied with [member color]). - [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. + [b]Note:[/b] [member color_ramp] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member color_ramp] will have no visible effect. The rate at which particles lose velocity. @@ -140,7 +140,7 @@ Particle color will be modulated by color determined by sampling this texture at the same point as the [member emission_point_texture]. - [b]Note:[/b] [member emission_color_texture] multiplies the particle mesh's vertex colors. To have a visible effect on a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_color_texture] will have no visible effect. + [b]Note:[/b] [member emission_color_texture] multiplies the particle mesh's vertex colors. To have a visible effect on a [Material3D], [member Material3D.vertex_color_use_as_albedo] [i]must[/i] be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. Otherwise, [member emission_color_texture] will have no visible effect. Particle velocity and rotation will be set by sampling this texture at the same point as the [member emission_point_texture]. Used only in [constant EMISSION_SHAPE_DIRECTED_POINTS]. Can be created automatically from mesh or node by selecting "Create Emission Points from Mesh/Node" under the "Particles" tool in the toolbar. diff --git a/doc/classes/PointMesh.xml b/doc/classes/PointMesh.xml index 8021d0ed1ac..2c48f542d19 100644 --- a/doc/classes/PointMesh.xml +++ b/doc/classes/PointMesh.xml @@ -5,7 +5,7 @@ The PointMesh is made from a single point. Instead of relying on triangles, points are rendered as a single rectangle on the screen with a constant size. They are intended to be used with Particle systems, but can be used as a cheap way to render constant size billboarded sprites (for example in a point cloud). - PointMeshes, must be used with a material that has a point size. Point size can be accessed in a shader with [code]POINT_SIZE[/code], or in a [SpatialMaterial] by setting [member SpatialMaterial.flags_use_point_size] and the variable [member SpatialMaterial.params_point_size]. + PointMeshes, must be used with a material that has a point size. Point size can be accessed in a shader with [code]POINT_SIZE[/code], or in a [SpatialMaterial] by setting [member Material3D.flags_use_point_size] and the variable [member Material3D.params_point_size]. When using PointMeshes, properties that normally alter vertices will be ignored, including billboard mode, grow, and cull face. diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index c8a1ab214c1..742e178ceae 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -27,7 +27,7 @@ If set, the order of the vertices in each triangle are reversed resulting in the backside of the mesh being drawn. - This gives the same result as using [constant SpatialMaterial.CULL_BACK] in [member SpatialMaterial.params_cull_mode]. + This gives the same result as using [constant Material3D.CULL_BACK] in [member Material3D.params_cull_mode]. The current [Material] of the primitive mesh. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 78068fc6995..6b3bee98e4c 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1593,7 +1593,7 @@ If set to [code]Asynchronous[/code] and available on the target device, asynchronous compilation of shaders is enabled (in contrast to [code]Asynchronous[/code]). That means that when a shader is first used under some new rendering situation, the game won't stall while such shader is being compiled. Instead, a fallback will be used and the real shader will be compiled in the background. Once the actual shader is compiled, it will be used the next times it's used to draw a frame. - Depending on the [member SpatialMaterial.async_mode] mode configured for a given material, the fallback will be an "ubershader" (the default) or just skip rendering any item it is applied to. In custom [ShaderMaterial]s, the async mode is set using [code]render_mode async_visible;[/code] (default) or [code]render_mode async_hidden;[/code] at the top of the shader. + Depending on the [member Material3D.async_mode] mode configured for a given material, the fallback will be an "ubershader" (the default) or just skip rendering any item it is applied to. In custom [ShaderMaterial]s, the async mode is set using [code]render_mode async_visible;[/code] (default) or [code]render_mode async_hidden;[/code] at the top of the shader. An ubershader is a very complex shader, slow but suited to any rendering situation, that the engine generates internally so it can be used from the beginning while the traditional conditioned, optimized version of it is being compiled. To reduce loading times after the project has been launched at least once, you can use [code]Asynchronous + Cache[/code]. This also causes the ubershaders to be cached into storage so they can be ready faster next time they are used (provided the platform provides support for it). [b]Note:[/b] Asynchronous compilation requires driver support for the [code]GL_ARB_get_program_binary[/code] OpenGL extension. This extension is supported by all hardware that supports OpenGL 4.1 or higher as well as most hardware that supports OpenGL 3.3 or higher. @@ -1781,8 +1781,8 @@ Lower-end override for [member rendering/quality/shading/force_lambert_over_burley] on mobile devices, due to performance concerns or driver support. - If [code]true[/code], forces vertex shading for all 3D [SpatialMaterial] and [ShaderMaterial] rendering. This can be used to improve performance on low-end mobile devices. The downside is that shading becomes much less accurate, with visible linear interpolation between vertices that are joined together. This can be compensated by ensuring meshes have a sufficient level of subdivision (but not too much, to avoid reducing performance). Some material features are also not supported when vertex shading is enabled. - See also [member SpatialMaterial.flags_vertex_lighting] which can be used to enable vertex shading on specific materials only. + If [code]true[/code], forces vertex shading for all 3D [Material3D] and [ShaderMaterial] rendering. This can be used to improve performance on low-end mobile devices. The downside is that shading becomes much less accurate, with visible linear interpolation between vertices that are joined together. This can be compensated by ensuring meshes have a sufficient level of subdivision (but not too much, to avoid reducing performance). Some material features are also not supported when vertex shading is enabled. + See also [member Material3D.flags_vertex_lighting] which can be used to enable vertex shading on specific materials only. [b]Note:[/b] This setting does not affect unshaded materials. diff --git a/doc/classes/SpatialMaterial.xml b/doc/classes/SpatialMaterial.xml index ffcf76c83ff..1a241ab5fb5 100644 --- a/doc/classes/SpatialMaterial.xml +++ b/doc/classes/SpatialMaterial.xml @@ -1,7 +1,7 @@ - + - Default 3D rendering material. + Default 3D rendering material, based on [Material3D]. This provides a default material with a wide variety of rendering features and properties without the need to write shader code. See the tutorial below for details. @@ -10,659 +10,7 @@ $DOCS_URL/tutorials/3d/spatial_material.html - - - - - Returns [code]true[/code], if the specified [enum Feature] is enabled. - - - - - - - Returns [code]true[/code], if the specified flag is enabled. See [enum Flags] enumerator for options. - - - - - - - Returns the [Texture] associated with the specified [enum TextureParam]. - - - - - - - - If [code]true[/code], enables the specified [enum Feature]. Many features that are available in [SpatialMaterial]s need to be enabled before use. This way the cost for using the feature is only incurred when specified. Features can also be enabled by setting the corresponding member to [code]true[/code]. - - - - - - - - If [code]true[/code], enables the specified flag. Flags are optional behavior that can be turned on and off. Only one flag can be enabled at a time with this function, the flag enumerators cannot be bit-masked together to enable or disable multiple flags at once. Flags can also be enabled by setting the corresponding member to [code]true[/code]. See [enum Flags] enumerator for options. - - - - - - - - Sets the [Texture] to be used by the specified [enum TextureParam]. This function is called when setting members ending in [code]*_texture[/code]. - - - - - The material's base color. - - - Texture to multiply by [member albedo_color]. Used for basic texturing of objects. - - - The strength of the anisotropy effect. This is multiplied by [member anisotropy_flowmap]'s alpha channel if a texture is defined there and the texture contains an alpha channel. - - - If [code]true[/code], anisotropy is enabled. Anisotropy changes the shape of the specular blob and aligns it to tangent space. This is useful for brushed aluminium and hair reflections. - [b]Note:[/b] Mesh tangents are needed for anisotropy to work. If the mesh does not contain tangents, the anisotropy effect will appear broken. - [b]Note:[/b] Material anisotropy should not to be confused with anisotropic texture filtering. Anisotropic texture filtering can be enabled by selecting a texture in the FileSystem dock, going to the Import dock, checking the [b]Anisotropic[/b] checkbox then clicking [b]Reimport[/b]. The anisotropic filtering level can be changed by adjusting [member ProjectSettings.rendering/quality/filters/anisotropic_filter_level]. - - - Texture that offsets the tangent map for anisotropy calculations and optionally controls the anisotropy effect (if an alpha channel is present). The flowmap texture is expected to be a derivative map, with the red channel representing distortion on the X axis and green channel representing distortion on the Y axis. Values below 0.5 will result in negative distortion, whereas values above 0.5 will result in positive distortion. - If present, the texture's alpha channel will be used to multiply the strength of the [member anisotropy] effect. Fully opaque pixels will keep the anisotropy effect's original strength while fully transparent pixels will disable the anisotropy effect entirely. The flowmap texture's blue channel is ignored. - - - If [code]true[/code], ambient occlusion is enabled. Ambient occlusion darkens areas based on the [member ao_texture]. - - - Amount that ambient occlusion affects lighting from lights. If [code]0[/code], ambient occlusion only affects ambient light. If [code]1[/code], ambient occlusion affects lights just as much as it affects ambient light. This can be used to impact the strength of the ambient occlusion effect, but typically looks unrealistic. - - - If [code]true[/code], use [code]UV2[/code] coordinates to look up from the [member ao_texture]. - - - Texture that defines the amount of ambient occlusion for a given point on the object. - - - Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. - - - If [member ProjectSettings.rendering/gles3/shaders/shader_compilation_mode] is [code]Synchronous[/code] (with or without cache), this determines how this material must behave in regards to asynchronous shader compilation. - [constant ASYNC_MODE_VISIBLE] is the default and the best for most cases. - - - Sets the strength of the clearcoat effect. Setting to [code]0[/code] looks the same as disabling the clearcoat effect. - - - If [code]true[/code], clearcoat rendering is enabled. Adds a secondary transparent pass to the lighting calculation resulting in an added specular blob. This makes materials appear as if they have a clear layer on them that can be either glossy or rough. - [b]Note:[/b] Clearcoat rendering is not visible if the material has [member flags_unshaded] set to [code]true[/code]. - - - Sets the roughness of the clearcoat pass. A higher value results in a smoother clearcoat while a lower value results in a rougher clearcoat. - - - Texture that defines the strength of the clearcoat effect and the glossiness of the clearcoat. Strength is specified in the red channel while glossiness is specified in the green channel. - - - If [code]true[/code], the shader will read depth texture at multiple points along the view ray to determine occlusion and parrallax. This can be very performance demanding, but results in more realistic looking depth mapping. - - - If [code]true[/code], depth mapping is enabled (also called "parallax mapping" or "height mapping"). See also [member normal_enabled]. - [b]Note:[/b] Depth mapping is not supported if triplanar mapping is used on the same material. The value of [member depth_enabled] will be ignored if [member uv1_triplanar] is enabled. - - - If [code]true[/code], direction of the binormal is flipped before using in the depth effect. This may be necessary if you have encoded your binormals in a way that is conflicting with the depth effect. - - - If [code]true[/code], direction of the tangent is flipped before using in the depth effect. This may be necessary if you have encoded your tangents in a way that is conflicting with the depth effect. - - - Number of layers to use when using [member depth_deep_parallax] and the view direction is perpendicular to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp. - - - Number of layers to use when using [member depth_deep_parallax] and the view direction is parallel to the surface of the object. A higher number will be more performance demanding while a lower number may not look as crisp. - - - Scales the depth offset effect. A higher number will create a larger depth. - - - Texture used to determine depth at a given pixel. Depth is always stored in the red channel. - - - Texture that specifies the color of the detail overlay. - - - Specifies how the [member detail_albedo] should blend with the current [code]ALBEDO[/code]. See [enum BlendMode] for options. - - - If [code]true[/code], enables the detail overlay. Detail is a second texture that gets mixed over the surface of the object based on [member detail_mask]. This can be used to add variation to objects, or to blend between two different albedo/normal textures. - - - Texture used to specify how the detail textures get blended with the base textures. - - - Texture that specifies the per-pixel normal of the detail overlay. - [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. - - - Specifies whether to use [code]UV[/code] or [code]UV2[/code] for the detail layer. See [enum DetailUV] for options. - - - Distance at which the object appears fully opaque. - [b]Note:[/b] If [code]distance_fade_max_distance[/code] is less than [code]distance_fade_min_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. - - - Distance at which the object starts to become visible. If the object is less than this distance away, it will be invisible. - [b]Note:[/b] If [code]distance_fade_min_distance[/code] is greater than [code]distance_fade_max_distance[/code], the behavior will be reversed. The object will start to fade away at [code]distance_fade_max_distance[/code] and will fully disappear once it reaches [code]distance_fade_min_distance[/code]. - - - Specifies which type of fade to use. Can be any of the [enum DistanceFadeMode]s. - - - The emitted light's color. See [member emission_enabled]. - - - If [code]true[/code], the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a [GIProbe] or [BakedLightmap] is used and this object is used in baked lighting. - - - The emitted light's strength. See [member emission_enabled]. - - - Use [code]UV2[/code] to read from the [member emission_texture]. - - - Sets how [member emission] interacts with [member emission_texture]. Can either add or multiply. See [enum EmissionOperator] for options. - - - Texture that specifies how much surface emits light at a given point. - - - Forces a conversion of the [member albedo_texture] from sRGB space to linear space. - - - Enables signed distance field rendering shader. - - - If [code]true[/code], the object receives no ambient light. - - - If [code]true[/code], the object receives no shadow that would otherwise be cast onto it. - - - If [code]true[/code], the shader will compute extra operations to make sure the normal stays correct when using a non-uniform scale. Only enable if using non-uniform scaling. - - - If [code]true[/code], the object is rendered at the same size regardless of distance. - - - If [code]true[/code], depth testing is disabled and the object will be drawn in render order. - - - If [code]true[/code], transparency is enabled on the body. See also [member params_blend_mode]. - - - If [code]true[/code], the object is unaffected by lighting. - - - If [code]true[/code], render point size can be changed. - [b]Note:[/b] This is only effective for objects whose geometry is point-based rather than triangle-based. See also [member params_point_size]. - - - If [code]true[/code], enables the "shadow to opacity" render mode where lighting modifies the alpha so shadowed areas are opaque and non-shadowed areas are transparent. Useful for overlaying shadows onto a camera feed in AR. - - - If [code]true[/code], lighting is calculated per vertex rather than per pixel. This may increase performance on low-end devices, especially for meshes with a lower polygon count. The downside is that shading becomes much less accurate, with visible linear interpolation between vertices that are joined together. This can be compensated by ensuring meshes have a sufficient level of subdivision (but not too much, to avoid reducing performance). Some material features are also not supported when vertex shading is enabled. - See also [member ProjectSettings.rendering/quality/shading/force_vertex_shading] which can globally enable vertex shading on all materials. - [b]Note:[/b] By default, vertex shading is enforced on mobile platforms by [member ProjectSettings.rendering/quality/shading/force_vertex_shading]'s [code]mobile[/code] override. - [b]Note:[/b] [member flags_vertex_lighting] has no effect if [member flags_unshaded] is [code]true[/code]. - - - If [code]true[/code], triplanar mapping is calculated in world space rather than object local space. See also [member uv1_triplanar]. - - - A high value makes the material appear more like a metal. Non-metals use their albedo as the diffuse color and add diffuse to the specular reflection. With non-metals, the reflection appears on top of the albedo color. Metals use their albedo as a multiplier to the specular reflection and set the diffuse color to black resulting in a tinted reflection. Materials work better when fully metal or fully non-metal, values between [code]0[/code] and [code]1[/code] should only be used for blending between metal and non-metal sections. To alter the amount of reflection use [member roughness]. - - - Sets the size of the specular lobe. The specular lobe is the bright spot that is reflected from light sources. - [b]Note:[/b] Unlike [member metallic], this is not energy-conserving, so it should be left at [code]0.5[/code] in most cases. See also [member roughness]. - - - Texture used to specify metallic for an object. This is multiplied by [member metallic]. - - - Specifies the channel of the [member metallic_texture] in which the metallic information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. - - - If [code]true[/code], normal mapping is enabled. - - - The strength of the normal map's effect. - - - Texture used to specify the normal at a given pixel. The [code]normal_texture[/code] only uses the red and green channels; the blue and alpha channels are ignored. The normal read from [code]normal_texture[/code] is oriented around the surface normal provided by the [Mesh]. - [b]Note:[/b] The mesh must have both normals and tangents defined in its vertex data. Otherwise, the normal map won't render correctly and will only appear to darken the whole surface. If creating geometry with [SurfaceTool], you can use [method SurfaceTool.generate_normals] and [method SurfaceTool.generate_tangents] to automatically generate normals and tangents respectively. - [b]Note:[/b] Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates]this page[/url] for a comparison of normal map coordinates expected by popular engines. - - - Threshold at which the alpha scissor will discard values. - - - If [code]true[/code], the shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when [member params_billboard_mode] is [constant BILLBOARD_ENABLED]. - - - Controls how the object faces the camera. See [enum BillboardMode]. - [b]Note:[/b] Billboard mode is not suitable for VR because the left-right vector of the camera is not horizontal when the screen is attached to your head instead of on the table. See [url=https://github.com/godotengine/godot/issues/41567]GitHub issue #41567[/url] for details. - - - The material's blend mode. - [b]Note:[/b] Values other than [code]Mix[/code] force the object into the transparent pipeline. See [enum BlendMode]. - - - Which side of the object is not drawn when backfaces are rendered. See [enum CullMode]. - - - Determines when depth rendering takes place. See [enum DepthDrawMode]. See also [member flags_transparent]. - - - The algorithm used for diffuse light scattering. See [enum DiffuseMode]. - - - If [code]true[/code], enables the vertex grow setting. See [member params_grow_amount]. - - - Grows object vertices in the direction of their normals. - - - Currently unimplemented in Godot. - - - The point size in pixels. See [member flags_use_point_size]. - - - The method for rendering the specular blob. See [enum SpecularMode]. - - - If [code]true[/code], the shader will discard all pixels that have an alpha value less than [member params_alpha_scissor_threshold]. - - - The number of horizontal frames in the particle sprite sheet. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. - - - If [code]true[/code], particle animations are looped. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. - - - The number of vertical frames in the particle sprite sheet. Only enabled when using [constant BILLBOARD_PARTICLES]. See [member params_billboard_mode]. - - - Distance over which the fade effect takes place. The larger the distance the longer it takes for an object to fade. - - - If [code]true[/code], the proximity fade effect is enabled. The proximity fade effect fades out each pixel based on its distance to another object. - - - If [code]true[/code], the refraction effect is enabled. Refraction distorts transparency based on light from behind the object. When using the GLES3 backend, the material's roughness value will affect the blurriness of the refraction. Higher roughness values will make the refraction look blurrier. - - - The strength of the refraction effect. Higher values result in a more distorted appearance for the refraction. - - - Texture that controls the strength of the refraction per-pixel. Multiplied by [member refraction_scale]. - - - Specifies the channel of the [member refraction_texture] in which the refraction information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. - - - Sets the strength of the rim lighting effect. - - - If [code]true[/code], rim effect is enabled. Rim lighting increases the brightness at glancing angles on an object. - [b]Note:[/b] Rim lighting is not visible if the material has [member flags_unshaded] set to [code]true[/code]. - - - Texture used to set the strength of the rim lighting effect per-pixel. Multiplied by [member rim]. - - - The amount of to blend light and albedo color when rendering rim effect. If [code]0[/code] the light color is used, while [code]1[/code] means albedo color is used. An intermediate value generally works best. - - - Surface reflection. A value of [code]0[/code] represents a perfect mirror while a value of [code]1[/code] completely blurs the reflection. See also [member metallic]. - - - Texture used to control the roughness per-pixel. Multiplied by [member roughness]. - - - Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. - - - If [code]true[/code], subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges. - - - The strength of the subsurface scattering effect. - - - Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by [member subsurf_scatter_strength]. - - - The color used by the transmission effect. Represents the light passing through an object. - - - If [code]true[/code], the transmission effect is enabled. - - - Texture used to control the transmission effect per-pixel. Added to [member transmission]. - - - How much to offset the [code]UV[/code] coordinates. This amount will be added to [code]UV[/code] in the vertex function. This can be used to offset a texture. - - - How much to scale the [code]UV[/code] coordinates. This is multiplied by [code]UV[/code] in the vertex function. - - - If [code]true[/code], instead of using [code]UV[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. - - - A lower number blends the texture more softly while a higher number blends the texture more sharply. - [b]Note:[/b] [member uv1_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh. - - - How much to offset the [code]UV2[/code] coordinates. This amount will be added to [code]UV2[/code] in the vertex function. This can be used to offset a texture. - - - How much to scale the [code]UV2[/code] coordinates. This is multiplied by [code]UV2[/code] in the vertex function. - - - If [code]true[/code], instead of using [code]UV2[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. - - - A lower number blends the texture more softly while a higher number blends the texture more sharply. - [b]Note:[/b] [member uv2_triplanar_sharpness] is clamped between [code]0.0[/code] and [code]150.0[/code] (inclusive) as values outside that range can look broken depending on the mesh. - - - If [code]true[/code], the model's vertex colors are processed as sRGB mode. - - - If [code]true[/code], the vertex color is used as albedo color. - - - - Texture specifying per-pixel color. - - - Texture specifying per-pixel metallic value. - - - Texture specifying per-pixel roughness value. - - - Texture specifying per-pixel emission color. - - - Texture specifying per-pixel normal vector. - - - Texture specifying per-pixel rim value. - - - Texture specifying per-pixel clearcoat value. - - - Texture specifying per-pixel flowmap direction for use with [member anisotropy]. - - - Texture specifying per-pixel ambient occlusion value. - - - Texture specifying per-pixel depth. - - - Texture specifying per-pixel subsurface scattering. - - - Texture specifying per-pixel transmission color. - - - Texture specifying per-pixel refraction strength. - - - Texture specifying per-pixel detail mask blending value. - - - Texture specifying per-pixel detail color. - - - Texture specifying per-pixel detail normal. - - - Represents the size of the [enum TextureParam] enum. - - - Use [code]UV[/code] with the detail texture. - - - Use [code]UV2[/code] with the detail texture. - - - Constant for setting [member flags_transparent]. - - - Constant for setting [member emission_enabled]. - - - Constant for setting [member normal_enabled]. - - - Constant for setting [member rim_enabled]. - - - Constant for setting [member clearcoat_enabled]. - - - Constant for setting [member anisotropy_enabled]. - - - Constant for setting [member ao_enabled]. - - - Constant for setting [member depth_enabled]. - - - Constant for setting [member subsurf_scatter_enabled]. - - - Constant for setting [member transmission_enabled]. - - - Constant for setting [member refraction_enabled]. - - - Constant for setting [member detail_enabled]. - - - Represents the size of the [enum Feature] enum. - - - Default blend mode. The color of the object is blended over the background based on the object's alpha value. - - - The color of the object is added to the background. - - - The color of the object is subtracted from the background. - - - The color of the object is multiplied by the background. - - - Default depth draw mode. Depth is drawn only for opaque objects. - - - Depth draw is calculated for both opaque and transparent objects. - - - No depth draw. - - - For transparent objects, an opaque pass is made first with the opaque parts, then transparency is drawn. - - - Default cull mode. The back of the object is culled when not visible. - - - The front of the object is culled when not visible. - - - No culling is performed. - - - No lighting is used on the object. Color comes directly from [code]ALBEDO[/code]. - - - Lighting is calculated per-vertex rather than per-pixel. This can be used to increase the speed of the shader at the cost of quality. - - - Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it. - - - Set [code]ALBEDO[/code] to the per-vertex color specified in the mesh. - - - Vertex color is in sRGB space and needs to be converted to linear. Only applies in the GLES3 renderer. - - - Uses point size to alter the size of primitive points. Also changes the albedo texture lookup to use [code]POINT_COORD[/code] instead of [code]UV[/code]. - - - Object is scaled by depth so that it always appears the same size on screen. - - - Shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when [member params_billboard_mode] is [constant BILLBOARD_ENABLED]. - - - Use triplanar texture lookup for all texture lookups that would normally use [code]UV[/code]. - - - Use triplanar texture lookup for all texture lookups that would normally use [code]UV2[/code]. - - - Use [code]UV2[/code] coordinates to look up from the [member ao_texture]. - - - Use [code]UV2[/code] coordinates to look up from the [member emission_texture]. - - - Use alpha scissor. Set by [member params_use_alpha_scissor]. - - - Use world coordinates in the triplanar texture lookup instead of local coordinates. - - - Forces the shader to convert albedo from sRGB space to linear space. - - - Disables receiving shadows from other objects. - - - Disables receiving ambient light. - - - Ensures that normals appear correct, even with non-uniform scaling. - - - Enables the shadow to opacity feature. - - - Enables signed distance field rendering shader. - - - Represents the size of the [enum Flags] enum. - - - Default diffuse scattering algorithm. - - - Diffuse scattering ignores roughness. - - - Extends Lambert to cover more than 90 degrees when roughness increases. - - - Attempts to use roughness to emulate microsurfacing. - - - Uses a hard cut for lighting, with smoothing affected by roughness. - - - Default specular blob. - - - Older specular algorithm, included for compatibility. - - - Older specular algorithm, included for compatibility. - - - Toon blob which changes size based on roughness. - - - No specular blob. - - - Billboard mode is disabled. - - - The object's Z axis will always face the camera. - - - The object's X axis will always face the camera. - - - Used for particle systems when assigned to [Particles] and [CPUParticles] nodes. Enables [code]particles_anim_*[/code] properties. - The [member ParticlesMaterial.anim_speed] or [member CPUParticles.anim_speed] should also be set to a positive value for the animation to play. - - - Used to read from the red channel of a texture. - - - Used to read from the green channel of a texture. - - - Used to read from the blue channel of a texture. - - - Used to read from the alpha channel of a texture. - - - Currently unused. - - - Adds the emission color to the color from the emission texture. - - - Multiplies the emission color by the color from the emission texture. - - - Do not use distance fade. - - - Smoothly fades the object out based on each pixel's distance from the camera using the alpha channel. - - - Smoothly fades the object out based on each pixel's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than [constant DISTANCE_FADE_PIXEL_ALPHA]. - - - Smoothly fades the object out based on the object's distance from the camera using a dither approach. Dithering discards pixels based on a set pattern to smoothly fade without enabling transparency. On certain hardware this can be faster than [constant DISTANCE_FADE_PIXEL_ALPHA]. - - - The real conditioned shader needed on each situation will be sent for background compilation. In the meantime, a very complex shader that adapts to every situation will be used ("ubershader"). This ubershader is much slower to render, but will keep the game running without stalling to compile. Once shader compilation is done, the ubershader is replaced by the traditional optimized shader. - - - Anything with this material applied won't be rendered while this material's shader is being compiled. - This is useful for optimization, in cases where the visuals won't suffer from having certain non-essential elements missing during the short time their shaders are being compiled. - diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index 89910849987..fc04a0db0bb 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -42,7 +42,7 @@ The direction in which the front of the texture faces. - + If [code]true[/code], texture will be centered. @@ -61,7 +61,7 @@ A color value used to [i]multiply[/i] the texture's colors. Can be used for mood-coloring or to simulate the color of light. - [b]Note:[/b] If a [member GeometryInstance.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. + [b]Note:[/b] If a [member GeometryInstance.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [SpatialMaterial], [member Material3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function. If [code]true[/code], depth testing is disabled and the object will be drawn in render order. @@ -71,7 +71,7 @@ The texture's visibility on a scale from [code]0[/code] (fully invisible) to [code]1[/code] (fully visible). [member opacity] is a multiplier for the [member modulate] color's alpha channel. - [b]Note:[/b] If a [member GeometryInstance.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the opacity defined in [member opacity] will be ignored. For a [SpatialMaterial], [member SpatialMaterial.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALPHA *= COLOR.a;[/code] must be inserted in the shader's [code]fragment()[/code] function. + [b]Note:[/b] If a [member GeometryInstance.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the opacity defined in [member opacity] will be ignored. For a [SpatialMaterial], [member Material3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALPHA *= COLOR.a;[/code] must be inserted in the shader's [code]fragment()[/code] function. The size of one pixel's width on the sprite to scale it in 3D. diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index ab11d089736..98e8b4c8110 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -34,7 +34,7 @@ Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all. - [b]Note:[/b] The material must have [member SpatialMaterial.vertex_color_use_as_albedo] enabled for the vertex color to be visible. + [b]Note:[/b] The material must have [member Material3D.vertex_color_use_as_albedo] enabled for the vertex color to be visible. diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index e7091326b71..8da7943534b 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -2713,7 +2713,7 @@ - If asynchronous shader compilation is enabled, this controls whether [constant SpatialMaterial.ASYNC_MODE_HIDDEN] is obeyed. + If asynchronous shader compilation is enabled, this controls whether [constant Material3D.ASYNC_MODE_HIDDEN] is obeyed. For instance, you may want to enable this temporarily before taking a screenshot. This ensures everything is visible even if shaders with async mode [i]hidden[/i] are not ready yet. Reflection probes use this internally to ensure they capture everything regardless the shaders are ready or not. diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index f54d470ee4a..5ac14cd5dd1 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -518,7 +518,7 @@ void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set * } if (p_with_convert) { - if (base == "SpatialMaterial") { + if (base == "SpatialMaterial" || base == "ORMSpatialMaterial") { p_vector->insert("Texture"); } else if (base == "ShaderMaterial") { p_vector->insert("Shader"); @@ -643,11 +643,22 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ if (at == "SpatialMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture")) { // Use existing resource if possible and only replace its data. - Ref mat = edited_resource; + Ref mat = edited_resource; if (mat.is_null()) { mat.instance(); } - mat->set_texture(SpatialMaterial::TextureParam::TEXTURE_ALBEDO, dropped_resource); + mat->set_texture(Material3D::TextureParam::TEXTURE_ALBEDO, dropped_resource); + dropped_resource = mat; + break; + } + + if (at == "ORMSpatialMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture")) { + // Use existing resource if possible and only replace its data. + Ref mat = edited_resource; + if (mat.is_null()) { + mat.instance(); + } + mat->set_texture(Material3D::TextureParam::TEXTURE_ALBEDO, dropped_resource); dropped_resource = mat; break; } diff --git a/editor/icons/icon_o_r_m_spatial_material.svg b/editor/icons/icon_o_r_m_spatial_material.svg new file mode 100644 index 00000000000..e09208155de --- /dev/null +++ b/editor/icons/icon_o_r_m_spatial_material.svg @@ -0,0 +1 @@ + diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 963a33abc0e..39c44d4710c 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -336,7 +336,7 @@ Error ColladaImport::_create_material(const String &p_target) { ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect), ERR_INVALID_PARAMETER); Collada::Effect &effect = collada.state.effect_map[src_mat.instance_effect]; - Ref material = memnew(SpatialMaterial); + Ref material = memnew(SpatialMaterial); if (src_mat.name != "") { material->set_name(src_mat.name); @@ -354,9 +354,9 @@ Error ColladaImport::_create_material(const String &p_target) { } Ref texture = ResourceLoader::load(texfile, "Texture"); if (texture.is_valid()) { - material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + material->set_texture(Material3D::TEXTURE_ALBEDO, texture); material->set_albedo(Color(1, 1, 1, 1)); - //material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1)); + //material->set_parameter(Material3D::PARAM_DIFFUSE,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } @@ -376,11 +376,11 @@ Error ColladaImport::_create_material(const String &p_target) { Ref texture = ResourceLoader::load(texfile, "Texture"); if (texture.is_valid()) { - material->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); + material->set_texture(Material3D::TEXTURE_METALLIC, texture); material->set_specular(1.0); - //material->set_texture(SpatialMaterial::PARAM_SPECULAR,texture); - //material->set_parameter(SpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1)); + //material->set_texture(Material3D::PARAM_SPECULAR,texture); + //material->set_parameter(Material3D::PARAM_SPECULAR,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } @@ -401,18 +401,18 @@ Error ColladaImport::_create_material(const String &p_target) { Ref texture = ResourceLoader::load(texfile, "Texture"); if (texture.is_valid()) { - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - material->set_texture(SpatialMaterial::TEXTURE_EMISSION, texture); + material->set_feature(Material3D::FEATURE_EMISSION, true); + material->set_texture(Material3D::TEXTURE_EMISSION, texture); material->set_emission(Color(1, 1, 1, 1)); - //material->set_parameter(SpatialMaterial::PARAM_EMISSION,Color(1,1,1,1)); + //material->set_parameter(Material3D::PARAM_EMISSION,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } } } else { if (effect.emission.color != Color()) { - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_feature(Material3D::FEATURE_EMISSION, true); material->set_emission(effect.emission.color); } } @@ -428,11 +428,11 @@ Error ColladaImport::_create_material(const String &p_target) { Ref texture = ResourceLoader::load(texfile, "Texture"); if (texture.is_valid()) { - material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); - material->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); + material->set_feature(Material3D::FEATURE_NORMAL_MAPPING, true); + material->set_texture(Material3D::TEXTURE_NORMAL, texture); //material->set_emission(Color(1,1,1,1)); - //material->set_texture(SpatialMaterial::PARAM_NORMAL,texture); + //material->set_texture(Material3D::PARAM_NORMAL,texture); } else { //missing_textures.push_back(texfile.get_file()); } @@ -443,9 +443,9 @@ Error ColladaImport::_create_material(const String &p_target) { material->set_roughness(roughness); if (effect.double_sided) { - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(Material3D::CULL_DISABLED); } - material->set_flag(SpatialMaterial::FLAG_UNSHADED, effect.unshaded); + material->set_flag(Material3D::FLAG_UNSHADED, effect.unshaded); material_cache[p_target] = material; return OK; @@ -883,7 +883,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref &p_me /*****************/ { - Ref material; + Ref material; { if (p_material_map.has(p.material)) { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index bdcc45c0c91..8462ff8174c 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -41,7 +41,7 @@ uint32_t EditorOBJImporter::get_import_flags() const { return IMPORT_SCENE; } -static Error _parse_material_library(const String &p_path, Map> &material_map, List *r_missing_deps) { +static Error _parse_material_library(const String &p_path, Map> &material_map, List *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path)); @@ -99,7 +99,7 @@ static Error _parse_material_library(const String &p_path, Mapset_albedo(c); if (c.a < 0.99) { - current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + current->set_feature(Material3D::FEATURE_TRANSPARENT, true); } } else if (l.begins_with("Tr ")) { //normal @@ -111,7 +111,7 @@ static Error _parse_material_library(const String &p_path, Mapset_albedo(c); if (c.a < 0.99) { - current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + current->set_feature(Material3D::FEATURE_TRANSPARENT, true); } } else if (l.begins_with("map_Ka ")) { @@ -133,7 +133,7 @@ static Error _parse_material_library(const String &p_path, Map texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + current->set_texture(Material3D::TEXTURE_ALBEDO, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -153,7 +153,7 @@ static Error _parse_material_library(const String &p_path, Map texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); + current->set_texture(Material3D::TEXTURE_METALLIC, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -173,7 +173,7 @@ static Error _parse_material_library(const String &p_path, Map texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); + current->set_texture(Material3D::TEXTURE_ROUGHNESS, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -187,8 +187,8 @@ static Error _parse_material_library(const String &p_path, Map texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); - current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); + current->set_feature(Material3D::FEATURE_NORMAL_MAPPING, true); + current->set_texture(Material3D::TEXTURE_NORMAL, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -217,7 +217,7 @@ static Error _parse_obj(const String &p_path, List> &r_meshes, bool p_ Vector colors; String name; - Map>> material_map; + Map>> material_map; Ref surf_tool = memnew(SurfaceTool); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -361,7 +361,7 @@ static Error _parse_obj(const String &p_path, List> &r_meshes, bool p_ print_verbose("OBJ: Current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material))); if (material_map.has(current_material_library) && material_map[current_material_library].has(current_material)) { - Ref &material = material_map[current_material_library][current_material]; + Ref &material = material_map[current_material_library][current_material]; if (!colors.empty()) { material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); } @@ -411,7 +411,7 @@ static Error _parse_obj(const String &p_path, List> &r_meshes, bool p_ current_material_library = l.replace("mtllib", "").strip_edges(); if (!material_map.has(current_material_library)) { - Map> lib; + Map> lib; String lib_path = current_material_library; if (lib_path.is_rel_path()) { lib_path = p_path.get_base_dir().plus_file(current_material_library); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index a5862664f21..fad1403edc2 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -315,18 +315,18 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map if (m.is_valid()) { for (int i = 0; i < m->get_surface_count(); i++) { - Ref mat = m->surface_get_material(i); + Ref mat = m->surface_get_material(i); if (!mat.is_valid()) { continue; } if (_teststr(mat->get_name(), "alpha")) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); mat->set_name(_fixstr(mat->get_name(), "alpha")); } if (_teststr(mat->get_name(), "vcol")) { - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); mat->set_name(_fixstr(mat->get_name(), "vcol")); } } diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 374f7025125..b61f23e96b4 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -518,23 +518,23 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { imgeom = memnew(ImmediateGeometry); imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); - line_material = Ref(memnew(SpatialMaterial)); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + line_material = Ref(memnew(SpatialMaterial)); + line_material->set_flag(Material3D::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + line_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + line_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); line_material->set_albedo(Color(1, 1, 1)); - handle_material = Ref(memnew(SpatialMaterial)); - handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); - handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + handle_material = Ref(memnew(SpatialMaterial)); + handle_material->set_flag(Material3D::FLAG_UNSHADED, true); + handle_material->set_flag(Material3D::FLAG_USE_POINT_SIZE, true); + handle_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + handle_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); Ref handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); - handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle); + handle_material->set_texture(Material3D::TEXTURE_ALBEDO, handle); pointsm = memnew(MeshInstance); imgeom->add_child(pointsm); diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h index c83cc37f3ef..6147b6027e5 100644 --- a/editor/plugins/collision_polygon_editor_plugin.h +++ b/editor/plugins/collision_polygon_editor_plugin.h @@ -56,8 +56,8 @@ class Polygon3DEditor : public HBoxContainer { ToolButton *button_create; ToolButton *button_edit; - Ref line_material; - Ref handle_material; + Ref line_material; + Ref handle_material; EditorNode *editor; Panel *panel; diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 78f35170c42..d5afa301a14 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -263,11 +263,11 @@ String SpatialMaterialConversionPlugin::converts_to() const { return "ShaderMaterial"; } bool SpatialMaterialConversionPlugin::handles(const Ref &p_resource) const { - Ref mat = p_resource; + Ref mat = p_resource; return mat.is_valid(); } Ref SpatialMaterialConversionPlugin::convert(const Ref &p_resource) const { - Ref mat = p_resource; + Ref mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref()); Ref smat; diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index 12284cef6f6..4c14706d217 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -462,7 +462,7 @@ MeshInstanceEditor::MeshInstanceEditor() { options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH); - options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible.")); + options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the Material3D Grow property when using that property isn't possible.")); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1); options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2); diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 5b2e7b556d4..d988f8dade9 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -217,9 +217,9 @@ void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p void PathSpatialGizmo::redraw() { clear(); - Ref path_material = gizmo_plugin->get_material("path_material", this); - Ref path_thin_material = gizmo_plugin->get_material("path_thin_material", this); - Ref handles_material = gizmo_plugin->get_material("handles"); + Ref path_material = gizmo_plugin->get_material("path_material", this); + Ref path_thin_material = gizmo_plugin->get_material("path_thin_material", this); + Ref handles_material = gizmo_plugin->get_material("handles"); Ref c = path->get_curve(); if (c.is_null()) { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 40cb3df3dc7..ffe2f546bc0 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -5028,19 +5028,19 @@ void SpatialEditor::_generate_selection_boxes() { st_xray->add_vertex(b); } - Ref mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref mat = memnew(SpatialMaterial); + mat->set_flag(Material3D::FLAG_UNSHADED, true); const Color selection_box_color = EDITOR_GET("editors/3d/selection_box_color"); mat->set_albedo(selection_box_color); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); st->set_material(mat); selection_box = st->commit(); - Ref mat_xray = memnew(SpatialMaterial); - mat_xray->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - mat_xray->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true); + Ref mat_xray = memnew(SpatialMaterial); + mat_xray->set_flag(Material3D::FLAG_UNSHADED, true); + mat_xray->set_flag(Material3D::FLAG_DISABLE_DEPTH_TEST, true); mat_xray->set_albedo(selection_box_color * Color(1, 1, 1, 0.15)); - mat_xray->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat_xray->set_feature(Material3D::FEATURE_TRANSPARENT, true); st_xray->set_material(mat_xray); selection_box_xray = st_xray->commit(); } @@ -5618,10 +5618,10 @@ void SpatialEditor::_init_indicators() { grid_enabled = true; indicator_mat.instance(); - indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + indicator_mat->set_flag(Material3D::FLAG_UNSHADED, true); + indicator_mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + indicator_mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + indicator_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); Vector origin_colors; Vector origin_points; @@ -5753,14 +5753,14 @@ void SpatialEditor::_init_indicators() { scale_gizmo[i] = Ref(memnew(ArrayMesh)); scale_plane_gizmo[i] = Ref(memnew(ArrayMesh)); - Ref mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref mat = memnew(SpatialMaterial); + mat->set_flag(Material3D::FLAG_UNSHADED, true); mat->set_on_top_of_alpha(); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); mat->set_albedo(col); gizmo_color[i] = mat; - Ref mat_hl = mat->duplicate(); + Ref mat_hl = mat->duplicate(); const Color albedo = col.from_hsv(col.get_h(), 0.25, 1.0, 1); mat_hl->set_albedo(albedo); gizmo_color_hl[i] = mat_hl; @@ -5846,17 +5846,17 @@ void SpatialEditor::_init_indicators() { surftool->add_vertex(points[2]); surftool->add_vertex(points[3]); - Ref plane_mat = memnew(SpatialMaterial); - plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref plane_mat = memnew(SpatialMaterial); + plane_mat->set_flag(Material3D::FLAG_UNSHADED, true); plane_mat->set_on_top_of_alpha(); - plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + plane_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + plane_mat->set_cull_mode(Material3D::CULL_DISABLED); plane_mat->set_albedo(col); plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides surftool->set_material(plane_mat); surftool->commit(move_plane_gizmo[i]); - Ref plane_mat_hl = plane_mat->duplicate(); + Ref plane_mat_hl = plane_mat->duplicate(); plane_mat_hl->set_albedo(albedo); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } @@ -6055,17 +6055,17 @@ void SpatialEditor::_init_indicators() { surftool->add_vertex(points[2]); surftool->add_vertex(points[3]); - Ref plane_mat = memnew(SpatialMaterial); - plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref plane_mat = memnew(SpatialMaterial); + plane_mat->set_flag(Material3D::FLAG_UNSHADED, true); plane_mat->set_on_top_of_alpha(); - plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + plane_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + plane_mat->set_cull_mode(Material3D::CULL_DISABLED); plane_mat->set_albedo(col); plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides surftool->set_material(plane_mat); surftool->commit(scale_plane_gizmo[i]); - Ref plane_mat_hl = plane_mat->duplicate(); + Ref plane_mat_hl = plane_mat->duplicate(); plane_mat_hl->set_albedo(col.from_hsv(col.get_h(), 0.25, 1.0, 1)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } @@ -7398,13 +7398,13 @@ SpatialEditorPlugin::~SpatialEditorPlugin() { void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { Color instanced_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced"); - Vector> mats; + Vector> mats; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; bool instanced = i < 2; - Ref material = Ref(memnew(SpatialMaterial)); + Ref material = Ref(memnew(SpatialMaterial)); Color color = instanced ? instanced_color : p_color; @@ -7413,17 +7413,17 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color } material->set_albedo(color); - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 1); + material->set_flag(Material3D::FLAG_UNSHADED, true); + material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + material->set_render_priority(Material3D::RENDER_PRIORITY_MIN + 1); if (p_use_vertex_color) { - material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); } if (p_billboard) { - material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); + material->set_billboard_mode(Material3D::BILLBOARD_ENABLED); } if (p_on_top && selected) { @@ -7439,13 +7439,13 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Ref &p_texture, bool p_on_top, const Color &p_albedo) { Color instanced_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instanced"); - Vector> icons; + Vector> icons; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; bool instanced = i < 2; - Ref icon = Ref(memnew(SpatialMaterial)); + Ref icon = Ref(memnew(SpatialMaterial)); Color color = instanced ? instanced_color : p_albedo; @@ -7455,16 +7455,16 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const icon->set_albedo(color); - icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - icon->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - icon->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - icon->set_cull_mode(SpatialMaterial::CULL_DISABLED); - icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED); - icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture); - icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true); - icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); - icon->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN); + icon->set_flag(Material3D::FLAG_UNSHADED, true); + icon->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + icon->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + icon->set_cull_mode(Material3D::CULL_DISABLED); + icon->set_depth_draw_mode(Material3D::DEPTH_DRAW_DISABLED); + icon->set_feature(Material3D::FEATURE_TRANSPARENT, true); + icon->set_texture(Material3D::TEXTURE_ALBEDO, p_texture); + icon->set_flag(Material3D::FLAG_FIXED_SIZE, true); + icon->set_billboard_mode(Material3D::BILLBOARD_ENABLED); + icon->set_render_priority(Material3D::RENDER_PRIORITY_MIN); if (p_on_top && selected) { icon->set_on_top_of_alpha(); @@ -7477,36 +7477,36 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const } void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref &p_icon) { - Ref handle_material = Ref(memnew(SpatialMaterial)); + Ref handle_material = Ref(memnew(SpatialMaterial)); - handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); + handle_material->set_flag(Material3D::FLAG_UNSHADED, true); + handle_material->set_flag(Material3D::FLAG_USE_POINT_SIZE, true); Ref handle_t = p_icon != nullptr ? p_icon : SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle_t->get_width()); - handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t); + handle_material->set_texture(Material3D::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); - handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + handle_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + handle_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); handle_material->set_on_top_of_alpha(); if (p_billboard) { - handle_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); + handle_material->set_billboard_mode(Material3D::BILLBOARD_ENABLED); handle_material->set_on_top_of_alpha(); } - materials[p_name] = Vector>(); + materials[p_name] = Vector>(); materials[p_name].push_back(handle_material); } -void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref p_material) { - materials[p_name] = Vector>(); +void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref p_material) { + materials[p_name] = Vector>(); materials[p_name].push_back(p_material); } -Ref EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref &p_gizmo) { - ERR_FAIL_COND_V(!materials.has(p_name), Ref()); - ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref()); +Ref EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref &p_gizmo) { + ERR_FAIL_COND_V(!materials.has(p_name), Ref()); + ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref()); if (p_gizmo.is_null() || materials[p_name].size() == 1) { return materials[p_name][0]; @@ -7514,12 +7514,12 @@ Ref EditorSpatialGizmoPlugin::get_material(const String &p_name int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); - Ref mat = materials[p_name][index]; + Ref mat = materials[p_name][index]; if (current_state == ON_TOP && p_gizmo->is_selected()) { - mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true); + mat->set_flag(Material3D::FLAG_DISABLE_DEPTH_TEST, true); } else { - mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, false); + mat->set_flag(Material3D::FLAG_DISABLE_DEPTH_TEST, false); } return mat; diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 52caa146488..f761bd66080 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -619,11 +619,11 @@ private: bool grid_enabled; Ref move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[4], scale_gizmo[3], scale_plane_gizmo[3]; - Ref gizmo_color[3]; - Ref plane_gizmo_color[3]; + Ref gizmo_color[3]; + Ref plane_gizmo_color[3]; Ref rotate_gizmo_color[3]; - Ref gizmo_color_hl[3]; - Ref plane_gizmo_color_hl[3]; + Ref gizmo_color_hl[3]; + Ref plane_gizmo_color_hl[3]; Ref rotate_gizmo_color_hl[3]; int over_gizmo_handle; @@ -637,9 +637,9 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; - Ref indicator_mat; + Ref indicator_mat; Ref grid_mat[3]; - Ref cursor_material; + Ref cursor_material; // Scene drag and drop support Spatial *preview_node; @@ -896,7 +896,7 @@ public: protected: int current_state; List current_gizmos; - HashMap>> materials; + HashMap>> materials; static void _bind_methods(); virtual bool has_gizmo(Spatial *p_spatial); @@ -906,9 +906,9 @@ public: void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); void create_icon_material(const String &p_name, const Ref &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); void create_handle_material(const String &p_name, bool p_billboard = false, const Ref &p_icon = nullptr); - void add_material(const String &p_name, Ref p_material); + void add_material(const String &p_name, Ref p_material); - Ref get_material(const String &p_name, const Ref &p_gizmo = Ref()); + Ref get_material(const String &p_name, const Ref &p_gizmo = Ref()); virtual String get_name() const; virtual int get_priority() const; diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 40b49688189..4546c0742cd 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1644,11 +1644,11 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { cursor_colors.push_back(color_z.linear_interpolate(Color(0, 0, 0), 0.75)); cursor_colors.push_back(color_z.linear_interpolate(Color(0, 0, 0), 0.75)); - Ref mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + Ref mat = memnew(SpatialMaterial); + mat->set_flag(Material3D::FLAG_UNSHADED, true); + mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); mat->set_line_width(3); Array d; d.resize(VS::ARRAY_MAX); @@ -1990,7 +1990,7 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->clear(); - const Ref material = raycast->is_enabled() ? raycast->get_debug_material() : get_material("shape_material_disabled"); + const Ref material = raycast->is_enabled() ? raycast->get_debug_material() : get_material("shape_material_disabled"); p_gizmo->add_lines(raycast->get_debug_line_vertices(), material); @@ -2028,7 +2028,7 @@ void ShapeCastGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { p_gizmo->clear(); - const Ref material = shapecast->is_enabled() ? shapecast->get_debug_material() : get_material("shape_material_disabled"); + const Ref material = shapecast->is_enabled() ? shapecast->get_debug_material() : get_material("shape_material_disabled"); p_gizmo->add_lines(shapecast->get_debug_line_vertices(), material); @@ -2051,7 +2051,7 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(Vector3(0, 0, 1.0) * spring_arm->get_length()); - Ref material = get_material("shape_material", p_gizmo); + Ref material = get_material("shape_material", p_gizmo); p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 6e6380d7c18..f227e207c25 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -878,7 +878,7 @@ void SpaceBullet::update_gravity() { static ImmediateGeometry *motionVec(NULL); static ImmediateGeometry *normalLine(NULL); -static Ref red_mat; +static Ref red_mat; static Ref blue_mat; #endif @@ -895,21 +895,21 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f motionVec->set_as_toplevel(true); normalLine->set_as_toplevel(true); - red_mat = Ref(memnew(SpatialMaterial)); - red_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + red_mat = Ref(memnew(SpatialMaterial)); + red_mat->set_flag(Material3D::FLAG_UNSHADED, true); red_mat->set_line_width(20.0); - red_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - red_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - red_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + red_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + red_mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + red_mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); red_mat->set_albedo(Color(1, 0, 0, 1)); motionVec->set_material_override(red_mat); - blue_mat = Ref(memnew(SpatialMaterial)); - blue_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + blue_mat = Ref(memnew(SpatialMaterial)); + blue_mat->set_flag(Material3D::FLAG_UNSHADED, true); blue_mat->set_line_width(20.0); - blue_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - blue_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - blue_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + blue_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + blue_mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + blue_mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); blue_mat->set_albedo(Color(0, 0, 1, 1)); normalLine->set_material_override(blue_mat); } diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index c6518e4ee30..5b76495f68b 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -961,7 +961,7 @@ void CSGMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void CSGMesh::set_mesh(const Ref &p_mesh) { @@ -1128,7 +1128,7 @@ void CSGSphere::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void CSGSphere::set_radius(const float p_radius) { @@ -1307,7 +1307,7 @@ void CSGBox::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void CSGBox::set_width(const float p_width) { @@ -1521,7 +1521,7 @@ void CSGCylinder::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cone"), "set_cone", "is_cone"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void CSGCylinder::set_radius(const float p_radius) { @@ -1748,7 +1748,7 @@ void CSGTorus::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ring_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_ring_sides", "get_ring_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void CSGTorus::set_inner_radius(const float p_inner_radius) { @@ -2266,7 +2266,7 @@ void CSGPolygon::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_u_distance", PROPERTY_HINT_RANGE, "0.0,10.0,0.01,or_greater"), "set_path_u_distance", "get_path_u_distance"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_joined"), "set_path_joined", "is_path_joined"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); BIND_ENUM_CONSTANT(MODE_DEPTH); BIND_ENUM_CONSTANT(MODE_SPIN); diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index 56452384882..f8aa99f4b1c 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -184,7 +184,7 @@ FBXMaterial::MaterialInfo FBXMaterial::extract_material_info(const FBXDocParser: const String texture_name = absoulte_fbx_file_path.get_file(); print_verbose("Getting FBX mapping mode for " + String(fbx_mapping_name.c_str())); - const SpatialMaterial::TextureParam mapping_mode = fbx_texture_mapping_desc.at(fbx_mapping_name); + const Material3D::TextureParam mapping_mode = fbx_texture_mapping_desc.at(fbx_mapping_name); print_verbose("Set FBX mapping mode to " + get_texture_param_name(mapping_mode)); TextureFileMapping file_mapping; file_mapping.map_mode = mapping_mode; @@ -194,42 +194,43 @@ FBXMaterial::MaterialInfo FBXMaterial::extract_material_info(const FBXDocParser: // Make sure to active the various features. switch (mapping_mode) { - case SpatialMaterial::TextureParam::TEXTURE_ALBEDO: - case SpatialMaterial::TextureParam::TEXTURE_METALLIC: - case SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS: - case SpatialMaterial::TextureParam::TEXTURE_FLOWMAP: - case SpatialMaterial::TextureParam::TEXTURE_REFRACTION: - case SpatialMaterial::TextureParam::TEXTURE_MAX: + case Material3D::TextureParam::TEXTURE_ALBEDO: + case Material3D::TextureParam::TEXTURE_METALLIC: + case Material3D::TextureParam::TEXTURE_ROUGHNESS: + case Material3D::TextureParam::TEXTURE_ORM: + case Material3D::TextureParam::TEXTURE_FLOWMAP: + case Material3D::TextureParam::TEXTURE_REFRACTION: + case Material3D::TextureParam::TEXTURE_MAX: // No features required. break; - case SpatialMaterial::TextureParam::TEXTURE_EMISSION: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_EMISSION); + case Material3D::TextureParam::TEXTURE_EMISSION: + mat_info.features.push_back(Material3D::Feature::FEATURE_EMISSION); break; - case SpatialMaterial::TextureParam::TEXTURE_NORMAL: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING); + case Material3D::TextureParam::TEXTURE_NORMAL: + mat_info.features.push_back(Material3D::Feature::FEATURE_NORMAL_MAPPING); break; - case SpatialMaterial::TextureParam::TEXTURE_RIM: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_RIM); + case Material3D::TextureParam::TEXTURE_RIM: + mat_info.features.push_back(Material3D::Feature::FEATURE_RIM); break; - case SpatialMaterial::TextureParam::TEXTURE_CLEARCOAT: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_CLEARCOAT); + case Material3D::TextureParam::TEXTURE_CLEARCOAT: + mat_info.features.push_back(Material3D::Feature::FEATURE_CLEARCOAT); break; - case SpatialMaterial::TextureParam::TEXTURE_AMBIENT_OCCLUSION: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_AMBIENT_OCCLUSION); + case Material3D::TextureParam::TEXTURE_AMBIENT_OCCLUSION: + mat_info.features.push_back(Material3D::Feature::FEATURE_AMBIENT_OCCLUSION); break; - case SpatialMaterial::TextureParam::TEXTURE_DEPTH: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_DEPTH_MAPPING); + case Material3D::TextureParam::TEXTURE_DEPTH: + mat_info.features.push_back(Material3D::Feature::FEATURE_DEPTH_MAPPING); break; - case SpatialMaterial::TextureParam::TEXTURE_SUBSURFACE_SCATTERING: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_SUBSURACE_SCATTERING); + case Material3D::TextureParam::TEXTURE_SUBSURFACE_SCATTERING: + mat_info.features.push_back(Material3D::Feature::FEATURE_SUBSURACE_SCATTERING); break; - case SpatialMaterial::TextureParam::TEXTURE_TRANSMISSION: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_TRANSMISSION); + case Material3D::TextureParam::TEXTURE_TRANSMISSION: + mat_info.features.push_back(Material3D::Feature::FEATURE_TRANSMISSION); break; - case SpatialMaterial::TextureParam::TEXTURE_DETAIL_ALBEDO: - case SpatialMaterial::TextureParam::TEXTURE_DETAIL_MASK: - case SpatialMaterial::TextureParam::TEXTURE_DETAIL_NORMAL: - mat_info.features.push_back(SpatialMaterial::Feature::FEATURE_DETAIL); + case Material3D::TextureParam::TEXTURE_DETAIL_ALBEDO: + case Material3D::TextureParam::TEXTURE_DETAIL_MASK: + case Material3D::TextureParam::TEXTURE_DETAIL_NORMAL: + mat_info.features.push_back(Material3D::Feature::FEATURE_DETAIL); break; } } @@ -247,12 +248,12 @@ T extract_from_prop(FBXDocParser::PropertyPtr prop, const T &p_default, const st return val->Value(); } -Ref FBXMaterial::import_material(ImportState &state) { +Ref FBXMaterial::import_material(ImportState &state) { ERR_FAIL_COND_V(material == nullptr, nullptr); const String p_fbx_current_directory = state.path; - Ref spatial_material; + Ref spatial_material; // read the material file // is material two sided @@ -364,8 +365,8 @@ Ref FBXMaterial::import_material(ImportState &state) { Color c = spatial_material->get_albedo(); c.a = opacity; spatial_material->set_albedo(c); - material_info.features.push_back(SpatialMaterial::Feature::FEATURE_TRANSPARENT); - spatial_material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); + material_info.features.push_back(Material3D::Feature::FEATURE_TRANSPARENT); + spatial_material->set_depth_draw_mode(Material3D::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); } } else if (vector_value) { print_error("unsupported transparent desc type vector!"); @@ -410,7 +411,7 @@ Ref FBXMaterial::import_material(ImportState &state) { } break; case PROPERTY_DESC_COAT: { if (real_value) { - material_info.features.push_back(SpatialMaterial::Feature::FEATURE_CLEARCOAT); + material_info.features.push_back(Material3D::Feature::FEATURE_CLEARCOAT); print_verbose("clearcoat real value: " + rtos(real_value->Value())); spatial_material->set_clearcoat(MIN(1.0f, real_value->Value())); } else { @@ -423,7 +424,7 @@ Ref FBXMaterial::import_material(ImportState &state) { print_verbose("clearcoat real value: " + rtos(real_value->Value())); spatial_material->set_clearcoat_gloss(1.0 - real_value->Value()); - material_info.features.push_back(SpatialMaterial::Feature::FEATURE_CLEARCOAT); + material_info.features.push_back(Material3D::Feature::FEATURE_CLEARCOAT); } else { print_error("unsupported value type for clearcoat gloss"); } @@ -432,7 +433,7 @@ Ref FBXMaterial::import_material(ImportState &state) { if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) { print_verbose("Emissive real value: " + rtos(real_value->Value())); spatial_material->set_emission_energy(real_value->Value()); - material_info.features.push_back(SpatialMaterial::Feature::FEATURE_EMISSION); + material_info.features.push_back(Material3D::Feature::FEATURE_EMISSION); } else if (vector_value && !vector_value->Value().is_equal_approx(Vector3(0, 0, 0))) { const Vector3 &color = vector_value->Value(); Color c; @@ -440,7 +441,7 @@ Ref FBXMaterial::import_material(ImportState &state) { c[1] = color[1]; c[2] = color[2]; spatial_material->set_emission(c); - material_info.features.push_back(SpatialMaterial::Feature::FEATURE_EMISSION); + material_info.features.push_back(Material3D::Feature::FEATURE_EMISSION); } } break; case PROPERTY_DESC_EMISSIVE_COLOR: { @@ -548,31 +549,31 @@ Ref FBXMaterial::import_material(ImportState &state) { } switch (mapping.map_mode) { - case SpatialMaterial::TextureParam::TEXTURE_METALLIC: + case Material3D::TextureParam::TEXTURE_METALLIC: if (mapping.name.to_lower().find("ser") >= 0) { // SER shader. - spatial_material->set_metallic_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_RED); + spatial_material->set_metallic_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_RED); } else { // Use grayscale as default. - spatial_material->set_metallic_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); + spatial_material->set_metallic_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); } break; - case SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS: + case Material3D::TextureParam::TEXTURE_ROUGHNESS: if (mapping.name.to_lower().find("ser") >= 0) { // SER shader. - spatial_material->set_roughness_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_BLUE); + spatial_material->set_roughness_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_BLUE); } else { // Use grayscale as default. - spatial_material->set_roughness_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); + spatial_material->set_roughness_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); } break; - case SpatialMaterial::TextureParam::TEXTURE_AMBIENT_OCCLUSION: + case Material3D::TextureParam::TEXTURE_AMBIENT_OCCLUSION: // Use grayscale as default. - spatial_material->set_ao_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); + spatial_material->set_ao_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); break; - case SpatialMaterial::TextureParam::TEXTURE_REFRACTION: + case Material3D::TextureParam::TEXTURE_REFRACTION: // Use grayscale as default. - spatial_material->set_refraction_texture_channel(SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); + spatial_material->set_refraction_texture_channel(Material3D::TextureChannel::TEXTURE_CHANNEL_GRAYSCALE); break; default: // Nothing to do. diff --git a/modules/fbx/data/fbx_material.h b/modules/fbx/data/fbx_material.h index 1b89216dd99..dbbe17ced9a 100644 --- a/modules/fbx/data/fbx_material.h +++ b/modules/fbx/data/fbx_material.h @@ -71,41 +71,41 @@ struct FBXMaterial : public Reference { }; /* Returns the string representation of the TextureParam enum */ - static String get_texture_param_name(SpatialMaterial::TextureParam param) { + static String get_texture_param_name(Material3D::TextureParam param) { switch (param) { - case SpatialMaterial::TEXTURE_ALBEDO: + case Material3D::TEXTURE_ALBEDO: return "TEXTURE_ALBEDO"; - case SpatialMaterial::TEXTURE_METALLIC: + case Material3D::TEXTURE_METALLIC: return "TEXTURE_METALLIC"; - case SpatialMaterial::TEXTURE_ROUGHNESS: + case Material3D::TEXTURE_ROUGHNESS: return "TEXTURE_ROUGHNESS"; - case SpatialMaterial::TEXTURE_EMISSION: + case Material3D::TEXTURE_EMISSION: return "TEXTURE_EMISSION"; - case SpatialMaterial::TEXTURE_NORMAL: + case Material3D::TEXTURE_NORMAL: return "TEXTURE_NORMAL"; - case SpatialMaterial::TEXTURE_RIM: + case Material3D::TEXTURE_RIM: return "TEXTURE_RIM"; - case SpatialMaterial::TEXTURE_CLEARCOAT: + case Material3D::TEXTURE_CLEARCOAT: return "TEXTURE_CLEARCOAT"; - case SpatialMaterial::TEXTURE_FLOWMAP: + case Material3D::TEXTURE_FLOWMAP: return "TEXTURE_FLOWMAP"; - case SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION: + case Material3D::TEXTURE_AMBIENT_OCCLUSION: return "TEXTURE_AMBIENT_OCCLUSION"; - case SpatialMaterial::TEXTURE_DEPTH: + case Material3D::TEXTURE_DEPTH: return "TEXTURE_DEPTH"; - case SpatialMaterial::TEXTURE_SUBSURFACE_SCATTERING: + case Material3D::TEXTURE_SUBSURFACE_SCATTERING: return "TEXTURE_SUBSURFACE_SCATTERING"; - case SpatialMaterial::TEXTURE_TRANSMISSION: + case Material3D::TEXTURE_TRANSMISSION: return "TEXTURE_TRANSMISSION"; - case SpatialMaterial::TEXTURE_REFRACTION: + case Material3D::TEXTURE_REFRACTION: return "TEXTURE_REFRACTION"; - case SpatialMaterial::TEXTURE_DETAIL_MASK: + case Material3D::TEXTURE_DETAIL_MASK: return "TEXTURE_DETAIL_MASK"; - case SpatialMaterial::TEXTURE_DETAIL_ALBEDO: + case Material3D::TEXTURE_DETAIL_ALBEDO: return "TEXTURE_DETAIL_ALBEDO"; - case SpatialMaterial::TEXTURE_DETAIL_NORMAL: + case Material3D::TEXTURE_DETAIL_NORMAL: return "TEXTURE_DETAIL_NORMAL"; - case SpatialMaterial::TEXTURE_MAX: + case Material3D::TEXTURE_MAX: return "TEXTURE_MAX"; default: return "broken horribly"; @@ -113,69 +113,69 @@ struct FBXMaterial : public Reference { }; // TODO make this static? - const std::map fbx_feature_mapping_desc = { + const std::map fbx_feature_mapping_desc = { /* Transparent */ - { "TransparentColor", SpatialMaterial::Feature::FEATURE_TRANSPARENT }, - { "Maya|opacity", SpatialMaterial::Feature::FEATURE_TRANSPARENT } + { "TransparentColor", Material3D::Feature::FEATURE_TRANSPARENT }, + { "Maya|opacity", Material3D::Feature::FEATURE_TRANSPARENT } }; // TODO make this static? - const std::map fbx_texture_mapping_desc = { + const std::map fbx_texture_mapping_desc = { /* Diffuse */ - { "Maya|base", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "DiffuseColor", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "Maya|DiffuseTexture", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "Maya|baseColor", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "Maya|baseColor|file", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "3dsMax|Parameters|base_color_map", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "Maya|TEX_color_map|file", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, - { "Maya|TEX_color_map", SpatialMaterial::TextureParam::TEXTURE_ALBEDO }, + { "Maya|base", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "DiffuseColor", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "Maya|DiffuseTexture", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "Maya|baseColor", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "Maya|baseColor|file", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "3dsMax|Parameters|base_color_map", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "Maya|TEX_color_map|file", Material3D::TextureParam::TEXTURE_ALBEDO }, + { "Maya|TEX_color_map", Material3D::TextureParam::TEXTURE_ALBEDO }, /* Emission */ - { "EmissiveColor", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "EmissiveFactor", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "Maya|emissionColor", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "Maya|emissionColor|file", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "3dsMax|Parameters|emission_map", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "Maya|TEX_emissive_map", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, - { "Maya|TEX_emissive_map|file", SpatialMaterial::TextureParam::TEXTURE_EMISSION }, + { "EmissiveColor", Material3D::TextureParam::TEXTURE_EMISSION }, + { "EmissiveFactor", Material3D::TextureParam::TEXTURE_EMISSION }, + { "Maya|emissionColor", Material3D::TextureParam::TEXTURE_EMISSION }, + { "Maya|emissionColor|file", Material3D::TextureParam::TEXTURE_EMISSION }, + { "3dsMax|Parameters|emission_map", Material3D::TextureParam::TEXTURE_EMISSION }, + { "Maya|TEX_emissive_map", Material3D::TextureParam::TEXTURE_EMISSION }, + { "Maya|TEX_emissive_map|file", Material3D::TextureParam::TEXTURE_EMISSION }, /* Metallic */ - { "Maya|metalness", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|metalness|file", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "3dsMax|Parameters|metalness_map", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|TEX_metallic_map", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|TEX_metallic_map|file", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "SpecularColor", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|specularColor", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|SpecularTexture", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, - { "Maya|SpecularTexture|file", SpatialMaterial::TextureParam::TEXTURE_METALLIC }, + { "Maya|metalness", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|metalness|file", Material3D::TextureParam::TEXTURE_METALLIC }, + { "3dsMax|Parameters|metalness_map", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|TEX_metallic_map", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|TEX_metallic_map|file", Material3D::TextureParam::TEXTURE_METALLIC }, + { "SpecularColor", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|specularColor", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|SpecularTexture", Material3D::TextureParam::TEXTURE_METALLIC }, + { "Maya|SpecularTexture|file", Material3D::TextureParam::TEXTURE_METALLIC }, /* Roughness */ // Arnold Roughness Map - { "Maya|specularRoughness", SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS }, + { "Maya|specularRoughness", Material3D::TextureParam::TEXTURE_ROUGHNESS }, - { "3dsMax|Parameters|roughness_map", SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS }, - { "Maya|TEX_roughness_map", SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS }, - { "Maya|TEX_roughness_map|file", SpatialMaterial::TextureParam::TEXTURE_ROUGHNESS }, + { "3dsMax|Parameters|roughness_map", Material3D::TextureParam::TEXTURE_ROUGHNESS }, + { "Maya|TEX_roughness_map", Material3D::TextureParam::TEXTURE_ROUGHNESS }, + { "Maya|TEX_roughness_map|file", Material3D::TextureParam::TEXTURE_ROUGHNESS }, /* Normal */ - { "NormalMap", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - //{ "Bump", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - //{ "3dsMax|Parameters|bump_map", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - { "Maya|NormalTexture", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - //{ "Maya|normalCamera", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - //{ "Maya|normalCamera|file", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - { "Maya|TEX_normal_map", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, - { "Maya|TEX_normal_map|file", SpatialMaterial::TextureParam::TEXTURE_NORMAL }, + { "NormalMap", Material3D::TextureParam::TEXTURE_NORMAL }, + //{ "Bump", Material3D::TextureParam::TEXTURE_NORMAL }, + //{ "3dsMax|Parameters|bump_map", Material3D::TextureParam::TEXTURE_NORMAL }, + { "Maya|NormalTexture", Material3D::TextureParam::TEXTURE_NORMAL }, + //{ "Maya|normalCamera", Material3D::TextureParam::TEXTURE_NORMAL }, + //{ "Maya|normalCamera|file", Material3D::TextureParam::TEXTURE_NORMAL }, + { "Maya|TEX_normal_map", Material3D::TextureParam::TEXTURE_NORMAL }, + { "Maya|TEX_normal_map|file", Material3D::TextureParam::TEXTURE_NORMAL }, /* AO */ - { "Maya|TEX_ao_map", SpatialMaterial::TextureParam::TEXTURE_AMBIENT_OCCLUSION }, - { "Maya|TEX_ao_map|file", SpatialMaterial::TextureParam::TEXTURE_AMBIENT_OCCLUSION }, + { "Maya|TEX_ao_map", Material3D::TextureParam::TEXTURE_AMBIENT_OCCLUSION }, + { "Maya|TEX_ao_map|file", Material3D::TextureParam::TEXTURE_AMBIENT_OCCLUSION }, - //{ "Maya|diffuseRoughness", SpatialMaterial::TextureParam::UNSUPPORTED }, - //{ "Maya|diffuseRoughness|file", SpatialMaterial::TextureParam::UNSUPPORTED }, - //{ "ShininessExponent", SpatialMaterial::TextureParam::UNSUPPORTED }, - //{ "ReflectionFactor", SpatialMaterial::TextureParam::UNSUPPORTED }, - //{ "TransparentColor",SpatialMaterial::TextureParam::TEXTURE_CHANNEL_ALPHA }, - //{ "TransparencyFactor",SpatialMaterial::TextureParam::TEXTURE_CHANNEL_ALPHA } + //{ "Maya|diffuseRoughness", Material3D::TextureParam::UNSUPPORTED }, + //{ "Maya|diffuseRoughness|file", Material3D::TextureParam::UNSUPPORTED }, + //{ "ShininessExponent", Material3D::TextureParam::UNSUPPORTED }, + //{ "ReflectionFactor", Material3D::TextureParam::UNSUPPORTED }, + //{ "TransparentColor",Material3D::TextureParam::TEXTURE_CHANNEL_ALPHA }, + //{ "TransparencyFactor",Material3D::TextureParam::TEXTURE_CHANNEL_ALPHA } }; // TODO make this static? @@ -261,7 +261,7 @@ struct FBXMaterial : public Reference { }; struct TextureFileMapping { - SpatialMaterial::TextureParam map_mode = SpatialMaterial::TEXTURE_ALBEDO; + Material3D::TextureParam map_mode = Material3D::TEXTURE_ALBEDO; String name = String(); const FBXDocParser::Texture *texture = nullptr; }; @@ -269,7 +269,7 @@ struct FBXMaterial : public Reference { /* storing the texture properties like color */ template struct TexturePropertyMapping : Reference { - SpatialMaterial::TextureParam map_mode = SpatialMaterial::TextureParam::TEXTURE_ALBEDO; + Material3D::TextureParam map_mode = Material3D::TextureParam::TEXTURE_ALBEDO; const T property = T(); }; @@ -283,12 +283,12 @@ struct FBXMaterial : public Reference { struct MaterialInfo { Vector textures; - Vector features; + Vector features; }; /// Extracts the material information. MaterialInfo extract_material_info(const FBXDocParser::Material *material) const; - Ref import_material(ImportState &state); + Ref import_material(ImportState &state); }; #endif // FBX_MATERIAL_H diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 22d0e2afbac..02897a493fd 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -110,7 +110,7 @@ struct SurfaceData { Ref surface_tool; OrderedHashMap lookup_table; // proposed fix is to replace lookup_table[vertex_id] to give the position of the vertices_map[int] index. LocalVector vertices_map; // this must be ordered the same as insertion <-- slow to do find() operation. - Ref material; + Ref material; HashMap> surface_polygon_vertex; Array morphs; }; diff --git a/modules/fbx/data/import_state.h b/modules/fbx/data/import_state.h index 481b3d95985..e15d8a59c84 100644 --- a/modules/fbx/data/import_state.h +++ b/modules/fbx/data/import_state.h @@ -67,7 +67,7 @@ struct ImportState { bool is_blender_fbx = false; Map> cached_image_searches; - Map> cached_materials; + Map> cached_materials; String path = String(); Spatial *root_owner = nullptr; diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index ff0432f4a04..faebc560e7d 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -530,7 +530,7 @@ Spatial *EditorSceneImporterFBX::_generate_scene( material.instance(); material->set_imported_material(mat); - Ref godot_material = material->import_material(state); + Ref godot_material = material->import_material(state); state.cached_materials.insert(material_id, godot_material); } diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index dc0f4b5c0c8..505ab1cae85 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -2587,7 +2587,7 @@ Error GLTFDocument::_serialize_meshes(Ref p_state) { if (surface_i < instance_materials.size()) { v = instance_materials.get(surface_i); } - Ref mat = v; + Ref mat = v; if (!mat.is_valid()) { mat = import_mesh->surface_get_material(surface_i); } @@ -2919,20 +2919,20 @@ Error GLTFDocument::_parse_meshes(Ref p_state) { //just add it - Ref mat; + Ref mat; if (p.has("material")) { const int material = p["material"]; ERR_FAIL_INDEX_V(material, p_state->materials.size(), ERR_FILE_CORRUPT); - Ref mat3d = p_state->materials[material]; + Ref mat3d = p_state->materials[material]; if (has_vertex_color) { - mat3d->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat3d->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); } mat = mat3d; } else if (has_vertex_color) { - Ref mat3d; + Ref mat3d; mat3d.instance(); - mat3d->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat3d->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat = mat3d; } int32_t mat_idx = import_mesh->get_surface_count(); @@ -3377,7 +3377,7 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { for (int32_t i = 0; i < p_state->materials.size(); i++) { Dictionary d; - Ref material = p_state->materials[i]; + Ref material = p_state->materials[i]; if (material.is_null()) { materials.push_back(d); continue; @@ -3398,7 +3398,7 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { } { Dictionary bct; - Ref albedo_texture = material->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + Ref albedo_texture = material->get_texture(Material3D::TEXTURE_ALBEDO); GLTFTextureIndex gltf_texture_index = -1; if (albedo_texture.is_valid() && albedo_texture->get_data().is_valid()) { @@ -3418,17 +3418,17 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { mr["metallicFactor"] = material->get_metallic(); mr["roughnessFactor"] = material->get_roughness(); - bool has_roughness = material->get_texture(SpatialMaterial::TEXTURE_ROUGHNESS).is_valid() && material->get_texture(SpatialMaterial::TEXTURE_ROUGHNESS)->get_data().is_valid(); - bool has_ao = material->get_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION) && material->get_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION).is_valid(); - bool has_metalness = material->get_texture(SpatialMaterial::TEXTURE_METALLIC).is_valid() && material->get_texture(SpatialMaterial::TEXTURE_METALLIC)->get_data().is_valid(); + bool has_roughness = material->get_texture(Material3D::TEXTURE_ROUGHNESS).is_valid() && material->get_texture(Material3D::TEXTURE_ROUGHNESS)->get_data().is_valid(); + bool has_ao = material->get_feature(Material3D::FEATURE_AMBIENT_OCCLUSION) && material->get_texture(Material3D::TEXTURE_AMBIENT_OCCLUSION).is_valid(); + bool has_metalness = material->get_texture(Material3D::TEXTURE_METALLIC).is_valid() && material->get_texture(Material3D::TEXTURE_METALLIC)->get_data().is_valid(); if (has_ao || has_roughness || has_metalness) { Dictionary mrt; - Ref roughness_texture = material->get_texture(SpatialMaterial::TEXTURE_ROUGHNESS); - SpatialMaterial::TextureChannel roughness_channel = material->get_roughness_texture_channel(); - Ref metallic_texture = material->get_texture(SpatialMaterial::TEXTURE_METALLIC); - SpatialMaterial::TextureChannel metalness_channel = material->get_metallic_texture_channel(); - Ref ao_texture = material->get_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION); - SpatialMaterial::TextureChannel ao_channel = material->get_ao_texture_channel(); + Ref roughness_texture = material->get_texture(Material3D::TEXTURE_ROUGHNESS); + Material3D::TextureChannel roughness_channel = material->get_roughness_texture_channel(); + Ref metallic_texture = material->get_texture(Material3D::TEXTURE_METALLIC); + Material3D::TextureChannel metalness_channel = material->get_metallic_texture_channel(); + Ref ao_texture = material->get_texture(Material3D::TEXTURE_AMBIENT_OCCLUSION); + Material3D::TextureChannel ao_channel = material->get_ao_texture_channel(); Ref orm_texture; orm_texture.instance(); Ref orm_image; @@ -3474,7 +3474,7 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { metallness_image->decompress(); } } - Ref albedo_texture = material->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + Ref albedo_texture = material->get_texture(Material3D::TEXTURE_ALBEDO); if (albedo_texture.is_valid() && albedo_texture->get_data().is_valid()) { height = albedo_texture->get_height(); width = albedo_texture->get_width(); @@ -3495,39 +3495,39 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { Color c = Color(1.0f, 1.0f, 1.0f); if (has_ao) { ao_image->lock(); - if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_RED == ao_channel) { + if (Material3D::TextureChannel::TEXTURE_CHANNEL_RED == ao_channel) { c.r = ao_image->get_pixel(w, h).r; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GREEN == ao_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_GREEN == ao_channel) { c.r = ao_image->get_pixel(w, h).g; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_BLUE == ao_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_BLUE == ao_channel) { c.r = ao_image->get_pixel(w, h).b; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_ALPHA == ao_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_ALPHA == ao_channel) { c.r = ao_image->get_pixel(w, h).a; } ao_image->lock(); } if (has_roughness) { roughness_image->lock(); - if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_RED == roughness_channel) { + if (Material3D::TextureChannel::TEXTURE_CHANNEL_RED == roughness_channel) { c.g = roughness_image->get_pixel(w, h).r; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GREEN == roughness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_GREEN == roughness_channel) { c.g = roughness_image->get_pixel(w, h).g; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_BLUE == roughness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_BLUE == roughness_channel) { c.g = roughness_image->get_pixel(w, h).b; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_ALPHA == roughness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_ALPHA == roughness_channel) { c.g = roughness_image->get_pixel(w, h).a; } roughness_image->unlock(); } if (has_metalness) { metallness_image->lock(); - if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_RED == metalness_channel) { + if (Material3D::TextureChannel::TEXTURE_CHANNEL_RED == metalness_channel) { c.b = metallness_image->get_pixel(w, h).r; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_GREEN == metalness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_GREEN == metalness_channel) { c.b = metallness_image->get_pixel(w, h).g; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_BLUE == metalness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_BLUE == metalness_channel) { c.b = metallness_image->get_pixel(w, h).b; - } else if (SpatialMaterial::TextureChannel::TEXTURE_CHANNEL_ALPHA == metalness_channel) { + } else if (Material3D::TextureChannel::TEXTURE_CHANNEL_ALPHA == metalness_channel) { c.b = metallness_image->get_pixel(w, h).a; } metallness_image->unlock(); @@ -3561,12 +3561,12 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { d["pbrMetallicRoughness"] = mr; } - if (material->get_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING)) { + if (material->get_feature(Material3D::FEATURE_NORMAL_MAPPING)) { Dictionary nt; Ref tex; tex.instance(); { - Ref normal_texture = material->get_texture(SpatialMaterial::TEXTURE_NORMAL); + Ref normal_texture = material->get_texture(Material3D::TEXTURE_NORMAL); if (normal_texture.is_valid()) { // Code for uncompressing RG normal maps Ref img = normal_texture->get_data(); @@ -3606,7 +3606,7 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { } } - if (material->get_feature(SpatialMaterial::FEATURE_EMISSION)) { + if (material->get_feature(Material3D::FEATURE_EMISSION)) { const Color c = material->get_emission().to_srgb(); Array arr; arr.push_back(c.r); @@ -3614,9 +3614,9 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { arr.push_back(c.b); d["emissiveFactor"] = arr; } - if (material->get_feature(SpatialMaterial::FEATURE_EMISSION)) { + if (material->get_feature(Material3D::FEATURE_EMISSION)) { Dictionary et; - Ref emission_texture = material->get_texture(SpatialMaterial::TEXTURE_EMISSION); + Ref emission_texture = material->get_texture(Material3D::TEXTURE_EMISSION); GLTFTextureIndex gltf_texture_index = -1; if (emission_texture.is_valid() && emission_texture->get_data().is_valid()) { emission_texture->set_name(material->get_name() + "_emission"); @@ -3628,12 +3628,12 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { d["emissiveTexture"] = et; } } - const bool ds = material->get_cull_mode() == SpatialMaterial::CULL_DISABLED; + const bool ds = material->get_cull_mode() == Material3D::CULL_DISABLED; if (ds) { d["doubleSided"] = ds; } - if (material->get_feature(SpatialMaterial::FEATURE_TRANSPARENT)) { - if (material->get_flag(SpatialMaterial::FLAG_USE_ALPHA_SCISSOR)) { + if (material->get_feature(Material3D::FEATURE_TRANSPARENT)) { + if (material->get_flag(Material3D::FLAG_USE_ALPHA_SCISSOR)) { d["alphaMode"] = "MASK"; d["alphaCutoff"] = material->get_alpha_scissor_threshold(); } else { @@ -3642,7 +3642,7 @@ Error GLTFDocument::_serialize_materials(Ref p_state) { } Dictionary extensions; - if (material->get_flag(SpatialMaterial::FLAG_UNSHADED)) { + if (material->get_flag(Material3D::FLAG_UNSHADED)) { Dictionary mat_unlit; extensions["KHR_materials_unlit"] = mat_unlit; p_state->add_used_extension("KHR_materials_unlit"); @@ -3669,7 +3669,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { for (GLTFMaterialIndex i = 0; i < materials.size(); i++) { const Dictionary &d = materials[i]; - Ref material; + Ref material; material.instance(); if (d.has("name") && !String(d["name"]).empty()) { material->set_name(d["name"]); @@ -3677,14 +3677,14 @@ Error GLTFDocument::_parse_materials(Ref p_state) { material->set_name(vformat("material_%s", itos(i))); } - material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); Dictionary pbr_spec_gloss_extensions; if (d.has("extensions")) { pbr_spec_gloss_extensions = d["extensions"]; } if (pbr_spec_gloss_extensions.has("KHR_materials_unlit")) { - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + material->set_flag(Material3D::FLAG_UNSHADED, true); } if (pbr_spec_gloss_extensions.has("KHR_materials_pbrSpecularGlossiness")) { @@ -3699,7 +3699,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { Ref diffuse_texture = _get_texture(p_state, diffuse_texture_dict["index"]); if (diffuse_texture.is_valid()) { spec_gloss->diffuse_img = diffuse_texture->get_data(); - material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, diffuse_texture); + material->set_texture(Material3D::TEXTURE_ALBEDO, diffuse_texture); } } } @@ -3744,7 +3744,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { if (mr.has("baseColorTexture")) { const Dictionary &bct = mr["baseColorTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _get_texture(p_state, bct["index"])); + material->set_texture(Material3D::TEXTURE_ALBEDO, _get_texture(p_state, bct["index"])); } if (!mr.has("baseColorFactor")) { material->set_albedo(Color(1, 1, 1)); @@ -3768,10 +3768,10 @@ Error GLTFDocument::_parse_materials(Ref p_state) { const Dictionary &bct = mr["metallicRoughnessTexture"]; if (bct.has("index")) { const Ref t = _get_texture(p_state, bct["index"]); - material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); - material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); - material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); - material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN); + material->set_texture(Material3D::TEXTURE_METALLIC, t); + material->set_metallic_texture_channel(Material3D::TEXTURE_CHANNEL_BLUE); + material->set_texture(Material3D::TEXTURE_ROUGHNESS, t); + material->set_roughness_texture_channel(Material3D::TEXTURE_CHANNEL_GREEN); if (!mr.has("metallicFactor")) { material->set_metallic(1); } @@ -3785,8 +3785,8 @@ Error GLTFDocument::_parse_materials(Ref p_state) { if (d.has("normalTexture")) { const Dictionary &bct = d["normalTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_NORMAL, _get_texture(p_state, bct["index"])); - material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); + material->set_texture(Material3D::TEXTURE_NORMAL, _get_texture(p_state, bct["index"])); + material->set_feature(Material3D::FEATURE_NORMAL_MAPPING, true); } if (bct.has("scale")) { material->set_normal_scale(bct["scale"]); @@ -3795,9 +3795,9 @@ Error GLTFDocument::_parse_materials(Ref p_state) { if (d.has("occlusionTexture")) { const Dictionary &bct = d["occlusionTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(p_state, bct["index"])); - material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); - material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); + material->set_texture(Material3D::TEXTURE_AMBIENT_OCCLUSION, _get_texture(p_state, bct["index"])); + material->set_ao_texture_channel(Material3D::TEXTURE_CHANNEL_RED); + material->set_feature(Material3D::FEATURE_AMBIENT_OCCLUSION, true); } } @@ -3805,7 +3805,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { const Array &arr = d["emissiveFactor"]; ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR); const Color c = Color(arr[0], arr[1], arr[2]).to_srgb(); - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_feature(Material3D::FEATURE_EMISSION, true); material->set_emission(c); } @@ -3813,8 +3813,8 @@ Error GLTFDocument::_parse_materials(Ref p_state) { if (d.has("emissiveTexture")) { const Dictionary &bct = d["emissiveTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_EMISSION, _get_texture(p_state, bct["index"])); - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_texture(Material3D::TEXTURE_EMISSION, _get_texture(p_state, bct["index"])); + material->set_feature(Material3D::FEATURE_EMISSION, true); material->set_emission(Color(0, 0, 0)); } } @@ -3822,17 +3822,17 @@ Error GLTFDocument::_parse_materials(Ref p_state) { if (d.has("doubleSided")) { const bool ds = d["doubleSided"]; if (ds) { - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(Material3D::CULL_DISABLED); } } if (d.has("alphaMode")) { const String &am = d["alphaMode"]; if (am == "BLEND") { - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); + material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + material->set_depth_draw_mode(Material3D::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); } else if (am == "MASK") { - material->set_flag(SpatialMaterial::FLAG_USE_ALPHA_SCISSOR, true); + material->set_flag(Material3D::FLAG_USE_ALPHA_SCISSOR, true); if (d.has("alphaCutoff")) { material->set_alpha_scissor_threshold(d["alphaCutoff"]); } else { @@ -3848,7 +3848,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { return OK; } -void GLTFDocument::_set_texture_transform_uv1(const Dictionary &p_dict, Ref p_material) { +void GLTFDocument::_set_texture_transform_uv1(const Dictionary &p_dict, Ref p_material) { if (p_dict.has("extensions")) { const Dictionary &extensions = p_dict["extensions"]; if (extensions.has("KHR_texture_transform")) { @@ -3868,7 +3868,7 @@ void GLTFDocument::_set_texture_transform_uv1(const Dictionary &p_dict, Ref r_spec_gloss, Ref p_material) { +void GLTFDocument::spec_gloss_to_rough_metal(Ref r_spec_gloss, Ref p_material) { if (r_spec_gloss->spec_gloss_img.is_null()) { return; } @@ -3922,18 +3922,18 @@ void GLTFDocument::spec_gloss_to_rough_metal(Ref r_spec_gloss, Re Ref diffuse_image_texture; diffuse_image_texture.instance(); diffuse_image_texture->create_from_image(r_spec_gloss->diffuse_img); - p_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, diffuse_image_texture); + p_material->set_texture(Material3D::TEXTURE_ALBEDO, diffuse_image_texture); Ref rm_image_texture; rm_image_texture.instance(); rm_image_texture->create_from_image(rm_img); if (has_roughness) { - p_material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, rm_image_texture); - p_material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN); + p_material->set_texture(Material3D::TEXTURE_ROUGHNESS, rm_image_texture); + p_material->set_roughness_texture_channel(Material3D::TEXTURE_CHANNEL_GREEN); } if (has_metal) { - p_material->set_texture(SpatialMaterial::TEXTURE_METALLIC, rm_image_texture); - p_material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); + p_material->set_texture(Material3D::TEXTURE_METALLIC, rm_image_texture); + p_material->set_metallic_texture_channel(Material3D::TEXTURE_CHANNEL_BLUE); } } @@ -6859,7 +6859,7 @@ Dictionary _serialize_texture_transform_uv(Vector2 p_offset, Vector2 p_scale) { return extension; } -Dictionary GLTFDocument::_serialize_texture_transform_uv1(Ref p_material) { +Dictionary GLTFDocument::_serialize_texture_transform_uv1(Ref p_material) { if (p_material.is_valid()) { Vector3 offset = p_material->get_uv1_offset(); Vector3 scale = p_material->get_uv1_scale(); @@ -6868,7 +6868,7 @@ Dictionary GLTFDocument::_serialize_texture_transform_uv1(Ref p return Dictionary(); } -Dictionary GLTFDocument::_serialize_texture_transform_uv2(Ref p_material) { +Dictionary GLTFDocument::_serialize_texture_transform_uv2(Ref p_material) { if (p_material.is_valid()) { Vector3 offset = p_material->get_uv2_offset(); Vector3 scale = p_material->get_uv2_scale(); diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 58c5cdbb451..4027aeae956 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -171,9 +171,9 @@ private: Error _parse_textures(Ref p_state); Error _parse_texture_samplers(Ref p_state); Error _parse_materials(Ref p_state); - void _set_texture_transform_uv1(const Dictionary &p_dict, Ref p_material); + void _set_texture_transform_uv1(const Dictionary &p_dict, Ref p_material); void spec_gloss_to_rough_metal(Ref r_spec_gloss, - Ref p_material); + Ref p_material); static void spec_gloss_to_metal_base_color(const Color &p_specular_factor, const Color &p_diffuse, Color &r_base_color, @@ -283,8 +283,8 @@ private: GLTFNodeIndex p_node_i); Error _encode_buffer_bins(Ref p_state, const String &p_path); Error _encode_buffer_glb(Ref p_state, const String &p_path); - Dictionary _serialize_texture_transform_uv1(Ref p_material); - Dictionary _serialize_texture_transform_uv2(Ref p_material); + Dictionary _serialize_texture_transform_uv1(Ref p_material); + Dictionary _serialize_texture_transform_uv2(Ref p_material); Error _serialize_version(Ref p_state); Error _serialize_file(Ref p_state, const String p_path); Error _serialize_gltf_extensions(Ref p_state) const; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 2a175861f43..0b48667581e 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1421,8 +1421,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { inner_mat.instance(); inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2)); - inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + inner_mat->set_flag(Material3D::FLAG_UNSHADED, true); + inner_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); d[VS::ARRAY_VERTEX] = triangles; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d); @@ -1431,14 +1431,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { outer_mat.instance(); outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); outer_mat->set_on_top_of_alpha(); - outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + outer_mat->set_flag(Material3D::FLAG_UNSHADED, true); outer_mat->set_line_width(3.0); - outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + outer_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); selection_floor_mat.instance(); selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1)); selection_floor_mat->set_on_top_of_alpha(); - selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + selection_floor_mat->set_flag(Material3D::FLAG_UNSHADED, true); selection_floor_mat->set_line_width(3.0); d[VS::ARRAY_VERTEX] = lines; @@ -1466,10 +1466,10 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { accumulated_floor_delta = 0.0; indicator_mat.instance(); - indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + indicator_mat->set_flag(Material3D::FLAG_UNSHADED, true); + indicator_mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + indicator_mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + indicator_mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); indicator_mat->set_albedo(Color(0.8, 0.5, 0.1)); } diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 4612278aa5f..a89fbfa02a8 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -124,10 +124,10 @@ class GridMapEditor : public VBoxContainer { List clipboard_items; - Ref indicator_mat; - Ref inner_mat; - Ref outer_mat; - Ref selection_floor_mat; + Ref indicator_mat; + Ref inner_mat; + Ref outer_mat; + Ref selection_floor_mat; bool updating; diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index fc205d6e162..46dbb39ee2a 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -451,7 +451,7 @@ void BakedLightmap::_find_meshes_and_lights(Node *p_at_node, Vector void BakedLightmap::_get_material_images(const MeshesFound &p_found_mesh, Lightmapper::MeshData &r_mesh_data, Vector> &r_albedo_textures, Vector> &r_emission_textures) { for (int i = 0; i < p_found_mesh.mesh->get_surface_count(); ++i) { - Ref mat = p_found_mesh.overrides[i]; + Ref mat = p_found_mesh.overrides[i]; if (mat.is_null()) { mat = p_found_mesh.mesh->surface_get_material(i); @@ -466,7 +466,7 @@ void BakedLightmap::_get_material_images(const MeshesFound &p_found_mesh, Lightm Color emission_mul = Color(1, 1, 1, 1); if (mat.is_valid()) { - albedo_texture = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + albedo_texture = mat->get_texture(Material3D::TEXTURE_ALBEDO); if (albedo_texture.is_valid()) { albedo_mul = mat->get_albedo(); @@ -475,11 +475,11 @@ void BakedLightmap::_get_material_images(const MeshesFound &p_found_mesh, Lightm albedo_add = mat->get_albedo(); } - emission_texture = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); + emission_texture = mat->get_texture(Material3D::TEXTURE_EMISSION); Color emission_color = mat->get_emission(); float emission_energy = mat->get_emission_energy(); - if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) { + if (mat->get_emission_operator() == Material3D::EMISSION_OP_ADD) { emission_mul = Color(1, 1, 1) * emission_energy; emission_add = emission_color * emission_energy; } else { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index 819303c4a08..6f0e7ee0dd9 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -209,14 +209,14 @@ String CPUParticles::get_configuration_warning() const { mesh_found = true; for (int j = 0; j < get_mesh()->get_surface_count(); j++) { anim_material_found = Object::cast_to(get_mesh()->surface_get_material(j).ptr()) != nullptr; - SpatialMaterial *spat = Object::cast_to(get_mesh()->surface_get_material(j).ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + Material3D *spat = Object::cast_to(get_mesh()->surface_get_material(j).ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == Material3D::BILLBOARD_PARTICLES); } } anim_material_found = anim_material_found || Object::cast_to(get_material_override().ptr()) != nullptr; - SpatialMaterial *spat = Object::cast_to(get_material_override().ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + Material3D *spat = Object::cast_to(get_material_override().ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == Material3D::BILLBOARD_PARTICLES); if (!mesh_found) { if (warnings != String()) { diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index 252ade142dc..3694b8216a5 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -539,7 +539,7 @@ float Label3D::_generate_glyph_surfaces(const Ref &p_font, CharType p_char if (!surfaces.has(key)) { SurfaceData surf; surf.material = RID_PRIME(VisualServer::get_singleton()->material_create()); - // Set defaults for material, names need to match up those in SpatialMaterial + // Set defaults for material, names need to match up those in Material3D VS::get_singleton()->material_set_param(surf.material, "albedo", Color(1, 1, 1, 1)); VS::get_singleton()->material_set_param(surf.material, "specular", 0.5); VS::get_singleton()->material_set_param(surf.material, "metallic", 0.0); @@ -550,7 +550,7 @@ float Label3D::_generate_glyph_surfaces(const Ref &p_font, CharType p_char VS::get_singleton()->material_set_param(surf.material, "uv2_scale", Vector3(1, 1, 1)); VS::get_singleton()->material_set_param(surf.material, "alpha_scissor_threshold", alpha_scissor_threshold); - RID shader_rid = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), true, get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), p_font->is_distance_field_hint()); + RID shader_rid = Material3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), true, get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == Material3D::BILLBOARD_ENABLED, get_billboard_mode() == Material3D::BILLBOARD_FIXED_Y, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), p_font->is_distance_field_hint()); VS::get_singleton()->material_set_shader(surf.material, VS::get_singleton()->material_get_shader(shader_rid)); VS::get_singleton()->material_set_param(surf.material, "texture_albedo", tex); @@ -1003,7 +1003,7 @@ bool Label3D::get_draw_flag(DrawFlags p_flag) const { return flags[p_flag]; } -void Label3D::set_billboard_mode(SpatialMaterial::BillboardMode p_mode) { +void Label3D::set_billboard_mode(Material3D::BillboardMode p_mode) { ERR_FAIL_INDEX(p_mode, 3); if (billboard_mode != p_mode) { billboard_mode = p_mode; @@ -1011,7 +1011,7 @@ void Label3D::set_billboard_mode(SpatialMaterial::BillboardMode p_mode) { } } -SpatialMaterial::BillboardMode Label3D::get_billboard_mode() const { +Material3D::BillboardMode Label3D::get_billboard_mode() const { return billboard_mode; } diff --git a/scene/3d/label_3d.h b/scene/3d/label_3d.h index 80d91be1c44..f2d3d5a236a 100644 --- a/scene/3d/label_3d.h +++ b/scene/3d/label_3d.h @@ -158,7 +158,7 @@ private: float line_spacing = 0.f; RID base_material; - SpatialMaterial::BillboardMode billboard_mode = SpatialMaterial::BILLBOARD_DISABLED; + Material3D::BillboardMode billboard_mode = Material3D::BILLBOARD_DISABLED; bool pending_update = false; @@ -232,8 +232,8 @@ public: void set_alpha_scissor_threshold(float p_threshold); float get_alpha_scissor_threshold() const; - void set_billboard_mode(SpatialMaterial::BillboardMode p_mode); - SpatialMaterial::BillboardMode get_billboard_mode() const; + void set_billboard_mode(Material3D::BillboardMode p_mode); + Material3D::BillboardMode get_billboard_mode() const; virtual AABB get_aabb() const; Ref generate_triangle_mesh() const; diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 64edfedb6cf..048e81791c6 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -104,7 +104,7 @@ void MeshInstance::_get_property_list(List *p_list) const { if (mesh.is_valid()) { for (int i = 0; i < mesh->get_surface_count(); i++) { - p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("%s/%d", PNAME("material"), i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial")); + p_list->push_back(PropertyInfo(Variant::OBJECT, vformat("%s/%d", PNAME("material"), i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial,ORMSpatialMaterial")); } } } @@ -277,11 +277,11 @@ void MeshInstance::_initialize_skinning(bool p_force_reset, bool p_call_attach_s Ref mat = get_active_material(surface_index); if (mat.is_valid()) { - Ref spatial_mat = mat; + Ref spatial_mat = mat; if (spatial_mat.is_valid()) { // Spatial material, check from material settings. - surface_data.transform_tangents = spatial_mat->get_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING); - surface_data.ensure_correct_normals = spatial_mat->get_flag(SpatialMaterial::FLAG_ENSURE_CORRECT_NORMALS); + surface_data.transform_tangents = spatial_mat->get_feature(Material3D::FEATURE_NORMAL_MAPPING); + surface_data.ensure_correct_normals = spatial_mat->get_flag(Material3D::FLAG_ENSURE_CORRECT_NORMALS); } else { // Custom shader, must check for compiled flags. surface_data.transform_tangents = VSG::storage->material_uses_tangents(mat->get_rid()); @@ -822,12 +822,12 @@ void MeshInstance::create_debug_tangents() { } if (lines.size()) { - Ref sm; + Ref sm; sm.instance(); - sm->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - sm->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - sm->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + sm->set_flag(Material3D::FLAG_UNSHADED, true); + sm->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + sm->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); Ref am; am.instance(); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 97b13b1e482..cafabca76dc 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -257,8 +257,8 @@ String Particles::get_configuration_warning() const { meshes_found = true; for (int j = 0; j < draw_passes[i]->get_surface_count(); j++) { anim_material_found = Object::cast_to(draw_passes[i]->surface_get_material(j).ptr()) != nullptr; - SpatialMaterial *spat = Object::cast_to(draw_passes[i]->surface_get_material(j).ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + Material3D *spat = Object::cast_to(draw_passes[i]->surface_get_material(j).ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == Material3D::BILLBOARD_PARTICLES); } if (anim_material_found) { break; @@ -267,8 +267,8 @@ String Particles::get_configuration_warning() const { } anim_material_found = anim_material_found || Object::cast_to(get_material_override().ptr()) != nullptr; - SpatialMaterial *spat = Object::cast_to(get_material_override().ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + Material3D *spat = Object::cast_to(get_material_override().ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == Material3D::BILLBOARD_PARTICLES); if (!meshes_found) { if (warnings != String()) { diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index f6b3a487ceb..0d7ae0c4f26 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -392,7 +392,7 @@ void RayCast::set_debug_shape_custom_color(const Color &p_color) { } } -Ref RayCast::get_debug_material() { +Ref RayCast::get_debug_material() { _update_debug_shape_material(); return debug_material; } @@ -421,13 +421,13 @@ void RayCast::_create_debug_shape() { void RayCast::_update_debug_shape_material(bool p_check_collision) { if (!debug_material.is_valid()) { - Ref material = memnew(SpatialMaterial); + Ref material = memnew(Material3D); debug_material = material; - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + material->set_flag(Material3D::FLAG_UNSHADED, true); + material->set_feature(Material3D::FEATURE_TRANSPARENT, true); // Use double-sided rendering so that the RayCast can be seen if the camera is inside. - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(Material3D::CULL_DISABLED); } Color color = debug_shape_custom_color; @@ -446,7 +446,7 @@ void RayCast::_update_debug_shape_material(bool p_check_collision) { } } - Ref material = static_cast>(debug_material); + Ref material = static_cast>(debug_material); material->set_albedo(color); } diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h index 18ce341dcab..de9d89e92a1 100644 --- a/scene/3d/ray_cast.h +++ b/scene/3d/ray_cast.h @@ -98,7 +98,7 @@ public: const Vector &get_debug_shape_vertices() const; const Vector &get_debug_line_vertices() const; - Ref get_debug_material(); + Ref get_debug_material(); int get_debug_shape_thickness() const; void set_debug_shape_thickness(const int p_debug_thickness); diff --git a/scene/3d/shape_cast.cpp b/scene/3d/shape_cast.cpp index 4ecf6dadf1d..a195fced0e1 100644 --- a/scene/3d/shape_cast.cpp +++ b/scene/3d/shape_cast.cpp @@ -516,7 +516,7 @@ void ShapeCast::set_debug_shape_custom_color(const Color &p_color) { } } -Ref ShapeCast::get_debug_material() { +Ref ShapeCast::get_debug_material() { _update_debug_shape_material(); return debug_material; } @@ -539,13 +539,13 @@ void ShapeCast::_create_debug_shape() { void ShapeCast::_update_debug_shape_material(bool p_check_collision) { if (!debug_material.is_valid()) { - Ref material = memnew(SpatialMaterial); + Ref material = memnew(Material3D); debug_material = material; - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + material->set_flag(Material3D::FLAG_UNSHADED, true); + material->set_feature(Material3D::FEATURE_TRANSPARENT, true); // Use double-sided rendering so that the RayCast can be seen if the camera is inside. - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(Material3D::CULL_DISABLED); } Color color = debug_shape_custom_color; @@ -564,7 +564,7 @@ void ShapeCast::_update_debug_shape_material(bool p_check_collision) { } } - Ref material = static_cast>(debug_material); + Ref material = static_cast>(debug_material); material->set_albedo(color); } diff --git a/scene/3d/shape_cast.h b/scene/3d/shape_cast.h index 3dbe0aad1cd..b9f91d69ae5 100644 --- a/scene/3d/shape_cast.h +++ b/scene/3d/shape_cast.h @@ -116,7 +116,7 @@ public: const Vector &get_debug_shape_vertices() const; const Vector &get_debug_line_vertices() const; - Ref get_debug_material(); + Ref get_debug_material(); int get_collision_count() const; Object *get_collider(int p_idx) const; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 57a2246db16..d53ec7fcb9d 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -231,7 +231,7 @@ void SpriteBase3D::draw_texture_rect(Ref p_texture, Rect2 p_dst_rect, R VS::get_singleton()->mesh_set_custom_aabb(mesh, aabb); set_aabb(aabb); - RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE)); + RID mat = Material3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == Material3D::BILLBOARD_ENABLED, get_billboard_mode() == Material3D::BILLBOARD_FIXED_Y, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE)); VS::get_singleton()->material_set_shader(get_material(), VS::get_singleton()->material_get_shader(mat)); VS::get_singleton()->material_set_param(get_material(), "texture_albedo", p_texture->get_rid()); if (get_alpha_cut_mode() == ALPHA_CUT_DISABLED) { @@ -428,13 +428,13 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const { return alpha_cut; } -void SpriteBase3D::set_billboard_mode(SpatialMaterial::BillboardMode p_mode) { +void SpriteBase3D::set_billboard_mode(Material3D::BillboardMode p_mode) { ERR_FAIL_INDEX(p_mode, 3); billboard_mode = p_mode; _queue_update(); } -SpatialMaterial::BillboardMode SpriteBase3D::get_billboard_mode() const { +Material3D::BillboardMode SpriteBase3D::get_billboard_mode() const { return billboard_mode; } @@ -524,7 +524,7 @@ SpriteBase3D::SpriteBase3D() { } alpha_cut = ALPHA_CUT_DISABLED; - billboard_mode = SpatialMaterial::BILLBOARD_DISABLED; + billboard_mode = Material3D::BILLBOARD_DISABLED; axis = Vector3::AXIS_Z; pixel_size = 0.01; modulate = Color(1, 1, 1, 1); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index a0ccc94d8f7..0abfb61e9a9 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -83,7 +83,7 @@ private: bool flags[FLAG_MAX]; AlphaCutMode alpha_cut; - SpatialMaterial::BillboardMode billboard_mode; + Material3D::BillboardMode billboard_mode; bool pending_update; void _im_update(); @@ -139,8 +139,8 @@ public: void set_alpha_cut_mode(AlphaCutMode p_mode); AlphaCutMode get_alpha_cut_mode() const; - void set_billboard_mode(SpatialMaterial::BillboardMode p_mode); - SpatialMaterial::BillboardMode get_billboard_mode() const; + void set_billboard_mode(Material3D::BillboardMode p_mode); + Material3D::BillboardMode get_billboard_mode() const; virtual Rect2 get_item_rect() const = 0; diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 58f93ba20b7..9713fa19ee1 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -387,8 +387,8 @@ void GeometryInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aabb"), &GeometryInstance::get_aabb); ADD_GROUP("Geometry", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_override", "get_material_override"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_overlay", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_overlay", "get_material_overlay"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial,ORMSpatialMaterial"), "set_material_override", "get_material_override"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_overlay", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial,ORMSpatialMaterial"), "set_material_overlay", "get_material_overlay"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0.01"), "set_extra_cull_margin", "get_extra_cull_margin"); diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index a6521650b9e..4ef6a2d27d2 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -526,7 +526,7 @@ Vector VoxelLightBaker::_get_bake_texture(Ref p_image, const Color VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref p_material) { //this way of obtaining materials is inaccurate and also does not support some compressed formats very well - Ref mat = p_material; + Ref mat = p_material; Ref material = mat; //hack for now @@ -539,7 +539,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref empty; if (mat.is_valid()) { - Ref albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + Ref albedo_tex = mat->get_texture(Material3D::TEXTURE_ALBEDO); Ref img_albedo; if (albedo_tex.is_valid()) { @@ -549,8 +549,8 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Refget_albedo()); // no albedo texture, color is additive } - if (mat->get_feature(SpatialMaterial::FEATURE_EMISSION)) { - Ref emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); + if (mat->get_feature(Material3D::FEATURE_EMISSION)) { + Ref emission_tex = mat->get_texture(Material3D::TEXTURE_EMISSION); Color emission_col = mat->get_emission(); float emission_energy = mat->get_emission_energy(); @@ -561,7 +561,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Refget_data(); } - if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) { + if (mat->get_emission_operator() == Material3D::EMISSION_OP_ADD) { mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy); } else { mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0)); @@ -1507,11 +1507,11 @@ Ref VoxelLightBaker::create_debug_multimesh(DebugMode p_mode) { } { - Ref fsm; + Ref fsm; fsm.instance(); - fsm->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - fsm->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - fsm->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + fsm->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + fsm->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + fsm->set_flag(Material3D::FLAG_UNSHADED, true); fsm->set_albedo(Color(1, 1, 1, 1)); mesh->surface_set_material(0, fsm); diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index 24b944f66e8..fe716c0d180 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -77,7 +77,7 @@ bool RootMotionView::get_zero_y() const { void RootMotionView::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - VS::get_singleton()->immediate_set_material(immediate, SpatialMaterial::get_material_rid_for_2d(false, true, false, false, false)); + VS::get_singleton()->immediate_set_material(immediate, Material3D::get_material_rid_for_2d(false, true, false, false, false)); first = true; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 5562216fa8f..cab97256c59 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -935,11 +935,11 @@ Ref SceneTree::get_debug_navigation_material() { return navigation_material; } - Ref line_material = Ref(memnew(SpatialMaterial)); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref line_material = Ref(memnew(SpatialMaterial)); + line_material->set_flag(Material3D::FLAG_UNSHADED, true); + line_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + line_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_navigation_color()); navigation_material = line_material; @@ -952,11 +952,11 @@ Ref SceneTree::get_debug_navigation_disabled_material() { return navigation_disabled_material; } - Ref line_material = Ref(memnew(SpatialMaterial)); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref line_material = Ref(memnew(SpatialMaterial)); + line_material->set_flag(Material3D::FLAG_UNSHADED, true); + line_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + line_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_navigation_disabled_color()); navigation_disabled_material = line_material; @@ -968,11 +968,11 @@ Ref SceneTree::get_debug_collision_material() { return collision_material; } - Ref line_material = Ref(memnew(SpatialMaterial)); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref line_material = Ref(memnew(SpatialMaterial)); + line_material->set_flag(Material3D::FLAG_UNSHADED, true); + line_material->set_feature(Material3D::FEATURE_TRANSPARENT, true); + line_material->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_collisions_color()); collision_material = line_material; @@ -987,11 +987,11 @@ Ref SceneTree::get_debug_contact_mesh() { debug_contact_mesh = Ref(memnew(ArrayMesh)); - Ref mat = Ref(memnew(SpatialMaterial)); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref mat = Ref(memnew(SpatialMaterial)); + mat->set_flag(Material3D::FLAG_UNSHADED, true); + mat->set_feature(Material3D::FEATURE_TRANSPARENT, true); + mat->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat->set_albedo(get_debug_collision_contact_color()); Vector3 diamond[6] = { diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index e96726eed68..9fd44f9e2c2 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -670,9 +670,11 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_virtual_class(); + ClassDB::register_virtual_class(); ClassDB::register_class(); - SceneTree::add_idle_callback(SpatialMaterial::flush_changes); - SpatialMaterial::init_shaders(); + ClassDB::register_class(); + SceneTree::add_idle_callback(Material3D::flush_changes); + Material3D::init_shaders(); ClassDB::register_class(); @@ -875,7 +877,7 @@ void unregister_scene_types() { //SpatialMaterial is not initialised when 3D is disabled, so it shouldn't be cleaned up either #ifndef _3D_DISABLED - SpatialMaterial::finish_shaders(); + Material3D::finish_shaders(); #endif // _3D_DISABLED ParticlesMaterial::finish_shaders(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 6fa88026f0c..85d4075b076 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -271,13 +271,13 @@ ShaderMaterial::~ShaderMaterial() { ///////////////////////////////// -Mutex SpatialMaterial::material_mutex; -SelfList::List *SpatialMaterial::dirty_materials = nullptr; -Map SpatialMaterial::shader_map; -SpatialMaterial::ShaderNames *SpatialMaterial::shader_names = nullptr; +Mutex Material3D::material_mutex; +SelfList::List *Material3D::dirty_materials = nullptr; +Map Material3D::shader_map; +Material3D::ShaderNames *Material3D::shader_names = nullptr; -void SpatialMaterial::init_shaders() { - dirty_materials = memnew(SelfList::List); +void Material3D::init_shaders() { + dirty_materials = memnew(SelfList::List); shader_names = memnew(ShaderNames); @@ -330,6 +330,7 @@ void SpatialMaterial::init_shaders() { shader_names->alpha_scissor_threshold = "alpha_scissor_threshold"; shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo"; + shader_names->texture_names[TEXTURE_ORM] = "texture_orm"; shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic"; shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness"; shader_names->texture_names[TEXTURE_EMISSION] = "texture_emission"; @@ -347,9 +348,9 @@ void SpatialMaterial::init_shaders() { shader_names->texture_names[TEXTURE_DETAIL_NORMAL] = "texture_detail_normal"; } -HashMap> SpatialMaterial::materials_for_2d; +HashMap> Material3D::materials_for_2d; -void SpatialMaterial::finish_shaders() { +void Material3D::finish_shaders() { materials_for_2d.clear(); memdelete(dirty_materials); @@ -358,7 +359,7 @@ void SpatialMaterial::finish_shaders() { memdelete(shader_names); } -void SpatialMaterial::_update_shader() { +void Material3D::_update_shader() { dirty_materials->remove(&element); MaterialKey mk = _compute_key(); @@ -386,7 +387,9 @@ void SpatialMaterial::_update_shader() { //must create a shader! // Add a comment to describe the shader origin (useful when converting to ShaderMaterial). - String code = "// NOTE: Shader automatically converted from " VERSION_NAME " " VERSION_FULL_CONFIG "'s SpatialMaterial.\n\n"; + String code = vformat( + "// NOTE: Shader automatically converted from " VERSION_NAME " " VERSION_FULL_CONFIG "'s %s.\n\n", + orm ? "ORMSpatialMaterial3D" : "SpatialMaterial"); //TODO: check names! code += "shader_type spatial;\nrender_mode "; switch (blend_mode) { @@ -518,15 +521,31 @@ void SpatialMaterial::_update_shader() { code += "uniform float roughness : hint_range(0,1);\n"; code += "uniform float point_size : hint_range(0,128);\n"; - if (textures[TEXTURE_METALLIC] != nullptr) { - code += "uniform sampler2D texture_metallic : hint_white;\n"; - code += "uniform vec4 metallic_texture_channel;\n"; + if (orm) { + if (textures[TEXTURE_ORM] != nullptr) { + code += "uniform sampler2D texture_orm : hint_white;\n"; + if (features[FEATURE_AMBIENT_OCCLUSION]) { + code += "uniform float ao_light_affect;\n"; + } + } + } else { + if (textures[TEXTURE_METALLIC] != nullptr) { + code += "uniform sampler2D texture_metallic : hint_white;\n"; + code += "uniform vec4 metallic_texture_channel;\n"; + } + + if (textures[TEXTURE_ROUGHNESS] != nullptr) { + code += "uniform sampler2D texture_roughness : hint_white;\n"; + code += "uniform vec4 roughness_texture_channel;\n"; + } + + if (features[FEATURE_AMBIENT_OCCLUSION]) { + code += "uniform sampler2D texture_ambient_occlusion : hint_white;\n"; + code += "uniform vec4 ao_texture_channel;\n"; + code += "uniform float ao_light_affect;\n"; + } } - if (textures[TEXTURE_ROUGHNESS] != nullptr) { - code += "uniform sampler2D texture_roughness : hint_white;\n"; - code += "uniform vec4 roughness_texture_channel;\n"; - } if (billboard_mode == BILLBOARD_PARTICLES) { code += "uniform int particles_anim_h_frames;\n"; code += "uniform int particles_anim_v_frames;\n"; @@ -563,11 +582,6 @@ void SpatialMaterial::_update_shader() { code += "uniform float anisotropy_ratio : hint_range(0,256);\n"; code += "uniform sampler2D texture_flowmap : hint_aniso;\n"; } - if (features[FEATURE_AMBIENT_OCCLUSION]) { - code += "uniform sampler2D texture_ambient_occlusion : hint_white;\n"; - code += "uniform vec4 ao_texture_channel;\n"; - code += "uniform float ao_light_affect;\n"; - } if (features[FEATURE_DETAIL]) { code += "uniform sampler2D texture_detail_albedo : hint_albedo;\n"; @@ -825,28 +839,76 @@ void SpatialMaterial::_update_shader() { } code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n"; - if (textures[TEXTURE_METALLIC] != nullptr) { - if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tfloat metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_triplanar_pos),metallic_texture_channel);\n"; + if (orm) { + if (textures[TEXTURE_ORM] != nullptr) { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tvec4 orm_tex = triplanar_texture(texture_orm,uv1_power_normal,uv1_triplanar_pos);\n"; + } else { + code += "\tvec4 orm_tex = texture(texture_orm,base_uv);\n"; + } + code += "\tMETALLIC = orm_tex.b;\n"; + code += "\tROUGHNESS = orm_tex.g;\n"; } else { - code += "\tfloat metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n"; + code += "\tMETALLIC = metallic;\n"; + code += "\tROUGHNESS = roughness;\n"; } - code += "\tMETALLIC = metallic_tex * metallic;\n"; - } else { - code += "\tMETALLIC = metallic;\n"; - } - if (textures[TEXTURE_ROUGHNESS] != nullptr) { - if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tfloat roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_triplanar_pos),roughness_texture_channel);\n"; + // AO + if (features[FEATURE_AMBIENT_OCCLUSION]) { + if (flags[FLAG_AO_ON_UV2]) { + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "\tAO = triplanar_texture(texture_orm,uv2_power_normal,uv2_triplanar_pos).r;\n"; + } else { + code += "\tAO = texture(texture_orm,base_uv2).r;\n"; + } + } else { + code += "\tAO = orm_tex.r;\n"; + } + + code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; + } + + } else { + if (textures[TEXTURE_METALLIC] != nullptr) { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_triplanar_pos),metallic_texture_channel);\n"; + } else { + code += "\tfloat metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n"; + } + code += "\tMETALLIC = metallic_tex * metallic;\n"; } else { - code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n"; + code += "\tMETALLIC = metallic;\n"; } - code += "\tROUGHNESS = roughness_tex * roughness;\n"; - } else { - code += "\tROUGHNESS = roughness;\n"; - } + if (textures[TEXTURE_ROUGHNESS] != nullptr) { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_triplanar_pos),roughness_texture_channel);\n"; + } else { + code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n"; + } + code += "\tROUGHNESS = roughness_tex * roughness;\n"; + } else { + code += "\tROUGHNESS = roughness;\n"; + } + + if (features[FEATURE_AMBIENT_OCCLUSION]) { + if (flags[FLAG_AO_ON_UV2]) { + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; + } else { + code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; + } + } else { + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; + } else { + code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; + } + } + + code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; + } + } code += "\tSPECULAR = specular;\n"; if (features[FEATURE_NORMAL_MAPPING]) { @@ -968,24 +1030,6 @@ void SpatialMaterial::_update_shader() { code += "\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n"; } - if (features[FEATURE_AMBIENT_OCCLUSION]) { - if (flags[FLAG_AO_ON_UV2]) { - if (flags[FLAG_UV2_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; - } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; - } - } else { - if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; - } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; - } - } - - code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; - } - if (features[FEATURE_SUBSURACE_SCATTERING]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "\tfloat sss_tex = triplanar_texture(texture_subsurface_scattering,uv1_power_normal,uv1_triplanar_pos).r;\n"; @@ -1072,7 +1116,7 @@ void SpatialMaterial::_update_shader() { VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); } -void SpatialMaterial::flush_changes() { +void Material3D::flush_changes() { material_mutex.lock(); while (dirty_materials->first()) { @@ -1082,7 +1126,7 @@ void SpatialMaterial::flush_changes() { material_mutex.unlock(); } -void SpatialMaterial::_queue_shader_change() { +void Material3D::_queue_shader_change() { material_mutex.lock(); if (is_initialized && !element.in_list()) { @@ -1092,7 +1136,7 @@ void SpatialMaterial::_queue_shader_change() { material_mutex.unlock(); } -bool SpatialMaterial::_is_shader_dirty() const { +bool Material3D::_is_shader_dirty() const { bool dirty = false; material_mutex.lock(); @@ -1103,154 +1147,154 @@ bool SpatialMaterial::_is_shader_dirty() const { return dirty; } -void SpatialMaterial::set_albedo(const Color &p_albedo) { +void Material3D::set_albedo(const Color &p_albedo) { albedo = p_albedo; VS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo); } -Color SpatialMaterial::get_albedo() const { +Color Material3D::get_albedo() const { return albedo; } -void SpatialMaterial::set_specular(float p_specular) { +void Material3D::set_specular(float p_specular) { specular = p_specular; VS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular); } -float SpatialMaterial::get_specular() const { +float Material3D::get_specular() const { return specular; } -void SpatialMaterial::set_roughness(float p_roughness) { +void Material3D::set_roughness(float p_roughness) { roughness = p_roughness; VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness); } -float SpatialMaterial::get_roughness() const { +float Material3D::get_roughness() const { return roughness; } -void SpatialMaterial::set_metallic(float p_metallic) { +void Material3D::set_metallic(float p_metallic) { metallic = p_metallic; VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic); } -float SpatialMaterial::get_metallic() const { +float Material3D::get_metallic() const { return metallic; } -void SpatialMaterial::set_emission(const Color &p_emission) { +void Material3D::set_emission(const Color &p_emission) { emission = p_emission; VS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission); } -Color SpatialMaterial::get_emission() const { +Color Material3D::get_emission() const { return emission; } -void SpatialMaterial::set_emission_energy(float p_emission_energy) { +void Material3D::set_emission_energy(float p_emission_energy) { emission_energy = p_emission_energy; VS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy); } -float SpatialMaterial::get_emission_energy() const { +float Material3D::get_emission_energy() const { return emission_energy; } -void SpatialMaterial::set_normal_scale(float p_normal_scale) { +void Material3D::set_normal_scale(float p_normal_scale) { normal_scale = p_normal_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale); } -float SpatialMaterial::get_normal_scale() const { +float Material3D::get_normal_scale() const { return normal_scale; } -void SpatialMaterial::set_rim(float p_rim) { +void Material3D::set_rim(float p_rim) { rim = p_rim; VS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim); } -float SpatialMaterial::get_rim() const { +float Material3D::get_rim() const { return rim; } -void SpatialMaterial::set_rim_tint(float p_rim_tint) { +void Material3D::set_rim_tint(float p_rim_tint) { rim_tint = p_rim_tint; VS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint); } -float SpatialMaterial::get_rim_tint() const { +float Material3D::get_rim_tint() const { return rim_tint; } -void SpatialMaterial::set_ao_light_affect(float p_ao_light_affect) { +void Material3D::set_ao_light_affect(float p_ao_light_affect) { ao_light_affect = p_ao_light_affect; VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect); } -float SpatialMaterial::get_ao_light_affect() const { +float Material3D::get_ao_light_affect() const { return ao_light_affect; } -void SpatialMaterial::set_clearcoat(float p_clearcoat) { +void Material3D::set_clearcoat(float p_clearcoat) { clearcoat = p_clearcoat; VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat); } -float SpatialMaterial::get_clearcoat() const { +float Material3D::get_clearcoat() const { return clearcoat; } -void SpatialMaterial::set_clearcoat_gloss(float p_clearcoat_gloss) { +void Material3D::set_clearcoat_gloss(float p_clearcoat_gloss) { clearcoat_gloss = p_clearcoat_gloss; VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss); } -float SpatialMaterial::get_clearcoat_gloss() const { +float Material3D::get_clearcoat_gloss() const { return clearcoat_gloss; } -void SpatialMaterial::set_anisotropy(float p_anisotropy) { +void Material3D::set_anisotropy(float p_anisotropy) { anisotropy = p_anisotropy; VS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy); } -float SpatialMaterial::get_anisotropy() const { +float Material3D::get_anisotropy() const { return anisotropy; } -void SpatialMaterial::set_depth_scale(float p_depth_scale) { +void Material3D::set_depth_scale(float p_depth_scale) { depth_scale = p_depth_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_scale, p_depth_scale); } -float SpatialMaterial::get_depth_scale() const { +float Material3D::get_depth_scale() const { return depth_scale; } -void SpatialMaterial::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) { +void Material3D::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) { subsurface_scattering_strength = p_subsurface_scattering_strength; VS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength); } -float SpatialMaterial::get_subsurface_scattering_strength() const { +float Material3D::get_subsurface_scattering_strength() const { return subsurface_scattering_strength; } -void SpatialMaterial::set_transmission(const Color &p_transmission) { +void Material3D::set_transmission(const Color &p_transmission) { transmission = p_transmission; VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); } -Color SpatialMaterial::get_transmission() const { +Color Material3D::get_transmission() const { return transmission; } -void SpatialMaterial::set_refraction(float p_refraction) { +void Material3D::set_refraction(float p_refraction) { refraction = p_refraction; VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction); } -float SpatialMaterial::get_refraction() const { +float Material3D::get_refraction() const { return refraction; } -void SpatialMaterial::set_detail_uv(DetailUV p_detail_uv) { +void Material3D::set_detail_uv(DetailUV p_detail_uv) { if (detail_uv == p_detail_uv) { return; } @@ -1258,11 +1302,11 @@ void SpatialMaterial::set_detail_uv(DetailUV p_detail_uv) { detail_uv = p_detail_uv; _queue_shader_change(); } -SpatialMaterial::DetailUV SpatialMaterial::get_detail_uv() const { +Material3D::DetailUV Material3D::get_detail_uv() const { return detail_uv; } -void SpatialMaterial::set_blend_mode(BlendMode p_mode) { +void Material3D::set_blend_mode(BlendMode p_mode) { if (blend_mode == p_mode) { return; } @@ -1270,19 +1314,19 @@ void SpatialMaterial::set_blend_mode(BlendMode p_mode) { blend_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::BlendMode SpatialMaterial::get_blend_mode() const { +Material3D::BlendMode Material3D::get_blend_mode() const { return blend_mode; } -void SpatialMaterial::set_detail_blend_mode(BlendMode p_mode) { +void Material3D::set_detail_blend_mode(BlendMode p_mode) { detail_blend_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::BlendMode SpatialMaterial::get_detail_blend_mode() const { +Material3D::BlendMode Material3D::get_detail_blend_mode() const { return detail_blend_mode; } -void SpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) { +void Material3D::set_depth_draw_mode(DepthDrawMode p_mode) { if (depth_draw_mode == p_mode) { return; } @@ -1290,11 +1334,11 @@ void SpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) { depth_draw_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::DepthDrawMode SpatialMaterial::get_depth_draw_mode() const { +Material3D::DepthDrawMode Material3D::get_depth_draw_mode() const { return depth_draw_mode; } -void SpatialMaterial::set_cull_mode(CullMode p_mode) { +void Material3D::set_cull_mode(CullMode p_mode) { if (cull_mode == p_mode) { return; } @@ -1302,11 +1346,11 @@ void SpatialMaterial::set_cull_mode(CullMode p_mode) { cull_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::CullMode SpatialMaterial::get_cull_mode() const { +Material3D::CullMode Material3D::get_cull_mode() const { return cull_mode; } -void SpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) { +void Material3D::set_diffuse_mode(DiffuseMode p_mode) { if (diffuse_mode == p_mode) { return; } @@ -1314,11 +1358,11 @@ void SpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) { diffuse_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::DiffuseMode SpatialMaterial::get_diffuse_mode() const { +Material3D::DiffuseMode Material3D::get_diffuse_mode() const { return diffuse_mode; } -void SpatialMaterial::set_specular_mode(SpecularMode p_mode) { +void Material3D::set_specular_mode(SpecularMode p_mode) { if (specular_mode == p_mode) { return; } @@ -1326,11 +1370,11 @@ void SpatialMaterial::set_specular_mode(SpecularMode p_mode) { specular_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::SpecularMode SpatialMaterial::get_specular_mode() const { +Material3D::SpecularMode Material3D::get_specular_mode() const { return specular_mode; } -void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { +void Material3D::set_flag(Flags p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); if (flags[p_flag] == p_enabled) { @@ -1351,12 +1395,12 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { _queue_shader_change(); } -bool SpatialMaterial::get_flag(Flags p_flag) const { +bool Material3D::get_flag(Flags p_flag) const { ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags[p_flag]; } -void SpatialMaterial::set_feature(Feature p_feature, bool p_enabled) { +void Material3D::set_feature(Feature p_feature, bool p_enabled) { ERR_FAIL_INDEX(p_feature, FEATURE_MAX); if (features[p_feature] == p_enabled) { return; @@ -1367,12 +1411,12 @@ void SpatialMaterial::set_feature(Feature p_feature, bool p_enabled) { _queue_shader_change(); } -bool SpatialMaterial::get_feature(Feature p_feature) const { +bool Material3D::get_feature(Feature p_feature) const { ERR_FAIL_INDEX_V(p_feature, FEATURE_MAX, false); return features[p_feature]; } -void SpatialMaterial::set_texture(TextureParam p_param, const Ref &p_texture) { +void Material3D::set_texture(TextureParam p_param, const Ref &p_texture) { ERR_FAIL_INDEX(p_param, TEXTURE_MAX); textures[p_param] = p_texture; RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID(); @@ -1381,13 +1425,13 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref &p_te _queue_shader_change(); } -Ref SpatialMaterial::get_texture(TextureParam p_param) const { +Ref Material3D::get_texture(TextureParam p_param) const { ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref()); return textures[p_param]; } -Ref SpatialMaterial::get_texture_by_name(StringName p_name) const { - for (int i = 0; i < (int)SpatialMaterial::TEXTURE_MAX; i++) { +Ref Material3D::get_texture_by_name(StringName p_name) const { + for (int i = 0; i < (int)Material3D::TEXTURE_MAX; i++) { TextureParam param = TextureParam(i); if (p_name == shader_names->texture_names[param]) { return textures[param]; @@ -1396,19 +1440,19 @@ Ref SpatialMaterial::get_texture_by_name(StringName p_name) const { return Ref(); } -void SpatialMaterial::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { +void Material3D::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) { property.usage = 0; } } -void SpatialMaterial::_validate_high_end(const String &text, PropertyInfo &property) const { +void Material3D::_validate_high_end(const String &text, PropertyInfo &property) const { if (property.name.begins_with(text)) { property.usage |= PROPERTY_USAGE_HIGH_END_GFX; } } -void SpatialMaterial::_validate_property(PropertyInfo &property) const { +void Material3D::_validate_property(PropertyInfo &property) const { _validate_feature("normal", FEATURE_NORMAL_MAPPING, property); _validate_feature("emission", FEATURE_EMISSION, property); _validate_feature("rim", FEATURE_RIM, property); @@ -1497,190 +1541,203 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { property.usage = 0; } } + if (orm) { + if (property.name == "shading_mode") { + // Vertex not supported in ORM mode, since no individual roughness. + property.hint_string = "Unshaded,Per-Pixel"; + } + if (property.name.begins_with("roughness") || property.name.begins_with("metallic") || property.name.begins_with("ao_texture")) { + property.usage = 0; + } + } else { + if (property.name == "orm_texture") { + property.usage = 0; + } + } } -void SpatialMaterial::set_line_width(float p_line_width) { +void Material3D::set_line_width(float p_line_width) { line_width = p_line_width; VS::get_singleton()->material_set_line_width(_get_material(), line_width); } -float SpatialMaterial::get_line_width() const { +float Material3D::get_line_width() const { return line_width; } -void SpatialMaterial::set_point_size(float p_point_size) { +void Material3D::set_point_size(float p_point_size) { point_size = p_point_size; VS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size); } -float SpatialMaterial::get_point_size() const { +float Material3D::get_point_size() const { return point_size; } -void SpatialMaterial::set_uv1_scale(const Vector3 &p_scale) { +void Material3D::set_uv1_scale(const Vector3 &p_scale) { uv1_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale); } -Vector3 SpatialMaterial::get_uv1_scale() const { +Vector3 Material3D::get_uv1_scale() const { return uv1_scale; } -void SpatialMaterial::set_uv1_offset(const Vector3 &p_offset) { +void Material3D::set_uv1_offset(const Vector3 &p_offset) { uv1_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset); } -Vector3 SpatialMaterial::get_uv1_offset() const { +Vector3 Material3D::get_uv1_offset() const { return uv1_offset; } -void SpatialMaterial::set_uv1_triplanar_blend_sharpness(float p_sharpness) { +void Material3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) { // Negative values or values higher than 150 can result in NaNs, leading to broken rendering. uv1_triplanar_sharpness = CLAMP(p_sharpness, 0.0, 150.0); VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, uv1_triplanar_sharpness); } -float SpatialMaterial::get_uv1_triplanar_blend_sharpness() const { +float Material3D::get_uv1_triplanar_blend_sharpness() const { return uv1_triplanar_sharpness; } -void SpatialMaterial::set_uv2_scale(const Vector3 &p_scale) { +void Material3D::set_uv2_scale(const Vector3 &p_scale) { uv2_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale); } -Vector3 SpatialMaterial::get_uv2_scale() const { +Vector3 Material3D::get_uv2_scale() const { return uv2_scale; } -void SpatialMaterial::set_uv2_offset(const Vector3 &p_offset) { +void Material3D::set_uv2_offset(const Vector3 &p_offset) { uv2_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset); } -Vector3 SpatialMaterial::get_uv2_offset() const { +Vector3 Material3D::get_uv2_offset() const { return uv2_offset; } -void SpatialMaterial::set_uv2_triplanar_blend_sharpness(float p_sharpness) { +void Material3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) { // Negative values or values higher than 150 can result in NaNs, leading to broken rendering. uv2_triplanar_sharpness = CLAMP(p_sharpness, 0.0, 150.0); VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, uv2_triplanar_sharpness); } -float SpatialMaterial::get_uv2_triplanar_blend_sharpness() const { +float Material3D::get_uv2_triplanar_blend_sharpness() const { return uv2_triplanar_sharpness; } -void SpatialMaterial::set_billboard_mode(BillboardMode p_mode) { +void Material3D::set_billboard_mode(BillboardMode p_mode) { billboard_mode = p_mode; _queue_shader_change(); _change_notify(); } -SpatialMaterial::BillboardMode SpatialMaterial::get_billboard_mode() const { +Material3D::BillboardMode Material3D::get_billboard_mode() const { return billboard_mode; } -void SpatialMaterial::set_particles_anim_h_frames(int p_frames) { +void Material3D::set_particles_anim_h_frames(int p_frames) { particles_anim_h_frames = p_frames; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); } -int SpatialMaterial::get_particles_anim_h_frames() const { +int Material3D::get_particles_anim_h_frames() const { return particles_anim_h_frames; } -void SpatialMaterial::set_particles_anim_v_frames(int p_frames) { +void Material3D::set_particles_anim_v_frames(int p_frames) { particles_anim_v_frames = p_frames; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); } -int SpatialMaterial::get_particles_anim_v_frames() const { +int Material3D::get_particles_anim_v_frames() const { return particles_anim_v_frames; } -void SpatialMaterial::set_particles_anim_loop(bool p_loop) { +void Material3D::set_particles_anim_loop(bool p_loop) { particles_anim_loop = p_loop; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); } -bool SpatialMaterial::get_particles_anim_loop() const { +bool Material3D::get_particles_anim_loop() const { return particles_anim_loop; } -void SpatialMaterial::set_depth_deep_parallax(bool p_enable) { +void Material3D::set_depth_deep_parallax(bool p_enable) { deep_parallax = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_depth_deep_parallax_enabled() const { +bool Material3D::is_depth_deep_parallax_enabled() const { return deep_parallax; } -void SpatialMaterial::set_depth_deep_parallax_min_layers(int p_layer) { +void Material3D::set_depth_deep_parallax_min_layers(int p_layer) { deep_parallax_min_layers = p_layer; VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_min_layers, p_layer); } -int SpatialMaterial::get_depth_deep_parallax_min_layers() const { +int Material3D::get_depth_deep_parallax_min_layers() const { return deep_parallax_min_layers; } -void SpatialMaterial::set_depth_deep_parallax_max_layers(int p_layer) { +void Material3D::set_depth_deep_parallax_max_layers(int p_layer) { deep_parallax_max_layers = p_layer; VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_max_layers, p_layer); } -int SpatialMaterial::get_depth_deep_parallax_max_layers() const { +int Material3D::get_depth_deep_parallax_max_layers() const { return deep_parallax_max_layers; } -void SpatialMaterial::set_depth_deep_parallax_flip_tangent(bool p_flip) { +void Material3D::set_depth_deep_parallax_flip_tangent(bool p_flip) { depth_parallax_flip_tangent = p_flip; VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_flip, Vector2(depth_parallax_flip_tangent ? -1 : 1, depth_parallax_flip_binormal ? -1 : 1)); } -bool SpatialMaterial::get_depth_deep_parallax_flip_tangent() const { +bool Material3D::get_depth_deep_parallax_flip_tangent() const { return depth_parallax_flip_tangent; } -void SpatialMaterial::set_depth_deep_parallax_flip_binormal(bool p_flip) { +void Material3D::set_depth_deep_parallax_flip_binormal(bool p_flip) { depth_parallax_flip_binormal = p_flip; VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_flip, Vector2(depth_parallax_flip_tangent ? -1 : 1, depth_parallax_flip_binormal ? -1 : 1)); } -bool SpatialMaterial::get_depth_deep_parallax_flip_binormal() const { +bool Material3D::get_depth_deep_parallax_flip_binormal() const { return depth_parallax_flip_binormal; } -void SpatialMaterial::set_grow_enabled(bool p_enable) { +void Material3D::set_grow_enabled(bool p_enable) { grow_enabled = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_grow_enabled() const { +bool Material3D::is_grow_enabled() const { return grow_enabled; } -void SpatialMaterial::set_alpha_scissor_threshold(float p_threshold) { +void Material3D::set_alpha_scissor_threshold(float p_threshold) { alpha_scissor_threshold = p_threshold; VS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold); } -float SpatialMaterial::get_alpha_scissor_threshold() const { +float Material3D::get_alpha_scissor_threshold() const { return alpha_scissor_threshold; } -void SpatialMaterial::set_grow(float p_grow) { +void Material3D::set_grow(float p_grow) { grow = p_grow; VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow); } -float SpatialMaterial::get_grow() const { +float Material3D::get_grow() const { return grow; } -static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) { +static Plane _get_texture_mask(Material3D::TextureChannel p_channel) { static const Plane masks[5] = { Plane(1, 0, 0, 0), Plane(0, 1, 0, 0), @@ -1692,47 +1749,47 @@ static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) { return masks[p_channel]; } -void SpatialMaterial::set_metallic_texture_channel(TextureChannel p_channel) { +void Material3D::set_metallic_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); metallic_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_metallic_texture_channel() const { +Material3D::TextureChannel Material3D::get_metallic_texture_channel() const { return metallic_texture_channel; } -void SpatialMaterial::set_roughness_texture_channel(TextureChannel p_channel) { +void Material3D::set_roughness_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); roughness_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_roughness_texture_channel() const { +Material3D::TextureChannel Material3D::get_roughness_texture_channel() const { return roughness_texture_channel; } -void SpatialMaterial::set_ao_texture_channel(TextureChannel p_channel) { +void Material3D::set_ao_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); ao_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_ao_texture_channel() const { +Material3D::TextureChannel Material3D::get_ao_texture_channel() const { return ao_texture_channel; } -void SpatialMaterial::set_refraction_texture_channel(TextureChannel p_channel) { +void Material3D::set_refraction_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); refraction_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_refraction_texture_channel() const { +Material3D::TextureChannel Material3D::get_refraction_texture_channel() const { return refraction_texture_channel; } -RID SpatialMaterial::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, bool p_billboard_y, bool p_no_depth_test, bool p_fixed_size, bool p_sdf) { +RID Material3D::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, bool p_billboard_y, bool p_no_depth_test, bool p_fixed_size, bool p_sdf) { uint64_t hash = 0; if (p_shaded) { hash |= 1 << 0; @@ -1769,7 +1826,7 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, return materials_for_2d[hash]->get_rid(); } - Ref material; + Ref material; material.instance(); material->set_flag(FLAG_UNSHADED, !p_shaded); @@ -1794,57 +1851,57 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, return materials_for_2d[hash]->get_rid(); } -void SpatialMaterial::set_on_top_of_alpha() { +void Material3D::set_on_top_of_alpha() { set_feature(FEATURE_TRANSPARENT, true); set_render_priority(RENDER_PRIORITY_MAX); set_flag(FLAG_DISABLE_DEPTH_TEST, true); } -void SpatialMaterial::set_proximity_fade(bool p_enable) { +void Material3D::set_proximity_fade(bool p_enable) { proximity_fade_enabled = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_proximity_fade_enabled() const { +bool Material3D::is_proximity_fade_enabled() const { return proximity_fade_enabled; } -void SpatialMaterial::set_proximity_fade_distance(float p_distance) { +void Material3D::set_proximity_fade_distance(float p_distance) { proximity_fade_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance); } -float SpatialMaterial::get_proximity_fade_distance() const { +float Material3D::get_proximity_fade_distance() const { return proximity_fade_distance; } -void SpatialMaterial::set_distance_fade(DistanceFadeMode p_mode) { +void Material3D::set_distance_fade(DistanceFadeMode p_mode) { distance_fade = p_mode; _queue_shader_change(); _change_notify(); } -SpatialMaterial::DistanceFadeMode SpatialMaterial::get_distance_fade() const { +Material3D::DistanceFadeMode Material3D::get_distance_fade() const { return distance_fade; } -void SpatialMaterial::set_distance_fade_max_distance(float p_distance) { +void Material3D::set_distance_fade_max_distance(float p_distance) { distance_fade_max_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance); } -float SpatialMaterial::get_distance_fade_max_distance() const { +float Material3D::get_distance_fade_max_distance() const { return distance_fade_max_distance; } -void SpatialMaterial::set_distance_fade_min_distance(float p_distance) { +void Material3D::set_distance_fade_min_distance(float p_distance) { distance_fade_min_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance); } -float SpatialMaterial::get_distance_fade_min_distance() const { +float Material3D::get_distance_fade_min_distance() const { return distance_fade_min_distance; } -void SpatialMaterial::set_emission_operator(EmissionOperator p_op) { +void Material3D::set_emission_operator(EmissionOperator p_op) { if (emission_op == p_op) { return; } @@ -1852,203 +1909,203 @@ void SpatialMaterial::set_emission_operator(EmissionOperator p_op) { _queue_shader_change(); } -SpatialMaterial::EmissionOperator SpatialMaterial::get_emission_operator() const { +Material3D::EmissionOperator Material3D::get_emission_operator() const { return emission_op; } -RID SpatialMaterial::get_shader_rid() const { +RID Material3D::get_shader_rid() const { ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); return shader_map[current_key].shader; } -Shader::Mode SpatialMaterial::get_shader_mode() const { +Shader::Mode Material3D::get_shader_mode() const { return Shader::MODE_SPATIAL; } -void SpatialMaterial::set_async_mode(AsyncMode p_mode) { +void Material3D::set_async_mode(AsyncMode p_mode) { async_mode = p_mode; _queue_shader_change(); _change_notify(); } -SpatialMaterial::AsyncMode SpatialMaterial::get_async_mode() const { +Material3D::AsyncMode Material3D::get_async_mode() const { return async_mode; } -void SpatialMaterial::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); - ClassDB::bind_method(D_METHOD("get_albedo"), &SpatialMaterial::get_albedo); +void Material3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &Material3D::set_albedo); + ClassDB::bind_method(D_METHOD("get_albedo"), &Material3D::get_albedo); - ClassDB::bind_method(D_METHOD("set_specular", "specular"), &SpatialMaterial::set_specular); - ClassDB::bind_method(D_METHOD("get_specular"), &SpatialMaterial::get_specular); + ClassDB::bind_method(D_METHOD("set_specular", "specular"), &Material3D::set_specular); + ClassDB::bind_method(D_METHOD("get_specular"), &Material3D::get_specular); - ClassDB::bind_method(D_METHOD("set_metallic", "metallic"), &SpatialMaterial::set_metallic); - ClassDB::bind_method(D_METHOD("get_metallic"), &SpatialMaterial::get_metallic); + ClassDB::bind_method(D_METHOD("set_metallic", "metallic"), &Material3D::set_metallic); + ClassDB::bind_method(D_METHOD("get_metallic"), &Material3D::get_metallic); - ClassDB::bind_method(D_METHOD("set_roughness", "roughness"), &SpatialMaterial::set_roughness); - ClassDB::bind_method(D_METHOD("get_roughness"), &SpatialMaterial::get_roughness); + ClassDB::bind_method(D_METHOD("set_roughness", "roughness"), &Material3D::set_roughness); + ClassDB::bind_method(D_METHOD("get_roughness"), &Material3D::get_roughness); - ClassDB::bind_method(D_METHOD("set_emission", "emission"), &SpatialMaterial::set_emission); - ClassDB::bind_method(D_METHOD("get_emission"), &SpatialMaterial::get_emission); + ClassDB::bind_method(D_METHOD("set_emission", "emission"), &Material3D::set_emission); + ClassDB::bind_method(D_METHOD("get_emission"), &Material3D::get_emission); - ClassDB::bind_method(D_METHOD("set_emission_energy", "emission_energy"), &SpatialMaterial::set_emission_energy); - ClassDB::bind_method(D_METHOD("get_emission_energy"), &SpatialMaterial::get_emission_energy); + ClassDB::bind_method(D_METHOD("set_emission_energy", "emission_energy"), &Material3D::set_emission_energy); + ClassDB::bind_method(D_METHOD("get_emission_energy"), &Material3D::get_emission_energy); - ClassDB::bind_method(D_METHOD("set_normal_scale", "normal_scale"), &SpatialMaterial::set_normal_scale); - ClassDB::bind_method(D_METHOD("get_normal_scale"), &SpatialMaterial::get_normal_scale); + ClassDB::bind_method(D_METHOD("set_normal_scale", "normal_scale"), &Material3D::set_normal_scale); + ClassDB::bind_method(D_METHOD("get_normal_scale"), &Material3D::get_normal_scale); - ClassDB::bind_method(D_METHOD("set_rim", "rim"), &SpatialMaterial::set_rim); - ClassDB::bind_method(D_METHOD("get_rim"), &SpatialMaterial::get_rim); + ClassDB::bind_method(D_METHOD("set_rim", "rim"), &Material3D::set_rim); + ClassDB::bind_method(D_METHOD("get_rim"), &Material3D::get_rim); - ClassDB::bind_method(D_METHOD("set_rim_tint", "rim_tint"), &SpatialMaterial::set_rim_tint); - ClassDB::bind_method(D_METHOD("get_rim_tint"), &SpatialMaterial::get_rim_tint); + ClassDB::bind_method(D_METHOD("set_rim_tint", "rim_tint"), &Material3D::set_rim_tint); + ClassDB::bind_method(D_METHOD("get_rim_tint"), &Material3D::get_rim_tint); - ClassDB::bind_method(D_METHOD("set_clearcoat", "clearcoat"), &SpatialMaterial::set_clearcoat); - ClassDB::bind_method(D_METHOD("get_clearcoat"), &SpatialMaterial::get_clearcoat); + ClassDB::bind_method(D_METHOD("set_clearcoat", "clearcoat"), &Material3D::set_clearcoat); + ClassDB::bind_method(D_METHOD("get_clearcoat"), &Material3D::get_clearcoat); - ClassDB::bind_method(D_METHOD("set_clearcoat_gloss", "clearcoat_gloss"), &SpatialMaterial::set_clearcoat_gloss); - ClassDB::bind_method(D_METHOD("get_clearcoat_gloss"), &SpatialMaterial::get_clearcoat_gloss); + ClassDB::bind_method(D_METHOD("set_clearcoat_gloss", "clearcoat_gloss"), &Material3D::set_clearcoat_gloss); + ClassDB::bind_method(D_METHOD("get_clearcoat_gloss"), &Material3D::get_clearcoat_gloss); - ClassDB::bind_method(D_METHOD("set_anisotropy", "anisotropy"), &SpatialMaterial::set_anisotropy); - ClassDB::bind_method(D_METHOD("get_anisotropy"), &SpatialMaterial::get_anisotropy); + ClassDB::bind_method(D_METHOD("set_anisotropy", "anisotropy"), &Material3D::set_anisotropy); + ClassDB::bind_method(D_METHOD("get_anisotropy"), &Material3D::get_anisotropy); - ClassDB::bind_method(D_METHOD("set_depth_scale", "depth_scale"), &SpatialMaterial::set_depth_scale); - ClassDB::bind_method(D_METHOD("get_depth_scale"), &SpatialMaterial::get_depth_scale); + ClassDB::bind_method(D_METHOD("set_depth_scale", "depth_scale"), &Material3D::set_depth_scale); + ClassDB::bind_method(D_METHOD("get_depth_scale"), &Material3D::get_depth_scale); - ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &SpatialMaterial::set_subsurface_scattering_strength); - ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &SpatialMaterial::get_subsurface_scattering_strength); + ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &Material3D::set_subsurface_scattering_strength); + ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &Material3D::get_subsurface_scattering_strength); - ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &SpatialMaterial::set_transmission); - ClassDB::bind_method(D_METHOD("get_transmission"), &SpatialMaterial::get_transmission); + ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &Material3D::set_transmission); + ClassDB::bind_method(D_METHOD("get_transmission"), &Material3D::get_transmission); - ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &SpatialMaterial::set_refraction); - ClassDB::bind_method(D_METHOD("get_refraction"), &SpatialMaterial::get_refraction); + ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &Material3D::set_refraction); + ClassDB::bind_method(D_METHOD("get_refraction"), &Material3D::get_refraction); - ClassDB::bind_method(D_METHOD("set_line_width", "line_width"), &SpatialMaterial::set_line_width); - ClassDB::bind_method(D_METHOD("get_line_width"), &SpatialMaterial::get_line_width); + ClassDB::bind_method(D_METHOD("set_line_width", "line_width"), &Material3D::set_line_width); + ClassDB::bind_method(D_METHOD("get_line_width"), &Material3D::get_line_width); - ClassDB::bind_method(D_METHOD("set_point_size", "point_size"), &SpatialMaterial::set_point_size); - ClassDB::bind_method(D_METHOD("get_point_size"), &SpatialMaterial::get_point_size); + ClassDB::bind_method(D_METHOD("set_point_size", "point_size"), &Material3D::set_point_size); + ClassDB::bind_method(D_METHOD("get_point_size"), &Material3D::get_point_size); - ClassDB::bind_method(D_METHOD("set_detail_uv", "detail_uv"), &SpatialMaterial::set_detail_uv); - ClassDB::bind_method(D_METHOD("get_detail_uv"), &SpatialMaterial::get_detail_uv); + ClassDB::bind_method(D_METHOD("set_detail_uv", "detail_uv"), &Material3D::set_detail_uv); + ClassDB::bind_method(D_METHOD("get_detail_uv"), &Material3D::get_detail_uv); - ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &SpatialMaterial::set_blend_mode); - ClassDB::bind_method(D_METHOD("get_blend_mode"), &SpatialMaterial::get_blend_mode); + ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &Material3D::set_blend_mode); + ClassDB::bind_method(D_METHOD("get_blend_mode"), &Material3D::get_blend_mode); - ClassDB::bind_method(D_METHOD("set_depth_draw_mode", "depth_draw_mode"), &SpatialMaterial::set_depth_draw_mode); - ClassDB::bind_method(D_METHOD("get_depth_draw_mode"), &SpatialMaterial::get_depth_draw_mode); + ClassDB::bind_method(D_METHOD("set_depth_draw_mode", "depth_draw_mode"), &Material3D::set_depth_draw_mode); + ClassDB::bind_method(D_METHOD("get_depth_draw_mode"), &Material3D::get_depth_draw_mode); - ClassDB::bind_method(D_METHOD("set_cull_mode", "cull_mode"), &SpatialMaterial::set_cull_mode); - ClassDB::bind_method(D_METHOD("get_cull_mode"), &SpatialMaterial::get_cull_mode); + ClassDB::bind_method(D_METHOD("set_cull_mode", "cull_mode"), &Material3D::set_cull_mode); + ClassDB::bind_method(D_METHOD("get_cull_mode"), &Material3D::get_cull_mode); - ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &SpatialMaterial::set_diffuse_mode); - ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &SpatialMaterial::get_diffuse_mode); + ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &Material3D::set_diffuse_mode); + ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &Material3D::get_diffuse_mode); - ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &SpatialMaterial::set_specular_mode); - ClassDB::bind_method(D_METHOD("get_specular_mode"), &SpatialMaterial::get_specular_mode); + ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &Material3D::set_specular_mode); + ClassDB::bind_method(D_METHOD("get_specular_mode"), &Material3D::get_specular_mode); - ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &SpatialMaterial::set_flag); - ClassDB::bind_method(D_METHOD("get_flag", "flag"), &SpatialMaterial::get_flag); + ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &Material3D::set_flag); + ClassDB::bind_method(D_METHOD("get_flag", "flag"), &Material3D::get_flag); - ClassDB::bind_method(D_METHOD("set_feature", "feature", "enable"), &SpatialMaterial::set_feature); - ClassDB::bind_method(D_METHOD("get_feature", "feature"), &SpatialMaterial::get_feature); + ClassDB::bind_method(D_METHOD("set_feature", "feature", "enable"), &Material3D::set_feature); + ClassDB::bind_method(D_METHOD("get_feature", "feature"), &Material3D::get_feature); - ClassDB::bind_method(D_METHOD("set_texture", "param", "texture"), &SpatialMaterial::set_texture); - ClassDB::bind_method(D_METHOD("get_texture", "param"), &SpatialMaterial::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "param", "texture"), &Material3D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture", "param"), &Material3D::get_texture); - ClassDB::bind_method(D_METHOD("set_detail_blend_mode", "detail_blend_mode"), &SpatialMaterial::set_detail_blend_mode); - ClassDB::bind_method(D_METHOD("get_detail_blend_mode"), &SpatialMaterial::get_detail_blend_mode); + ClassDB::bind_method(D_METHOD("set_detail_blend_mode", "detail_blend_mode"), &Material3D::set_detail_blend_mode); + ClassDB::bind_method(D_METHOD("get_detail_blend_mode"), &Material3D::get_detail_blend_mode); - ClassDB::bind_method(D_METHOD("set_uv1_scale", "scale"), &SpatialMaterial::set_uv1_scale); - ClassDB::bind_method(D_METHOD("get_uv1_scale"), &SpatialMaterial::get_uv1_scale); + ClassDB::bind_method(D_METHOD("set_uv1_scale", "scale"), &Material3D::set_uv1_scale); + ClassDB::bind_method(D_METHOD("get_uv1_scale"), &Material3D::get_uv1_scale); - ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &SpatialMaterial::set_uv1_offset); - ClassDB::bind_method(D_METHOD("get_uv1_offset"), &SpatialMaterial::get_uv1_offset); + ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &Material3D::set_uv1_offset); + ClassDB::bind_method(D_METHOD("get_uv1_offset"), &Material3D::get_uv1_offset); - ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv1_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &SpatialMaterial::get_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &Material3D::set_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &Material3D::get_uv1_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &SpatialMaterial::set_uv2_scale); - ClassDB::bind_method(D_METHOD("get_uv2_scale"), &SpatialMaterial::get_uv2_scale); + ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &Material3D::set_uv2_scale); + ClassDB::bind_method(D_METHOD("get_uv2_scale"), &Material3D::get_uv2_scale); - ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &SpatialMaterial::set_uv2_offset); - ClassDB::bind_method(D_METHOD("get_uv2_offset"), &SpatialMaterial::get_uv2_offset); + ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &Material3D::set_uv2_offset); + ClassDB::bind_method(D_METHOD("get_uv2_offset"), &Material3D::get_uv2_offset); - ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv2_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &SpatialMaterial::get_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &Material3D::set_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &Material3D::get_uv2_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpatialMaterial::set_billboard_mode); - ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpatialMaterial::get_billboard_mode); + ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &Material3D::set_billboard_mode); + ClassDB::bind_method(D_METHOD("get_billboard_mode"), &Material3D::get_billboard_mode); - ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &SpatialMaterial::set_particles_anim_h_frames); - ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &SpatialMaterial::get_particles_anim_h_frames); + ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &Material3D::set_particles_anim_h_frames); + ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &Material3D::get_particles_anim_h_frames); - ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &SpatialMaterial::set_particles_anim_v_frames); - ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &SpatialMaterial::get_particles_anim_v_frames); + ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &Material3D::set_particles_anim_v_frames); + ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &Material3D::get_particles_anim_v_frames); - ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &SpatialMaterial::set_particles_anim_loop); - ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &SpatialMaterial::get_particles_anim_loop); + ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &Material3D::set_particles_anim_loop); + ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &Material3D::get_particles_anim_loop); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax", "enable"), &SpatialMaterial::set_depth_deep_parallax); - ClassDB::bind_method(D_METHOD("is_depth_deep_parallax_enabled"), &SpatialMaterial::is_depth_deep_parallax_enabled); + ClassDB::bind_method(D_METHOD("set_depth_deep_parallax", "enable"), &Material3D::set_depth_deep_parallax); + ClassDB::bind_method(D_METHOD("is_depth_deep_parallax_enabled"), &Material3D::is_depth_deep_parallax_enabled); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_min_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_min_layers); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_min_layers"), &SpatialMaterial::get_depth_deep_parallax_min_layers); + ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_min_layers", "layer"), &Material3D::set_depth_deep_parallax_min_layers); + ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_min_layers"), &Material3D::get_depth_deep_parallax_min_layers); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_max_layers); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &SpatialMaterial::get_depth_deep_parallax_max_layers); + ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &Material3D::set_depth_deep_parallax_max_layers); + ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &Material3D::get_depth_deep_parallax_max_layers); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_tangent", "flip"), &SpatialMaterial::set_depth_deep_parallax_flip_tangent); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_tangent"), &SpatialMaterial::get_depth_deep_parallax_flip_tangent); + ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_tangent", "flip"), &Material3D::set_depth_deep_parallax_flip_tangent); + ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_tangent"), &Material3D::get_depth_deep_parallax_flip_tangent); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_binormal", "flip"), &SpatialMaterial::set_depth_deep_parallax_flip_binormal); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_binormal"), &SpatialMaterial::get_depth_deep_parallax_flip_binormal); + ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_binormal", "flip"), &Material3D::set_depth_deep_parallax_flip_binormal); + ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_binormal"), &Material3D::get_depth_deep_parallax_flip_binormal); - ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow); - ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow); + ClassDB::bind_method(D_METHOD("set_grow", "amount"), &Material3D::set_grow); + ClassDB::bind_method(D_METHOD("get_grow"), &Material3D::get_grow); - ClassDB::bind_method(D_METHOD("set_emission_operator", "operator"), &SpatialMaterial::set_emission_operator); - ClassDB::bind_method(D_METHOD("get_emission_operator"), &SpatialMaterial::get_emission_operator); + ClassDB::bind_method(D_METHOD("set_emission_operator", "operator"), &Material3D::set_emission_operator); + ClassDB::bind_method(D_METHOD("get_emission_operator"), &Material3D::get_emission_operator); - ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &SpatialMaterial::set_ao_light_affect); - ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &SpatialMaterial::get_ao_light_affect); + ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &Material3D::set_ao_light_affect); + ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &Material3D::get_ao_light_affect); - ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &SpatialMaterial::set_alpha_scissor_threshold); - ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &SpatialMaterial::get_alpha_scissor_threshold); + ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &Material3D::set_alpha_scissor_threshold); + ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &Material3D::get_alpha_scissor_threshold); - ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled); - ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled); + ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &Material3D::set_grow_enabled); + ClassDB::bind_method(D_METHOD("is_grow_enabled"), &Material3D::is_grow_enabled); - ClassDB::bind_method(D_METHOD("set_metallic_texture_channel", "channel"), &SpatialMaterial::set_metallic_texture_channel); - ClassDB::bind_method(D_METHOD("get_metallic_texture_channel"), &SpatialMaterial::get_metallic_texture_channel); + ClassDB::bind_method(D_METHOD("set_metallic_texture_channel", "channel"), &Material3D::set_metallic_texture_channel); + ClassDB::bind_method(D_METHOD("get_metallic_texture_channel"), &Material3D::get_metallic_texture_channel); - ClassDB::bind_method(D_METHOD("set_roughness_texture_channel", "channel"), &SpatialMaterial::set_roughness_texture_channel); - ClassDB::bind_method(D_METHOD("get_roughness_texture_channel"), &SpatialMaterial::get_roughness_texture_channel); + ClassDB::bind_method(D_METHOD("set_roughness_texture_channel", "channel"), &Material3D::set_roughness_texture_channel); + ClassDB::bind_method(D_METHOD("get_roughness_texture_channel"), &Material3D::get_roughness_texture_channel); - ClassDB::bind_method(D_METHOD("set_ao_texture_channel", "channel"), &SpatialMaterial::set_ao_texture_channel); - ClassDB::bind_method(D_METHOD("get_ao_texture_channel"), &SpatialMaterial::get_ao_texture_channel); + ClassDB::bind_method(D_METHOD("set_ao_texture_channel", "channel"), &Material3D::set_ao_texture_channel); + ClassDB::bind_method(D_METHOD("get_ao_texture_channel"), &Material3D::get_ao_texture_channel); - ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &SpatialMaterial::set_refraction_texture_channel); - ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &SpatialMaterial::get_refraction_texture_channel); + ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &Material3D::set_refraction_texture_channel); + ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &Material3D::get_refraction_texture_channel); - ClassDB::bind_method(D_METHOD("set_proximity_fade", "enabled"), &SpatialMaterial::set_proximity_fade); - ClassDB::bind_method(D_METHOD("is_proximity_fade_enabled"), &SpatialMaterial::is_proximity_fade_enabled); + ClassDB::bind_method(D_METHOD("set_proximity_fade", "enabled"), &Material3D::set_proximity_fade); + ClassDB::bind_method(D_METHOD("is_proximity_fade_enabled"), &Material3D::is_proximity_fade_enabled); - ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &SpatialMaterial::set_proximity_fade_distance); - ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &SpatialMaterial::get_proximity_fade_distance); + ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &Material3D::set_proximity_fade_distance); + ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &Material3D::get_proximity_fade_distance); - ClassDB::bind_method(D_METHOD("set_distance_fade", "mode"), &SpatialMaterial::set_distance_fade); - ClassDB::bind_method(D_METHOD("get_distance_fade"), &SpatialMaterial::get_distance_fade); + ClassDB::bind_method(D_METHOD("set_distance_fade", "mode"), &Material3D::set_distance_fade); + ClassDB::bind_method(D_METHOD("get_distance_fade"), &Material3D::get_distance_fade); - ClassDB::bind_method(D_METHOD("set_distance_fade_max_distance", "distance"), &SpatialMaterial::set_distance_fade_max_distance); - ClassDB::bind_method(D_METHOD("get_distance_fade_max_distance"), &SpatialMaterial::get_distance_fade_max_distance); + ClassDB::bind_method(D_METHOD("set_distance_fade_max_distance", "distance"), &Material3D::set_distance_fade_max_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_max_distance"), &Material3D::get_distance_fade_max_distance); - ClassDB::bind_method(D_METHOD("set_distance_fade_min_distance", "distance"), &SpatialMaterial::set_distance_fade_min_distance); - ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &SpatialMaterial::get_distance_fade_min_distance); + ClassDB::bind_method(D_METHOD("set_distance_fade_min_distance", "distance"), &Material3D::set_distance_fade_min_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &Material3D::get_distance_fade_min_distance); - ClassDB::bind_method(D_METHOD("set_async_mode", "mode"), &SpatialMaterial::set_async_mode); - ClassDB::bind_method(D_METHOD("get_async_mode"), &SpatialMaterial::get_async_mode); + ClassDB::bind_method(D_METHOD("set_async_mode", "mode"), &Material3D::set_async_mode); + ClassDB::bind_method(D_METHOD("get_async_mode"), &Material3D::get_async_mode); ADD_GROUP("Flags", "flags_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT); @@ -2091,6 +2148,9 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "albedo_color"), "set_albedo", "get_albedo"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ALBEDO); + ADD_GROUP("ORM", "orm_"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orm_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ORM); + ADD_GROUP("Metallic", "metallic_"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_specular", "get_specular"); @@ -2301,8 +2361,10 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(ASYNC_MODE_HIDDEN); } -SpatialMaterial::SpatialMaterial() : +Material3D::Material3D(bool p_orm) : element(this) { + orm = p_orm; + // Initialize to the same values as the shader set_albedo(Color(1.0, 1.0, 1.0, 1.0)); set_specular(0.5); @@ -2384,7 +2446,7 @@ SpatialMaterial::SpatialMaterial() : _queue_shader_change(); } -SpatialMaterial::~SpatialMaterial() { +Material3D::~Material3D() { material_mutex.lock(); if (shader_map.has(current_key)) { diff --git a/scene/resources/material.h b/scene/resources/material.h index 51353cf6fbf..01204eb1f45 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -104,8 +104,8 @@ public: ~ShaderMaterial(); }; -class SpatialMaterial : public Material { - GDCLASS(SpatialMaterial, Material); +class Material3D : public Material { + GDCLASS(Material3D, Material); public: enum TextureParam { @@ -125,6 +125,7 @@ public: TEXTURE_DETAIL_MASK, TEXTURE_DETAIL_ALBEDO, TEXTURE_DETAIL_NORMAL, + TEXTURE_ORM, TEXTURE_MAX }; @@ -364,15 +365,16 @@ private: }; static Mutex material_mutex; - static SelfList::List *dirty_materials; + static SelfList::List *dirty_materials; static ShaderNames *shader_names; - SelfList element; + SelfList element; void _update_shader(); _FORCE_INLINE_ void _queue_shader_change(); _FORCE_INLINE_ bool _is_shader_dirty() const; + bool orm; bool is_initialized = false; Color albedo; float specular; @@ -447,7 +449,7 @@ private: _FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const; - static HashMap> materials_for_2d; //used by Sprite3D and other stuff + static HashMap> materials_for_2d; //used by Sprite3D and other stuff void _validate_high_end(const String &text, PropertyInfo &property) const; @@ -641,24 +643,38 @@ public: virtual Shader::Mode get_shader_mode() const; - SpatialMaterial(); - virtual ~SpatialMaterial(); + Material3D(bool p_orm = false); + virtual ~Material3D(); }; -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) +class SpatialMaterial : public Material3D { + GDCLASS(SpatialMaterial, Material3D) +public: + SpatialMaterial() : + Material3D(false) {} +}; + +class ORMSpatialMaterial : public Material3D { + GDCLASS(ORMSpatialMaterial, Material3D) +public: + ORMSpatialMaterial() : + Material3D(true) {} +}; + +VARIANT_ENUM_CAST(Material3D::TextureParam) +VARIANT_ENUM_CAST(Material3D::DetailUV) +VARIANT_ENUM_CAST(Material3D::Feature) +VARIANT_ENUM_CAST(Material3D::BlendMode) +VARIANT_ENUM_CAST(Material3D::DepthDrawMode) +VARIANT_ENUM_CAST(Material3D::CullMode) +VARIANT_ENUM_CAST(Material3D::Flags) +VARIANT_ENUM_CAST(Material3D::DiffuseMode) +VARIANT_ENUM_CAST(Material3D::SpecularMode) +VARIANT_ENUM_CAST(Material3D::BillboardMode) +VARIANT_ENUM_CAST(Material3D::TextureChannel) +VARIANT_ENUM_CAST(Material3D::EmissionOperator) +VARIANT_ENUM_CAST(Material3D::DistanceFadeMode) +VARIANT_ENUM_CAST(Material3D::AsyncMode) ////////////////////// diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index f2f723f2143..e51c6df397a 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -876,7 +876,7 @@ void ArrayMesh::_get_property_list(List *p_list) const { if (surfaces[i].is_2d) { p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial", PROPERTY_USAGE_EDITOR)); } else { - p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial", PROPERTY_USAGE_EDITOR)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial,ORMSpatialMaterial", PROPERTY_USAGE_EDITOR)); } } } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 461d946c571..6650fd7919b 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -213,7 +213,7 @@ void PrimitiveMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("set_flip_faces", "flip_faces"), &PrimitiveMesh::set_flip_faces); ClassDB::bind_method(D_METHOD("get_flip_faces"), &PrimitiveMesh::get_flip_faces); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ORMSpatialMaterial,ShaderMaterial"), "set_material", "get_material"); ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces"); }