Class reference
WorldScape3DMaterial
Inherits Resource
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 [code skip-lint]is Material[/code] checks. It is a [code skip-lint]Resource[/code].
Properties
Dictionary _shader_parameters = {}
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
bool auto_shader_enabled = falseEnables selecting two texture IDs that will automatically be applied to the terrain based upon slope.
bool dual_scaling_enabled = false
bool dual_scaling_enabled = falseEnables 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
Shader shader_overrideIf 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
bool shader_override_enabled = falseEnables use of the shader_override shader code. Generates default code if shader_override is blank.
bool show_autoshader = false
bool show_autoshader = falseDisplay the area designated for use by the autoshader, which shows materials based upon slope.
bool show_checkered = false
bool show_checkered = falseShows 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
bool show_colormap = falsePlaces the color map in the albedo channel.
bool show_contours = false
bool show_contours = falseOverlays 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
bool show_control_angle = falseAlbedo 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
bool show_control_blend = falseDisplays the values used to blend the textures. Blue shows the autoshader blending, red shows manually painted blending.
bool show_control_scale = false
bool show_control_scale = falseAlbedo 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
bool show_control_texture = falseAlbedo 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
bool show_grey = falseAlbedo is set to 0.2 gray.
bool show_heightmap = false
bool show_heightmap = falseAlbedo 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
bool show_instancer_grid = falseOverlays 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
bool show_jaggedness = falseHighlights non-smooth areas of the terrain. Jagged peaks, troughs, or edges that are a bit rough with sharp angles between vertices.
bool show_navigation = false
bool show_navigation = falseDisplays the area designated for generating the navigation mesh.
bool show_region_grid = false
bool show_region_grid = falseOverlays 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.
bool show_roughmap = false
bool show_roughmap = falseAlbedo 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
bool show_texture_height = falseAlbedo is set to the painted Height textures.
bool show_texture_normal = false
bool show_texture_normal = falseAlbedo is set to the painted Normal textures.
bool show_texture_rough = false
bool show_texture_rough = falseAlbedo is set to the painted Roughness textures. This is different from the roughness modification map above.
bool show_vertex_grid = false
bool show_vertex_grid = falseOverlays the vertex grid on the terrain, showing where each vertex is. Press `3` with the mouse in the viewport to toggle.
int texture_filtering = 0
int texture_filtering = 0Sets how the renderer should filter textures. See TextureFiltering for options.
int world_background = 1
int world_background = 1Sets how the mesh outside of defined regions behave. See WorldBackground for options.
Methods
RID get_material_rid() const
RID get_material_rid() constReturns the RID of the material used with the Rendering Server. This is set per instance of this class.
Variant get_shader_param(StringName name) const
Variant get_shader_param(StringName name) constRetrieve a parameter from the active shader (built-in or override shader).
RID get_shader_rid() const
RID get_shader_rid() constReturns the RID of the built in shader used with the Rendering Server. This is different from any shader override which has its own RID.
int save(String path = "")
int save(String path = "")Saves this material resource to disk, if saved as an external [code skip-lint].tres[/code] or [code skip-lint].res[/code] resource file. path - specifies a directory and file name to use from now on.
void set_shader_param(StringName name, Variant value)
StringName name, Variant value)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.
Constants
NONE = 0
Outside of the defined regions, hide the mesh.
FLAT = 1
Outside of the defined regions, show a flat terrain.
NOISE = 2
Outside of the defined regions, generate visual-only hills.
LINEAR = 0
Textures are filtered using a blend of 4 adjacent pixels. Use this for most cases for high quality renders.
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.