Terrain3DMaterial
Inherits: Resource < RefCounted < Object
A custom shader material resource for Terrain3D.
Description
This class handles options for both the built-in shader and any custom override shader. It collects compiled texture data from the other classes and sends all of it to the shader via the RenderingServer.
It is a savable resource, so you can save it to disk and use the same material settings in multiple scenes that use Terrain3D. The amount of data is small, assuming you have saved your shader parameter textures to disk, so it can be saved as a git-friendly, text based .tres file or left within the scene file.
While it does mimic some of the functionality of ShaderMaterial, it does not derive from any of the Godot Material classes. It will not pass any is Material
checks. It is a Resource
.
Properties
Dictionary |
|
|
bool |
|
|
bool |
|
|
Shader |
||
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
bool |
|
|
|
||
|
Methods
RID |
|
RID |
|
Variant |
get_shader_param(name: StringName) |
RID |
|
void |
save() |
void |
set_shader_param(name: StringName, value: Variant) |
Enumerations
enum WorldBackground:
WorldBackground NONE = 0
Outside of the defined regions, hide the mesh.
WorldBackground FLAT = 1
Outside of the defined regions, show a flat terrain.
WorldBackground NOISE = 2
Outside of the defined regions, generate visual-only hills.
enum TextureFiltering:
TextureFiltering LINEAR = 0
Textures are filtered using a blend of 4 adjacent pixels. Use this for most cases for high quality renders.
TextureFiltering NEAREST = 1
Textures are filtered using a the nearest pixel only. It is faster than LINEAR, but the texture will look pixelated. Use this for a low-poly look, with a very low uv_scale.
Property Descriptions
Dictionary _shader_parameters = {}
This private dictionary stores all of the shader parameters in the resource. It is not a cache.
bool auto_shader = false
void set_auto_shader(value: bool)
bool get_auto_shader()
Enables selecting two texture IDs that will automatically be applied to the terrain based upon slope.
bool dual_scaling = false
void set_dual_scaling(value: bool)
bool get_dual_scaling()
Enables selecting one texture ID that will have multiple scales applied based upon camera distance. Use it for something like a rock texture so up close it will be nicely detailed, and far away mountains can be covered in the same rock texture. The two blend together at a specified distance.
Shader shader_override
void set_shader_override(value: Shader)
Shader get_shader_override()
If shader_override_enabled is true and this Shader is valid, the material will use this custom shader code. If this is blank when you enable the override, the system will generate a shader with the current settings. So if you have a debug view enabled, the generated shader will have all of that code. A visual shader will also work here. However we only generate a text based shader so currently a visual shader needs to be constructed with the base code before it can work.
bool shader_override_enabled = false
void enable_shader_override(value: bool)
bool is_shader_override_enabled()
Enables use of the shader_override shader code. Generates default code if shader_override is blank.
bool show_autoshader = false
void set_show_autoshader(value: bool)
bool get_show_autoshader()
Display the area designated for use by the autoshader, which shows materials based upon slope.
bool show_checkered = false
void set_show_checkered(value: bool)
bool get_show_checkered()
Shows a checkerboard display using a shader rendered pattern. This is turned on if the Texture List is empty.
Note that when a blank texture slot is created, a 1k checkerboard texture is generated and stored in the texture slot. That takes VRAM. The two patterns have a slightly different scale.
bool show_colormap = false
void set_show_colormap(value: bool)
bool get_show_colormap()
Places the color map in the albedo channel.
bool show_control_blend = false
void set_show_control_blend(value: bool)
bool get_show_control_blend()
Albedo shows the blend value used to blend the base and overlay textures as greyscale. This is especially helpful to see how the noise texture adjusts the blending edges.
bool show_control_texture = false
void set_show_control_texture(value: bool)
bool get_show_control_texture()
Albedo shows the base and overlay texture indices defined by the control map. Red pixels indicate the base texture, with brightness showing texture ids 0 to 31. Green pixels indicate the overlay texture. Yellow indicates both.
bool show_grey = false
void set_show_grey(value: bool)
bool get_show_grey()
Albedo is set to 0.2 grey.
bool show_heightmap = false
void set_show_heightmap(value: bool)
bool get_show_heightmap()
Albedo is a white to black gradient depending on height. The gradient is scaled to a height of 300, so above that or far below 0 will be all white or black.
void set_show_navigation(value: bool)
bool get_show_navigation()
Displays the area designated for generating the navigation mesh.
bool show_roughmap = false
void set_show_roughmap(value: bool)
bool get_show_roughmap()
Albedo is set to the roughness modification map as grey scale. Middle grey, 0.5 means no roughness modification. Black would be high gloss while white is very rough.
bool show_texture_height = false
void set_show_texture_height(value: bool)
bool get_show_texture_height()
Albedo is set to the painted Height textures.
bool show_texture_normal = false
void set_show_texture_normal(value: bool)
bool get_show_texture_normal()
Albedo is set to the painted Normal textures.
bool show_texture_rough = false
void set_show_texture_rough(value: bool)
bool get_show_texture_rough()
Albedo is set to the painted Roughness textures. This is different from the roughness modification map above.
bool show_vertex_grid = false
void set_show_vertex_grid(value: bool)
bool get_show_vertex_grid()
Show a grid on the vertices, overlaying any above shader.
TextureFiltering texture_filtering = 0
void set_texture_filtering(value: TextureFiltering)
TextureFiltering get_texture_filtering()
Sets how the renderer should filter textures. See TextureFiltering for options.
WorldBackground world_background = 1
void set_world_background(value: WorldBackground)
WorldBackground get_world_background()
Sets how the mesh outside of defined regions behave. See WorldBackground for options.
Method Descriptions
RID get_material_rid()
Returns the RID of the material used with the Rendering Server. This is set per instance of this class.
RID get_region_blend_map()
Returns the RID of the 512x512 texture used with the RenderingServer. It depicts a blurry map of region locations and is used for smoothly blending world noise into sculpted terrain.
Variant get_shader_param(name: StringName)
Retrieve a parameter from the active shader (built-in or override shader).
RID get_shader_rid()
Returns the RID of the built in shader used with the Rendering Server. This is different from any shader override which has its own RID.
void save()
Saves this material resource to disk, if saved as an external .tres
or .res
resource file.
void set_shader_param(name: StringName, value: Variant)
Set a parameter in the active shader (built-in or override shader).