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.
Constructor
Variables
albedoTexture:Texture
Texture to multiply by godot.SpatialMaterial.albedoColor
. Used for basic texturing of objects.
anisotropy:Single
The strength of the anisotropy effect. This is multiplied by godot.SpatialMaterial.anisotropyFlowmap
's alpha channel if a texture is defined there and the texture contains an alpha channel.
anisotropyEnabled:Bool
If true
, 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.
Note: Mesh tangents are needed for anisotropy to work. If the mesh does not contain tangents, the anisotropy effect will appear broken.
Note: 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 Anisotropic checkbox then clicking Reimport.
anisotropyFlowmap:Texture
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 godot.SpatialMaterial.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.
aoEnabled:Bool
If true
, ambient occlusion is enabled. Ambient occlusion darkens areas based on the godot.SpatialMaterial.aoTexture
.
aoLightAffect:Single
Amount that ambient occlusion affects lighting from lights. If 0
, ambient occlusion only affects ambient light. If 1
, 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.
aoTexture:Texture
Texture that defines the amount of ambient occlusion for a given point on the object.
aoTextureChannel:SpatialMaterial_TextureChannel
Specifies the channel of the godot.SpatialMaterial.aoTexture
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.
clearcoat:Single
Sets the strength of the clearcoat effect. Setting to 0
looks the same as disabling the clearcoat effect.
clearcoatEnabled:Bool
If true
, 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.
Note: Clearcoat rendering is not visible if the material has godot.SpatialMaterial.flagsUnshaded
set to true
.
clearcoatGloss:Single
Sets the roughness of the clearcoat pass. A higher value results in a smoother clearcoat while a lower value results in a rougher clearcoat.
clearcoatTexture:Texture
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.
depthDeepParallax:Bool
If true
, 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.
depthEnabled:Bool
If true
, depth mapping is enabled (also called "parallax mapping" or "height mapping"). See also godot.SpatialMaterial.normalEnabled
.
Note: Depth mapping is not supported if triplanar mapping is used on the same material. The value of godot.SpatialMaterial.depthEnabled
will be ignored if godot.SpatialMaterial.uv1Triplanar
is enabled.
depthFlipBinormal:Bool
If true
, 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.
depthFlipTangent:Bool
If true
, 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.
depthMaxLayers:Int
Number of layers to use when using godot.SpatialMaterial.depthDeepParallax
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.
depthMinLayers:Int
Number of layers to use when using godot.SpatialMaterial.depthDeepParallax
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.
depthTexture:Texture
Texture used to determine depth at a given pixel. Depth is always stored in the red channel.
detailBlendMode:SpatialMaterial_BlendMode
Specifies how the godot.SpatialMaterial.detailAlbedo
should blend with the current ALBEDO
. See godot.SpatialMaterial_BlendMode
for options.
detailEnabled:Bool
If true
, enables the detail overlay. Detail is a second texture that gets mixed over the surface of the object based on godot.SpatialMaterial.detailMask
. This can be used to add variation to objects, or to blend between two different albedo/normal textures.
detailMask:Texture
Texture used to specify how the detail textures get blended with the base textures.
detailNormal:Texture
Texture that specifies the per-pixel normal of the detail overlay.
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates](this page) for a comparison of normal map coordinates expected by popular engines.
detailUvLayer:SpatialMaterial_DetailUV
Specifies whether to use UV
or UV2
for the detail layer. See godot.SpatialMaterial_DetailUV
for options.
distanceFadeMaxDistance:Single
Distance at which the object appears fully opaque.
Note: If distance_fade_max_distance
is less than distance_fade_min_distance
, the behavior will be reversed. The object will start to fade away at distance_fade_max_distance
and will fully disappear once it reaches distance_fade_min_distance
.
distanceFadeMinDistance:Single
Distance at which the object starts to become visible. If the object is less than this distance away, it will be invisible.
Note: If distance_fade_min_distance
is greater than distance_fade_max_distance
, the behavior will be reversed. The object will start to fade away at distance_fade_max_distance
and will fully disappear once it reaches distance_fade_min_distance
.
distanceFadeMode:SpatialMaterial_DistanceFadeModeEnum
Specifies which type of fade to use. Can be any of the godot.SpatialMaterial_DistanceFadeModeEnum
s.
emissionEnabled:Bool
If true
, the body emits light. Emitting light makes the object appear brighter. The object can also cast light on other objects if a godot.GIProbe
or godot.BakedLightmap
is used and this object is used in baked lighting.
emissionOperator:SpatialMaterial_EmissionOperatorEnum
Sets how godot.SpatialMaterial.emission
interacts with godot.SpatialMaterial.emissionTexture
. Can either add or multiply. See godot.SpatialMaterial_EmissionOperatorEnum
for options.
flagsAlbedoTexForceSrgb:Bool
Forces a conversion of the godot.SpatialMaterial.albedoTexture
from sRGB space to linear space.
flagsDoNotReceiveShadows:Bool
If true
, the object receives no shadow that would otherwise be cast onto it.
flagsEnsureCorrectNormals:Bool
If true
, 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.
flagsNoDepthTest:Bool
If true
, depth testing is disabled and the object will be drawn in render order.
flagsTransparent:Bool
If true
, transparency is enabled on the body. See also godot.SpatialMaterial.paramsBlendMode
.
flagsUsePointSize:Bool
If true
, render point size can be changed.
Note: This is only effective for objects whose geometry is point-based rather than triangle-based. See also godot.SpatialMaterial.paramsPointSize
.
flagsUseShadowToOpacity:Bool
If true
, 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.
flagsVertexLighting:Bool
If true
, 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 which can globally enable vertex shading on all materials.
Note: By default, vertex shading is enforced on mobile platforms by 's mobile
override.
Note: godot.SpatialMaterial.flagsVertexLighting
has no effect if godot.SpatialMaterial.flagsUnshaded
is true
.
flagsWorldTriplanar:Bool
If true
, triplanar mapping is calculated in world space rather than object local space. See also godot.SpatialMaterial.uv1Triplanar
.
metallic:Single
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 0
and 1
should only be used for blending between metal and non-metal sections. To alter the amount of reflection use godot.SpatialMaterial.roughness
.
metallicSpecular:Single
Sets the size of the specular lobe. The specular lobe is the bright spot that is reflected from light sources.
Note: Unlike godot.SpatialMaterial.metallic
, this is not energy-conserving, so it should be left at 0.5
in most cases. See also godot.SpatialMaterial.roughness
.
metallicTexture:Texture
Texture used to specify metallic for an object. This is multiplied by godot.SpatialMaterial.metallic
.
metallicTextureChannel:SpatialMaterial_TextureChannel
Specifies the channel of the godot.SpatialMaterial.metallicTexture
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.
normalTexture:Texture
Texture used to specify the normal at a given pixel. The normal_texture
only uses the red and green channels; the blue and alpha channels are ignored. The normal read from normal_texture
is oriented around the surface normal provided by the godot.Mesh
.
Note: 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 godot.SurfaceTool
, you can use godot.SurfaceTool.generateNormals
and godot.SurfaceTool.generateTangents
to automatically generate normals and tangents respectively.
Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See [http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates](this page) for a comparison of normal map coordinates expected by popular engines.
paramsBillboardKeepScale:Bool
If true
, the shader will keep the scale set for the mesh. Otherwise the scale is lost when billboarding. Only applies when godot.SpatialMaterial.paramsBillboardMode
is godot.SpatialMaterial_BillboardMode.enabled
.
paramsBillboardMode:SpatialMaterial_BillboardMode
Controls how the object faces the camera. See godot.SpatialMaterial_BillboardMode
.
Note: 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 [https://github.com/godotengine/godot/issues/41567](GitHub issue #41567) for details.
paramsBlendMode:SpatialMaterial_BlendMode
The material's blend mode.
Note: Values other than Mix
force the object into the transparent pipeline. See godot.SpatialMaterial_BlendMode
.
paramsCullMode:SpatialMaterial_CullMode
Which side of the object is not drawn when backfaces are rendered. See godot.SpatialMaterial_CullMode
.
paramsDepthDrawMode:SpatialMaterial_DepthDrawMode
Determines when depth rendering takes place. See godot.SpatialMaterial_DepthDrawMode
. See also godot.SpatialMaterial.flagsTransparent
.
paramsDiffuseMode:SpatialMaterial_DiffuseMode
The algorithm used for diffuse light scattering. See godot.SpatialMaterial_DiffuseMode
.
paramsGrow:Bool
If true
, enables the vertex grow setting. See godot.SpatialMaterial.paramsGrowAmount
.
paramsSpecularMode:SpatialMaterial_SpecularMode
The method for rendering the specular blob. See godot.SpatialMaterial_SpecularMode
.
paramsUseAlphaScissor:Bool
If true
, the shader will discard all pixels that have an alpha value less than godot.SpatialMaterial.paramsAlphaScissorThreshold
.
particlesAnimHFrames:Int
The number of horizontal frames in the particle sprite sheet. Only enabled when using godot.SpatialMaterial_BillboardMode.particles
. See godot.SpatialMaterial.paramsBillboardMode
.
particlesAnimLoop:Bool
If true
, particle animations are looped. Only enabled when using godot.SpatialMaterial_BillboardMode.particles
. See godot.SpatialMaterial.paramsBillboardMode
.
particlesAnimVFrames:Int
The number of vertical frames in the particle sprite sheet. Only enabled when using godot.SpatialMaterial_BillboardMode.particles
. See godot.SpatialMaterial.paramsBillboardMode
.
proximityFadeDistance:Single
Distance over which the fade effect takes place. The larger the distance the longer it takes for an object to fade.
proximityFadeEnable:Bool
If true
, the proximity fade effect is enabled. The proximity fade effect fades out each pixel based on its distance to another object.
refractionEnabled:Bool
If true
, 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.
refractionScale:Single
The strength of the refraction effect. Higher values result in a more distorted appearance for the refraction.
refractionTexture:Texture
Texture that controls the strength of the refraction per-pixel. Multiplied by godot.SpatialMaterial.refractionScale
.
refractionTextureChannel:SpatialMaterial_TextureChannel
Specifies the channel of the godot.SpatialMaterial.refractionTexture
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.
rimEnabled:Bool
If true
, rim effect is enabled. Rim lighting increases the brightness at glancing angles on an object.
Note: Rim lighting is not visible if the material has godot.SpatialMaterial.flagsUnshaded
set to true
.
rimTexture:Texture
Texture used to set the strength of the rim lighting effect per-pixel. Multiplied by godot.SpatialMaterial.rim
.
rimTint:Single
The amount of to blend light and albedo color when rendering rim effect. If 0
the light color is used, while 1
means albedo color is used. An intermediate value generally works best.
roughness:Single
Surface reflection. A value of 0
represents a perfect mirror while a value of 1
completely blurs the reflection. See also godot.SpatialMaterial.metallic
.
roughnessTexture:Texture
Texture used to control the roughness per-pixel. Multiplied by godot.SpatialMaterial.roughness
.
roughnessTextureChannel:SpatialMaterial_TextureChannel
Specifies the channel of the godot.SpatialMaterial.aoTexture
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.
subsurfScatterEnabled:Bool
If true
, subsurface scattering is enabled. Emulates light that penetrates an object's surface, is scattered, and then emerges.
subsurfScatterTexture:Texture
Texture used to control the subsurface scattering strength. Stored in the red texture channel. Multiplied by godot.SpatialMaterial.subsurfScatterStrength
.
transmission:Color
The color used by the transmission effect. Represents the light passing through an object.
transmissionTexture:Texture
Texture used to control the transmission effect per-pixel. Added to godot.SpatialMaterial.transmission
.
uv1Offset:Vector3
How much to offset the UV
coordinates. This amount will be added to UV
in the vertex function. This can be used to offset a texture.
uv1Scale:Vector3
How much to scale the UV
coordinates. This is multiplied by UV
in the vertex function.
uv1Triplanar:Bool
If true
, instead of using UV
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.
uv1TriplanarSharpness:Single
A lower number blends the texture more softly while a higher number blends the texture more sharply.
uv2Offset:Vector3
How much to offset the UV2
coordinates. This amount will be added to UV2
in the vertex function. This can be used to offset a texture.
uv2Scale:Vector3
How much to scale the UV2
coordinates. This is multiplied by UV2
in the vertex function.
uv2Triplanar:Bool
If true
, instead of using UV2
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.
uv2TriplanarSharpness:Single
A lower number blends the texture more softly while a higher number blends the texture more sharply.
Methods
getFeature(feature:SpatialMaterial_Feature):Bool
Returns true
, if the specified godot.SpatialMaterial_Feature
is enabled.
getFlag(flag:SpatialMaterial_Flags):Bool
Returns true
, if the specified flag is enabled. See godot.SpatialMaterial_Flags
enumerator for options.
getTexture(param:SpatialMaterial_TextureParam):Texture
Returns the godot.Texture
associated with the specified godot.SpatialMaterial_TextureParam
.
setFeature(feature:SpatialMaterial_Feature, enable:Bool):Void
If true
, enables the specified godot.SpatialMaterial_Feature
. Many features that are available in godot.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 true
.
setFlag(flag:SpatialMaterial_Flags, enable:Bool):Void
If true
, enables the specified flag. Flags are optional behaviour 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 true
. See godot.SpatialMaterial_Flags
enumerator for options.
setTexture(param:SpatialMaterial_TextureParam, texture:Texture):Void
Sets the godot.Texture
to be used by the specified godot.SpatialMaterial_TextureParam
. This function is called when setting members ending in *_texture
.