Attention: Here be dragons (unstable version)
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Redot.
Checking the stable version of the documentation...
WorldScape3DMaterial
Inherits: Resource < RefCounted < Object
A custom shader material resource for WorldScape3D.
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 WorldScape3D. 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 Redot Material classes. It will not pass any is Material checks. It is a Resource.
Properties
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods
get_material_rid() const |
|
get_shader_param(name: StringName) const |
|
get_shader_rid() const |
|
void |
set_shader_param(name: StringName, value: Variant) |
void |
update() |
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_enabled = false 🔗
Enables selecting two texture IDs that will automatically be applied to the terrain based upon slope.
bool dual_scaling_enabled = false 🔗
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.
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 🔗
Enables use of the shader_override shader code. Generates default code if shader_override is blank.
bool show_autoshader = false 🔗
Display the area designated for use by the autoshader, which shows materials based upon slope.
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.
Places the color map in the albedo channel.
Overlays contour lines on the terrain. Customize the options in the material when enabled. Press 4 with the mouse in the viewport to toggle.
bool show_control_angle = false 🔗
Albedo shows the painted angle. Orange means 0°, Yellow 270°, Cyan 180°, Violet 90°. Or warm colors towards -Z, cool colors +Z, greens/yellows +X, reds/blues -X. Draw all angles coming from the center of a circle for a better understanding.
bool show_control_blend = false 🔗
Displays the values used to blend the textures. Blue shows the autoshader blending, red shows manually painted blending.
bool show_control_scale = false 🔗
Albedo shows the painted scale. Larger scales are more red, smaller scales are more blue. 0.5 middle gray is the default 100% scale.
bool show_control_texture = false 🔗
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.
Albedo is set to 0.2 gray.
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.
bool show_instancer_grid = false 🔗
Overlays the 32x32m instancer grid on the terrain, which shows how the instancer data is partitioned. Press 2 with the mouse in the viewport to toggle.
bool show_jaggedness = false 🔗
Highlights non-smooth areas of the terrain. Jagged peaks, troughs, or edges that are a bit rough with sharp angles between vertices.
Displays the area designated for generating the navigation mesh.
bool show_region_grid = false 🔗
Overlays the region grid on the terrain. This is more accurate than the region grid gizmo for determining where the region border is when editing. Press 1 with the mouse in the viewport to toggle.
Albedo is set to the roughness modification map as gray scale. Middle gray, 0.5 means no roughness modification. Black would be high gloss while white is very rough.
bool show_texture_height = false 🔗
Albedo is set to the painted Height textures.
bool show_texture_normal = false 🔗
Albedo is set to the painted Normal textures.
bool show_texture_rough = false 🔗
Albedo is set to the painted Roughness textures. This is different from the roughness modification map above.
bool show_vertex_grid = false 🔗
Overlays the vertex grid on the terrain, showing where each vertex is. Press 3 with the mouse in the viewport to toggle.
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() const 🔗
Returns the RID of the material used with the Rendering Server. This is set per instance of this class.
Variant get_shader_param(name: StringName) const 🔗
Retrieve a parameter from the active shader (built-in or override shader).
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.
Error save(path: String = "") 🔗
Saves this material resource to disk, if saved as an external .tres or .res resource file.
path - specifies a directory and file name to use from now on.
void set_shader_param(name: StringName, value: Variant) 🔗
Set a parameter in the active shader (built-in or override shader).
void update() 🔗
Recompiles the current shader and sends all uniform values to it again.