Skip to content

AI Image Spawner

AI Agent

🖼️ AI Image Spawner (Text-to-Texture)

This tool allows participants or researchers to spawn images into a virtual scene on demand, simply by typing text prompts (e.g. “a mountain at sunset”). The images are created via OpenAI's DALL·E 3 API and applied in real time as textures to quads in VR.

  • 🔤 Text → Image texture
  • 🧠 Generative AI using DALL·E 3
  • 👁️ Integrated gaze tracking + grabbing via SightLab
  • 🌗 Toggle lighting with B key (if you integrate that feature)
  • 🔁 Generate new images anytime using N key

⚙️ Setup Instructions

1. 📦 Install Required Python Libraries

pip install openai requests

Make sure SightLab and Vizard dependencies are already installed and working.


2. 🔑 Get an OpenAI API Key

  • Visit: https://platform.openai.com/account/api-keys
  • Create or log into your account
  • Copy your API key

3. 📁 Add API Key to File

  • Create a file at: keys/key.txt
  • Paste your API key inside (no extra spaces)
  • New Method (as of SightLab 2.3.7)
  • In windows search type "cmd" and enter setx OPENAI_API_KEY "your-api-key", setx GEMINI_API_KEY "your-api-key",
  • setx ELEVENLABS_API_KEY "your-api-key", setx ANTHROPIC_API_KEY "your-api-key"
  • Restart Vizard
  • With this method you don't need to keep the keys in a folder in your project and your api keys can be accessed from any folder.

▶️ How to Run

  1. Launch the script in Vizard
  2. Press N to enter a text prompt (e.g., a red dragon)
  3. An image is generated via the OpenAI DALL·E 3 API
  4. The image is automatically applied as a quad in the 3D scene
  5. Press N again to generate a new one (replaces the previous image)
  6. Press Trigger or Spacebar to complete the trial

🧠 Example Use Cases

Field Idea Example
🧠 Psychology Generate stimuli like a syringe, a clown face
🧪 UX/VR Design Add textures dynamically for user testing
📚 Education Display images like the solar system, a food pyramid
🎮 Game Studies Explore user responses to a monster, a treasure chest

💡 Tips

  • Images are saved to the /Resources/ folder automatically
  • Object names are generated from your prompt for easier tracking
  • All objects support gaze and grab interactions
  • SightLab logs all data including interactions with each spawned image

- 🌐 OpenAI DALL·E 3 Documentation

Was this page helpful?