# bey-closer-t1 milestone 3.0: Backglow Driver

## goal
extend bey-closer to serve as the bridge between VR titles (primarily VRChat) and an array of LEDs which are built into the user's facial interface, and connected to the Beyond HMD. these LEDs reproduce a human-observable effect caused by transscleral illumination, or light which penetrates the flesh at varying intensities (think sunlight vs. indoor lighting vs. a bedside lamp) and reaches the inner eye through the facial surfaces surrounding the eyes. for the purposes of this project, the aforementioned effect is coined as "backglow." the backglow driver seeks to digitally emulate backglow in a virtual context.

### compatibility
the backglow driver should work with any VR game whose devs choose to adopt it. an easy-to-use API is a must. vrchat is especially important, where its vast number of user-created worlds should be able to control the backglow driver by some means. that said, what vrchat worlds can interact with in terms of vr hardware directly, is greatly limited by the platform itself. avatar-based control (or influence) of the driver would be a secondary priority. worlds are most important, and may need to leverage the inbuilt networking features of vrchat's world coding language, Udon.

the exact interface for games to control the backglow driver needs to be deeply researched. some ideas include:
- registering unique OpenVR and/or OpenXR input components to the HMD container
- leveraging OSC (uses the local machine's internal network. for vrchat, probably only works with avatars and not worlds)
- control over WAN using hub and spoke structure. world sends user's avatar name or ID to a central backglow server-->server confirms to world whether user has it enabled-->streaming comms continue from there to a local backglow client (ideally built into the driver) on the user's machine.

### architecture
the earliest version of backglow is built today using early-phase rough prototype hardware. no custom PCB yet. as such, the backglow driver needs to be built in such a way as to very intentionally keep the "prototype" layers of code modular, and wholly separate from the "core featureset" layers of code. core featureset includes:
- communication protocols for VR applications
- internal protocol for receiving and processing LED signals
- potential local machine networking daemon for OSC and/or WAN interfaces
- potential public backglow server for WAN interface

prototype featureset includes:
- current hardware
  - MagWLED-1 PCB with bluetooth and wifi, connected to/powered by the PC via USB. runs WLED firmware on an ESPRESSIF ESP32-C3-MINI-1 https://www.amazon.com/dp/B0CYKYDH64
  - connected to the MagWLED-1 is a short string of 10x WS2812B RGB LED ICs, which have been integrated into the facial interface https://www.amazon.com/dp/B0CQRL3JXJ
- RBG LED control: WLED firmware comms over USB or potentially local network WiFi (needs researched)

### driving the prototype hardware
primary candidate interface discovered so far, for driving the prototype LEDs in realtime: https://kno.wled.ge/interfaces/ddp/. however ideally, it would be better to drive the MagWLED-1 over USB. that way there's no network setup to worry about. dealing with wifi setup can be a pain, especially in demo situations.

if necessary, we could create a custom firwmare for the ESP32. but that may be overly complex and risks damaging the prototype hardware.

LED arrangement on the lit cushion is as follows (where 1 is nearest to the controller board):
1. inner bottom right
2. outer bottom right
3. outer right
4. outer upper right
5. inner upper right
... to 10, inner bottom left.

## long-term
while backglow is an exciting new feature in the world of VR, it has a challenging road ahead:
- a good prototype phase --> it becomes necessary to create an EVT with fully custom electronics
- positive reception --> we will need to spin up a dev-friendly SDK that makes it easy for creators to build the necessary lighting calculations, geometry, code, etc. into their worlds and apps. help them emulate "light hitting the face" for a proper backglow experience. likely starting with a unity SDK first.