โ† All examples

godot shaders

2D laser beam with core, glow and sparks

Draw a horizontal laser across a rectangle: a hot core and coloured glow with noisy width, pulses travelling along it, a flare at the emitter end and sparkling impact at the far end.

Recorded render of 2D laser beam with core, glow and sparks

What this component contains

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

How it works

Shader type
canvas_item
Parameters
core_color (vec4 = 1, 0.95, 0.95, 1), beam_color (vec4 = 1, 0.15, 0.3, 1), core_width (float = 0.04), glow_width (float = 0.18), flicker (float = 0.3), pulse_speed (float = 3), pulse_spacing (float = 0.2), flare_size (float = 0.18) and 1 more
Use it on
A ColorRect stretched along the beam (rotate it to aim).
Result
A red laser with a white core crossing the rectangle, flared at the left and sparkling at the right.
Renderers
compatibility: compiled and rendered, forward plus: not verified, mobile: not verified
Placement
res://baltor/godot_shaders/laser_beam_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

Stretching the rectangle stretches the glow; adjust widths to its aspect. The beam is straight.