Browse Source

Create fresh material in webcam_display instead of duplicating

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
master
melancholytron 3 weeks ago
parent
commit
47a8ec2895
  1. 16
      scripts/webcam_display.gd

16
scripts/webcam_display.gd

@ -18,24 +18,18 @@ var _has_received_frame: bool = false
func _ready() -> void: func _ready() -> void:
# Get or create the material — duplicate to ensure each instance has its own
_material = material_override as StandardMaterial3D
if _material != null:
_material = _material.duplicate() as StandardMaterial3D
material_override = _material
else:
_material = StandardMaterial3D.new()
material_override = _material
# Configure material for unlit display (no scene lighting affects the webcam feed)
# Always create a fresh material — instanced scenes share sub_resources,
# so we must not reuse the scene's material or all quads show the same texture
_material = StandardMaterial3D.new()
_material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED _material.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
_material.albedo_color = default_color _material.albedo_color = default_color
_material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA _material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
material_override = _material
# Create initial texture (will be replaced on first frame) # Create initial texture (will be replaced on first frame)
_texture = ImageTexture.new() _texture = ImageTexture.new()
print("[WebcamDisplay] Ready, waiting for frames...")
print("[WebcamDisplay] %s ready, waiting for frames..." % name)
func _process(delta: float) -> void: func _process(delta: float) -> void:

Loading…
Cancel
Save