Class reference

WorldScape3DRegion

Inherits Resource

Description

This resource stores all map data for WorldScape3D.

Properties

Image color_map

This map is used to paint color that blends in to the terrain textures. Image format: FORMAT_RGBA8, 32-bits per pixel as four 8-bit components. RGB is used for color, which is multiplied by albedo in the shader. Multiply is a blend mode that only darkens. A is used for a roughness modifier. A value of 0.5 means no change to the existing texture roughness. Higher than this value increases roughness, lower decreases it.

Image control_map

This map tells the shader which textures to use where, how to blend, where to place holes, etc. Image format: FORMAT_RF, 32-bit per pixel as full-precision floating-point. However, we interpret these images as format: RenderingDevice.DATA_FORMAT_R32_UINT aka OpenGL RG32UI 32-bit per pixel as unsigned integer. See Control map format.

Image height_map

This map contains the real value heights for the terrain. Image format: FORMAT_RF, 32-bit per pixel as full-precision floating-point. Heights sent to the vertex shader on the GPU which modifies the mesh in real-time. Editing is always done in 32-bit. We do provide an option to save as 16-bit, see WorldScape3D.save_16_bit.

Vector2 height_range = Vector2(0, 0)

The current minimum and maximum height range for this region, used to calculate the AABB of the terrain. Update it with update_height(), and recalculate it with calc_height_range().

Dictionary instances = {}

A Dictionary that stores the instancer transforms for this region. The format is instances{mesh_id:int} -> cells{grid_location:Vector2i} -> ( Array:Transform3D, PackedColorArray, modified:bool ). That is: - A Dictionary keyed by mesh_id that returns: - A Dictionary keyed by the grid location of the 32 x 32m cell that returns: - A 3-item Array that contains: - 0: An Array of Transform3Ds - 1: A PackedColorArray with instance colors, same index as above - 2: A bool that tracks if this cell has been modified After changing this data, call WorldScape3DInstancer.update_mmis() to rebuild the MMIs.

Vector2i location

The location in region grid space [code skip-lint](world space / region_size)[/code] coordinates. e.g. (-1, 1) equates to (-1024, 1024) in world space given a region_size of 1024.

bool modified

This region has been modified and will be saved to disk upon save(). This serves a different purpose than the temporary edited setting.

int region_size = 0

The current region size for this region, calculated from the dimensions of the first loaded map. It should match WorldScape3D.region_size.

float version = 0.8

The data file version. This is independent of the WorldScape3D version, though they often align.

float vertex_spacing = 1.0

Stored instancer transforms are laterally scaled by this value. This value is manage by the instancer on loading or when WorldScape3D.vertex_spacing is set, and shouldn't be manually adjusted.

Methods

void calc_height_range()

Recalculates the height range for this region by looking at every pixel in the heightmap.

Dictionary get_data() const

Returns all data in this region in a dictionary.

Image get_map(int map_type) const

Returns the specified image map.

Image[] get_maps() const

Returns an ArrayImage with height, control, and color maps.

Image sanitize_map(int map_type, Image map) const

Validates and adjusts the map size and format if possible, or creates a usable blank image in the right size and format.

int save(String path = "", bool save_16_bit = false)

Saves this region to the current file name. - path - specifies a directory and file name to use from now on. - 16-bit - save this region with 16-bit height map instead of 32-bit. This process is lossy. Does not change the bit depth in memory.

void set_data(Dictionary data)

Overwrites all local variables with values in the dictionary.

void set_map(int map_type, Image map)

Assigns the provided map to the desired map type.

void set_maps(Image[] maps)

Expects an array with three images in it, and assigns them to the height, control, and color maps.

void update_height(float height)

When sculpting, this is called to provide the current height. It may expand the vertical bounds, which is used to calculate the terrain AABB.

void update_heights(Vector2 low_high)

When sculpting the terrain, this is called to provide both a low and high height. It may expand the vertical bounds, which is used to calculate the terrain AABB.

bool validate_map_size(Image map) const

This validates the map size according to previously loaded maps.

Constants

TYPE_HEIGHT = 0

Enum: MapType

Height map - real values, eg. 10m, 44.5m.

TYPE_CONTROL = 1

Enum: MapType

Control map - defines where textures and holes are placed.

TYPE_COLOR = 2

Enum: MapType

Color map - paints color on the terrain

TYPE_MAX = 3

Enum: MapType

The number of elements in this enum. Often used to specify all map types for functions that request one.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.