Image Generation

Image generation lets you create stunning visuals from text prompts using models like DALL·E, Gemini Imagen, and others.

There are three primary modes available:

  • 🖌️ Image Creation – Generate a new image from a text description

  • ✂️ Image Edit – Modify an existing image using a prompt

  • 🎨 Image Variation – Create visual remixes or alternatives of an image


✅ 1. Image Creation (from Text)

Texture2D result = await "A cat surfing a wave"
    .GENImage()
    .SetModel(ImageModel.DallE3)
    .ExecuteAsync();

🎨 The image is downloaded and converted into a Unity Texture2D. You can also save it directly using .SaveToDisk() or convert it to PNG.


✅ 2. Image Edit (prompt + image)

Texture2D result = await myTexture
    .GENImageEdit("Add a crown on the cat's head")
    .SetModel(ImageModel.DallE2)
    .ExecuteAsync()
    .AsTexture2D();

✂️ The given image is used as a base, and the model performs localized edits.


✅ 3. Image Variation (image only)

Texture2D result = await myTexture
    .GENImageVariation()
    .SetModel(ImageModel.DallE2)
    .ExecuteAsync();

🎨 A new image is generated based on the style and structure of the original.


📦 Example Output

  • Prompt: "A futuristic city with flying cars"

  • Output: A 1024×1024 image showing a neon-lit cyberpunk skyline


🧩 Advanced Configuration (Per Provider)

Fluent API extensions allow you to customize behavior depending on the selected model.


🔵 OpenAI (DALL·E 2 & 3)

Texture2D result = await "A cyberpunk city at night"
    .GENImage()
    .SetModel(ImageModel.DallE3)
    .SetSize(ImageSize._1024x1024)
    .SetQuality(ImageQuality.HD)
    .SetStyle(ImageStyle.Vivid)
    .ExecuteAsync();
Method
Description

SetSize(ImageSize)

Set image resolution (_256x256, _512x512, _1024x1024)

SetQuality(ImageQuality)

Choose quality (Standard, HD)

SetStyle(ImageStyle)

Define visual tone (Natural, Vivid)

SetMask(Texture2D)

Apply inpainting mask (for edits only)


🟢 Google (Gemini / Imagen)

Texture2D result = await "An astronaut riding a horse"
    .GENImage()
    .SetModel(GeminiModel.Imagen2)
    .SetAspectRatio(AspectRatio.Square)
    .SetPersonGeneration(PersonGeneration.Unspecified)
    .ExecuteAsync();
Method
Description

SetAspectRatio(...)

Choose image layout: Square, Portrait, Landscape

SetPersonGeneration(...)

Control generation of human figures (e.g., allow, deny, unspecified)


🧠 Tips

  • DALL·E 3 only supports generation (not editing/variation) through the OpenAI API.

  • All outputs are automatically saved to a temporary location unless SetOutputPath() is used.

  • Use .AsTexture2D(), .AsPNG(), or .SaveToDisk() depending on your workflow.

  • Not all models support all features. Use .SetModel(...) early and tailor the configuration accordingly.

Last updated