Skip to main content

CesBuilder

Struct CesBuilder 

Source
pub struct CesBuilder {
    pub device: BuilderDevice,
    pub builtin_shader: BuiltinShader,
    pub shader_file: GString,
    pub water_height: f32,
    pub water_enabled: bool,
    pub water_deep_color: Color,
    pub water_shallow_color: Color,
    pub water_wave_strength: f32,
    pub water_wave_scale: f32,
    pub water_wave_speed: f32,
    pub water_underwater_color: Color,
    pub water_underwater_density: f32,
    /* private fields */
}
Expand description

The terrain source: a Resource you assign to Celestial::builder. It answers “what does this planet’s surface look like?” — height, colour, and (since it also owns the water_* group) the ocean.

A planet has exactly one. Sub-class it in GDScript (extends CesBuilder) to write your own terrain, or use one of the shipped example builders; leave the property empty and the planet renders a plain white sphere. Every edit — a knob, the shader file, the water level — reshades the resident chunks live.

The routing between the built-in noise, a custom .glsl and custom GDScript is described in the module docs; user-facing guides live at https://celestialsim.github.io/CelestialSim/.

Fields§

§device: BuilderDevice

Which device produces the surface. BuilderDevice::GPU (the default) is the fast path: thousands of threads realize and bake each chunk with no readback. BuilderDevice::CPU bakes chunk surfaces from Rust worker threads (built-in noise) or from your GDScript height/color (custom) — far slower, and the synchronous GDScript route runs on the main thread, so keep tile_res moderate there. Switching this reshapes the inspector (only the relevant fields stay visible) via on_validate_property.

§builtin_shader: BuiltinShader

HIDDEN (STORAGE-only) selector for WHICH built-in library shader this builder runs. None = custom (user .glsl/GDScript); Terrain = the built-in noise. Set by the example GDScripts’ _init; combined with device it selects the BuilderRoute.

§shader_file: GString

GPU-device custom only: res:// path to your terrain .glsl (defines terrain_height / terrain_color, optional terrain_normal).

§water_height: f32

Water level — normalized sea level (0..1). A NATIVE field (was a per-subclass GDScript @export) so EVERY builder — noise or custom — carries the same water level. Also drives terrain shore colouring and is surfaced to custom shaders as CELS_WATER_HEIGHT. 0.5 = sea at the planet radius (noise midpoint / custom h = 0 baseline); raise to flood low land. Always visible. A changed-emitting setter (below) reshades the WHOLE terrain on edit — the water level controls the land/sea split, not just the sphere — so a plain field would leave the terrain stale.

§water_enabled: bool

Water toggle — draw the analytic ocean at water_height (default on). Off removes the sea surface entirely (the land/sea colouring of the terrain still follows water_height) and hides the appearance params below, which reappear — with their stored values — when it is switched back on.

§water_deep_color: Color

Body colour of deep water, far from shore; blended toward water_shallow_color as the sea floor rises. Default a dark blue.

§water_shallow_color: Color

Body colour of shallow water near the shoreline — the coastal tint. Default a light teal.

§water_wave_strength: f32

How strongly the wave normals perturb the surface: 0 = a flat mirror, 1 = maximum choppiness. Default 0.55.

§water_wave_scale: f32

Spatial frequency of the wave pattern — higher = smaller, tighter waves. Default 0.15.

§water_wave_speed: f32

How fast the wave pattern scrolls; 0 freezes the sea. Default 0.04.

§water_underwater_color: Color

Tint of the underwater fog (Beer–Lambert) applied when the camera is below the surface. Default a murky blue.

§water_underwater_density: f32

Underwater fog density, per world unit of water column: higher = visibility drops off faster once submerged; 0 = perfectly clear water. Default 0.02.

Implementations§

Source§

impl CesBuilder

Source

pub fn get_water_enabled(&self) -> <bool as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_enabled(&mut self, water_enabled: <bool as GodotConvert>::Via)

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_deep_color(&self) -> <Color as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_deep_color( &mut self, water_deep_color: <Color as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_shallow_color(&self) -> <Color as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_shallow_color( &mut self, water_shallow_color: <Color as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_wave_strength(&self) -> <f32 as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_wave_strength( &mut self, water_wave_strength: <f32 as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_wave_scale(&self) -> <f32 as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_wave_scale( &mut self, water_wave_scale: <f32 as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_wave_speed(&self) -> <f32 as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_wave_speed( &mut self, water_wave_speed: <f32 as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_underwater_color(&self) -> <Color as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_underwater_color( &mut self, water_underwater_color: <Color as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn get_water_underwater_density(&self) -> <f32 as GodotConvert>::Via

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source

pub fn set_water_underwater_density( &mut self, water_underwater_density: <f32 as GodotConvert>::Via, )

👎Deprecated:

Auto-generated Rust getters/setters for #[var] are being phased out until v0.6. If you need them, opt in with #[var(pub)].

Source§

impl CesBuilder

Source

pub fn params(&self) -> BuilderParams

Collect the noise knobs (declared as @exports on the example GDScripts) into the plain params struct, defaulting to the HQ terrain when absent.

Source

pub fn to_height_gpu(&self) -> HeightGpu

Geometry (height) params for the inline example shader.

Source

pub fn to_texture_gpu(&self) -> TextureGpu

Surface (texture) params for the inline example shader.

Source

pub fn to_noise_params(&self, radius: f32) -> NoiseParams

CPU-noise params for crate::noise_provider::NoiseProvider (CpuNoise). radius is the planet radius (for the FD normal).

Source

pub fn water_height(&self) -> f32

The builder’s normalized sea level (0..1). Read as a knob so a custom GPU builder (no water_height @export) falls back to the default.

Source

pub fn height_scale(&self) -> f32

The builder’s geometry displacement multiplier. Read as a knob so a custom GPU builder (no height_scale @export) falls back to the default.

Source

pub fn submits(&self) -> Arc<SubmitQueue>

The async-bake hand-back queue (the planet drains it each frame).

Source§

impl CesBuilder

Source

pub fn submit_chunk( &self, handle: i64, heights: PackedFloat32Array, colors: PackedColorArray, normals: PackedVector3Array, )

Hand a finished chunk surface back to the planet. Callable from any thread (it takes a mutex and returns; the planet drains next frame).

  • handle — the handle from the matching _bake_requested entry.
  • heightstile_res² displacements in YOUR vertical unit, row-major (the height_scale property converts them to displaced radius).
  • colorstile_res² albedos, row-major.
  • normals — optional; leave empty to have the library finite-difference the height grid for you.

Idempotent: call it again for the same handle to refine that chunk (a coarse tile now, a finer one when the download lands). A submission for a chunk that has left the view is simply dropped — that is the whole cancellation story. Wrong-length arrays are rejected (one error is printed, then silence); non-finite heights are sanitized to 0.0.

The full contract (the _bake_requested request format, _base_ready) is in the “Advanced: async bake” section of the custom-CPU-terrain guide at https://celestialsim.github.io/CelestialSim/.

Source

pub fn chunk_dirs( &self, corners: PackedVector3Array, tile_res: i64, ) -> PackedVector3Array

The tile_res² texel-centre world directions of a chunk, row-major — the same mapping the shaders use.

Not included in a bake request (786 KB per chunk at tile_res = 256, and a streaming builder wants a lat/lon box, not directions), so materialize them only if you need them. Pure: safe to call from a worker thread.

Source

pub fn get_device(&self) -> BuilderDevice

Source

pub fn set_device(&mut self, v: BuilderDevice)

Source

pub fn get_builtin_shader(&self) -> BuiltinShader

Source

pub fn set_builtin_shader(&mut self, v: BuiltinShader)

Source

pub fn get_shader_file(&self) -> GString

Source

pub fn set_shader_file(&mut self, v: GString)

Source

pub fn get_water_height(&self) -> f32

Source

pub fn set_water_height(&mut self, v: f32)

Trait Implementations§

Source§

impl Bounds for CesBuilder

Source§

type Memory = <<CesBuilder as GodotClass>::Base as Bounds>::Memory

Defines the memory strategy of the static type.
Source§

type Declarer = DeclUser

Whether this class is a core Godot class provided by the engine, or declared by the user as a Rust struct.
Source§

impl GodotClass for CesBuilder

Source§

type Base = Resource

The immediate superclass of T. This is always a Godot engine class.
Source§

fn class_id() -> ClassId

Globally unique class ID, linked to the name under which the class is registered in Godot. Read more
§

const INIT_LEVEL: InitLevel = <Self::Base as GodotClass>::INIT_LEVEL

Initialization level, during which this class should be initialized with Godot. Read more
§

fn inherits<Base>() -> bool
where Base: GodotClass,

Returns whether Self inherits from Base. Read more
Source§

impl IResource for CesBuilder

Source§

fn on_validate_property(&self, property: &mut PropertyInfo)

Reshape the inspector by (device, builtin_shader) — read as plain fields, NEVER via self.to_gd() (which would free a refcount-0 introspection object and crash). builtin_shader is always hidden (STORAGE only). shader_file shows ONLY for the GPU-custom route. Every other property (including the example GDScripts’ @export knobs) is left visible. Hidden fields keep STORAGE so values still persist.

§

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object. Read more
§

fn on_notification(&mut self, what: ObjectNotification)

Called when the object receives a Godot notification. Read more
§

fn on_get(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property. Read more
§

fn on_set(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property. Read more
§

fn on_get_property_list(&mut self) -> Vec<PropertyInfo>

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties. Read more
§

fn on_property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not. Read more
§

fn to_string(&self) -> GString

String representation of the Godot instance. Read more
§

fn setup_local_to_scene(&mut self)

Override this method to customize the newly duplicated resource created from [instantiate][crate::classes::PackedScene::instantiate], if the original’s [member resource_local_to_scene] is set to true. Read more
§

fn get_rid(&self) -> Rid

Override this method to return a custom [RID][crate::builtin::Rid] when [get_rid][crate::classes::Resource::get_rid] is called.
§

fn reset_state(&mut self)

For resources that store state in non-exported properties, such as via [on_validate_property][crate::classes::IObject::on_validate_property] or [on_get_property_list][crate::classes::IObject::on_get_property_list], this method must be implemented to clear them.
§

fn set_path_cache(&self, path: GString)

Override this method to execute additional logic after [set_path_cache][crate::classes::Resource::set_path_cache] is called on this object.
Source§

impl Inherits<Object> for CesBuilder

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<RefCounted> for CesBuilder

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl Inherits<Resource> for CesBuilder

§

const IS_SAME_CLASS: bool = false

True iff Self == Base. Read more
Source§

impl WithBaseField for CesBuilder

Source§

fn to_gd(&self) -> Gd<CesBuilder>

Returns the Gd pointer containing this object. Read more
§

fn base(&self) -> BaseRef<'_, Self>

Returns a shared reference guard, suitable for calling &self engine methods on this object. Read more
§

fn base_mut(&mut self) -> BaseMut<'_, Self>

Returns an exclusive reference guard, suitable for calling &self/&mut self engine methods on this object. Read more
§

fn run_deferred<F>(&mut self, mut_self_method: F)
where F: FnOnce(&mut Self) + 'static,

Defers the given closure to run during idle time. Read more
§

fn run_deferred_gd<F>(&mut self, gd_function: F)
where F: FnOnce(Gd<Self>) + 'static,

Defers the given closure to run during idle time. Read more
Source§

impl WithSignals for CesBuilder

Source§

type SignalCollection<'c, C: WithSignals> = __godot_Signals_CesBuilder<'c, C>

The associated struct listing all signals of this class. Read more
Source§

impl WithUserSignals for CesBuilder

Source§

fn signals(&mut self) -> Self::SignalCollection<'_, Self>

Access user-defined signals of the current object self. Read more
Source§

impl GodotDefault for CesBuilder

Source§

impl ImplementsGodotApi for CesBuilder

Source§

impl ImplementsGodotExports for CesBuilder

Source§

impl ImplementsGodotVirtual for CesBuilder

Source§

impl You_forgot_the_attribute__godot_api for CesBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T
where T: GodotClass,

§

const IS_SAME_CLASS: bool = true

True iff Self == Base. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> NewGd for T
where T: GodotDefault<Memory = MemRefCounted> + Bounds,

§

fn new_gd() -> Gd<T>

Return a new, ref-counted Gd containing a default-constructed instance. Read more
§

impl<C> ObjectToOwned<C> for C
where C: WithBaseField,

§

fn object_to_owned(&self) -> Gd<C>

Converts the object reference to an owned Gd<T>.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> UniformObjectDeref<DeclUser> for T
where T: WithBaseField,

§

type TargetRef<'a> = GdRef<'a, T>

§

type TargetMut<'a> = GdMut<'a, T>

§

fn object_as_ref<'a>( gd: &'a Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetRef<'a>

§

fn object_as_mut<'a>( gd: &'a mut Gd<T>, ) -> <T as UniformObjectDeref<DeclUser>>::TargetMut<'a>