Use a vertical fade for the flashlight beam
A GradientTexture1D varies along U, so the cone showed a bright ring; build a 1×64 vertical ramp for UV.y instead (faint at the lens, brightest near the start, gone before the tip). Regenerate the affected captures; headless 227/227, compare 11 good / 0 bad.
No files matched your search
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 756 KiB After Width: | Height: | Size: 756 KiB |
|
Before Width: | Height: | Size: 856 KiB After Width: | Height: | Size: 856 KiB |
@@ -139,13 +139,21 @@ static func light_beam() -> StandardMaterial3D:
|
||||
mat.cull_mode = BaseMaterial3D.CULL_DISABLED
|
||||
mat.depth_draw_mode = BaseMaterial3D.DEPTH_DRAW_DISABLED
|
||||
mat.albedo_color = Color(1.0, 0.95, 0.82, 1.0)
|
||||
var fade := Gradient.new()
|
||||
fade.set_color(0, Color(1.0, 0.95, 0.82, 0.08))
|
||||
fade.add_point(0.15, Color(1.0, 0.95, 0.82, 0.5))
|
||||
fade.set_color(fade.get_point_count() - 1, Color(1.0, 0.95, 0.82, 0.0))
|
||||
var ramp := GradientTexture1D.new()
|
||||
ramp.gradient = fade
|
||||
mat.albedo_texture = ramp
|
||||
# A vertical ramp, not a GradientTexture1D: a cylinder's UV.y runs along its
|
||||
# height, while the 1D gradient varies with U and would paint a bright ring.
|
||||
var ramp := Image.create(1, 64, false, Image.FORMAT_RGBA8)
|
||||
for y in 64:
|
||||
var t := float(y) / 63.0
|
||||
# Symmetric fade (bright in the middle, gone at both ends) so the look
|
||||
# does not depend on which way CylinderMesh orients its V coordinate; the
|
||||
# far end must never show as a bright ring.
|
||||
var alpha := 0.0
|
||||
if t < 0.5:
|
||||
alpha = lerpf(0.0, 0.3, t / 0.5)
|
||||
else:
|
||||
alpha = lerpf(0.3, 0.0, (t - 0.5) / 0.5)
|
||||
ramp.set_pixel(0, y, Color(1.0, 1.0, 1.0, alpha))
|
||||
mat.albedo_texture = ImageTexture.create_from_image(ramp)
|
||||
mat.texture_filter = BaseMaterial3D.TEXTURE_FILTER_LINEAR
|
||||
return mat
|
||||
|
||||
|
||||