How to make game window transparent using opacity from camera

I’d like to build something like live wallpaper and while I can set game window as desktop background I cannot make it not render “clear color” from camera to render only some objects. I can do CreateWindowEx(WS_EX_LAYERED… & UpdateLayeredWindow(hwnd, … ULW_ALPHA); for plain windows application, but cannot understand how to set it in UE

You can access HWND from the engine’s global variable GEngine.

#include "Widgets/SWindow.h"
#include "Engine/Engine.h"


    if (GEngine && GEngine->GameViewport && GEngine->GameViewport->GetWindow().IsValid())
    {
        TSharedPtr<SWindow> GameSWindow = GEngine->GameViewport->GetWindow();
        if (GameSWindow.IsValid() && GameSWindow->GetNativeWindow().IsValid())
        {
            void* Handle = GameSWindow->GetNativeWindow()->GetOSWindowHandle();
            HWND hwnd = static_cast<HWND>(Handle);
        }
    }

:video_game: How to Make a Game Window Transparent Using Camera Opacity

:white_check_mark: 1. Unity (C#)

If you’re using Unity, you can adjust the Camera’s background and alpha to make the game window partially or fully transparent:

Steps:
  1. Set the camera background color alpha to 0:

    Camera.main.clearFlags = CameraClearFlags.SolidColor;
    Camera.main.backgroundColor = new Color(0, 0, 0, 0); // RGBA (0 alpha)
    
  2. Enable transparency in the build:

    • Go to Project Settings → Player.

    • Under Windows → Resolution and Presentation, enable:

      • Allow Transparency (only works with certain settings)
    • Set the rendering mode to use alpha (in URP or HDRP).

  3. Use a transparent shader or materials in your scene as needed.

  4. Note: This might only work in Windowed mode and may require special window flags (see below).


:white_check_mark: 2. SDL2 (C++ or Python)

For simpler 2D games using SDL2:

SDL_SetWindowOpacity(window, 0.5f); // 50% transparent

Make sure to:

  • Use a window with the SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_BORDERLESS flags.
  • This works on platforms like Windows and Linux with proper backend support.

:white_check_mark: 3. Win32 API (C++)

If you are making your game with native Win32:

SetWindowLong(hwnd, GWL_EXSTYLE,
    GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, 0, 128, LWA_ALPHA); // 128 = 50% opacity

:smiley: