Per Pixel Transparency

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CassanovaWong

I’m trying to use a transparent background with per pixel transparency.

Project → Project Settings → Display → Window → Per Pixel Transparency → Allowed and Project → Project Settings → Display → Window → Per Pixel Transparency → Enabled then call get_tree().get_root().set_transparent_background(true) from the _ready() of my main scene

and I’ve gotten it to work but if I use fullscreen setting. it doesn’t work. I’ve tried adjusting other project settings…

Anyone know how to fix my issue?

I also want to know if it’s possible to have clicks or touches pass through the background…

:bust_in_silhouette: Reply From: rossunger

It sounds like you’re trying to invisibly hook into native OS mouse events, which is a pretty big security risk and fairly low-level programming …I don’t think there’s a built in was to do what you’re trying to do.
Do you have any experience with autohotKey? It’s more suited for this type of thing. You could integrate an ahk script with Godot using some combination of OS.execute or something.

Something like this imght give you an idea of what i want to do:

I want to have my project be able to draw over the user’s normal OS user interface or even interact with it, graphically, at least. With their permission, of course…

CassanovaWong | 2022-02-24 04:10

:bust_in_silhouette: Reply From: skysphr

Making a window full screen signals the compositor not to render other windows and instead draw the window’s buffer directly into the output buffer. The trivial alternative is to give size and position hints to the compositor that make your window cover the rest of things. Sending input events to one application or the other is also dictated by the implementation of the compositor; the only thing you somewhat have control over is the area of the window that responds to mouse events.

Ah, that makes sense. Thanks for explaining.

CassanovaWong | 2022-02-24 04:02

Well, mostly, I’ve solved this by adjusting the ‘OS.set_window_position’ follow to my character’s ‘global_position’, setting the screen size to a little larger than the character’s size., and instancing a second character that has the same position with a Camera2D.current(true) following it. <–Using that as a script attached to my current_scene (parent of character), along with the stuff in the OG post I made (above), it works pretty well (Some polish and debug required…) Nom, pasta code:

extends Node2d

onready var ss = get_viewport_rect().size

func _ready():
	$player.position = Vector2(480,540)
	$player/Camera2D.current = true

func _physics_process(_delta):
        $Polygon2D.polygon = [Vector2.ZERO,

	$player2.global_position = $player.get_global_position()

errrr… something like that…

I’m thinking this has an easier way but for now I can use OS.execute() to bring up several of these mini windows, each as their own process and with their own unique properties.
A side effect I hadn’t considered, by adding a background to the current_scene, this whole mess begins to look like a fog of war on my desktop!! :smiley:

OS is really cool!! I <3 Godot!

CassanovaWong | 2022-03-04 22:33