โ† All examples

godot shaders

Parallax starfield with twinkling layers

Fill a rectangle with a scrolling starfield: three layers of hashed stars at different densities, sizes and speeds for parallax, colour temperature per star, twinkle, and a scroll direction.

Recorded render of Parallax starfield with twinkling layers

What this component contains

  • ATTRIBUTION.md
  • LICENSE
  • README.md
  • component.json
  • demo.tscn
  • inspect_shader.py
  • material.tres
  • preview.png
  • starfield_parallax_2d.gdshader
  • test_package.py
  • verification/native.json

How it works

Shader type
canvas_item
Parameters
space_color (vec4 = 0.01, 0.01, 0.04, 1), nebula_tint (vec4 = 0.12, 0.05, 0.2, 1), density (float = 0.45), scroll_speed (float = 0.05), scroll_angle_degrees (float = 200), twinkle_speed (float = 3), star_scale (float = 60), brightness (float = 1.3)
Use it on
A ColorRect (or any CanvasItem) sized to the area to fill; UVs span 0 to 1 across it.
Result
A dark purple space with many small blue and warm stars at three sizes.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/starfield_parallax_2d/

Recorded checks

godot 4.7.2.stable.official.ed1daf0bf

  • contract_static
  • engine_run
  • engine_log_clean
  • shader_in_scene
  • capture_written
  • render_not_uniform
  • shader_changes_pixels

Limits to consider

Stars are placed per grid cell, so their density is regular at large scales. Very fast scrolling streaks nothing; it only translates the layers.