Meetup Unity 3D #5
Dungeon of the Endless
Hello world!
Sébastien Dubois
Lead programmer Unity3D
sdubois@amplitude-studios.com
@GFX47
Meetup Unity 3D #5
Dungeon of the Endless
Présentation

Rendu

Génération

Conclusion
Présentation - Perso
Formation

Parcours pro
Présentation – Amplitude Studios
Présentation – Amplitude Studios
Présentation – Amplitude Studios
Présentation – Amplitude Studios
Présentation – Dungeon of the Endless

Réf. : « Dungeon of the Endless – Early Access Trailer » http://goo.gl/y0WsVI
Présentation – Dungeon of the Endless
Présentation – Dungeon of the Endless
Michaël BREYTON

Simon Perin

Associate producer

Pixel Artist

Arthur Prudent

Sébastien Dubois

Game Designer

Lead programmer
Présentation – Dungeon of the Endless

Game Design

Playtests

Implémentation

QA / VIP

Public
Présentation – Dungeon of the Endless
Début (avril 2013)
…
Early access Steam
(décembre 2013)
+ 1 update / 2 semaines
…
Bêta (??/??/2014)
…
Gold (??/??/2014) o/
Réf. : « Dungeon of the Endless - Steam » store.steampowered.com/app/249050
Meetup Unity 3D #5
Dungeon of the Endless
Présentation

Rendu

Génération

Conclusion
Rendu – Pixel Perfect
- Caméra :
- Type orthographique
- « orthographic size » = hauteur d’écran (pixels) / 2

- Textures :
-

Filtre « point »
Désactiver les mip maps
Compression RGBA 32 bit (« True color with alpha »)
Dimensions = puissance de 2

- Scaling :
- 1 pixel = 1 unité de distance
Rendu – Dynamic Lighting/Shadows
Eclairage dynamique => scène 3D

Scène 3D + Pixel perfect => angle de la caméra spécifique
cos(60°) = ½
sin(60°) = 0,866

=>

scale.y = 2
scale.z = 1,155

(1 / ½)
(1 / 0,866)

yx2
Rendu – Dynamic Lighting/Shadows
y

60°
z
Rendu – Dynamic Lighting/Shadows
yx2

x

z x 1,155
Rendu – Dynamic Lighting/Shadows
Caméra orthographique => Forward rendering
« Yes, it's an unfortunate performance choice we had to do - deferred does not
work with orthographic cameras. »
- Aras (Unity3D Lead Graphics Programmer)

Forward rendering => pas d’ombres dynamiques
« Forward Rendering supports one directional light with shadows »
- Unity3D Documentation
Rendu – Dynamic Lighting/Shadows
Solution #1 : tricher
-

Caméra perspective
Field of view proche de 0° (min = 1)
Caméra placée très loin de la scène (vraiment très loin)
« Far clipping » très élevé

Résultat :
-

80% pixel perfect (lignes verticales… ou pas)
Nombreux bugs graphiques (« erreurs de flottant »)
Rendu – Dynamic Lighting/Shadows
Solution #2 : forcer la main au shader
« fullforwardshadows - Support all shadow types in Forward rendering path »
- Unity3D Documentation
#pragma surface surf Lambert fullforwardshadows

Résultat :
-

99% pixel perfect (angle de caméra => « erreurs de flottant »)
Rendu – Transparence et z-index
Shader transparent => z-index aléatoire
« Using transparent objects in your game can be tricky, as there are traditional
graphical programming problems that can present sorting issues in your game »
- Unity3D Documentation
Rendu – Transparence et z-index
Solution #1 : render queue index
private void Awake()
{
// Transparent + 1
this.renderer.sharedMaterial.renderQueue = 3001;
}

Résultat :
-

Difficile à maintenir
Un material par index (plus de draw calls)
Insuffisant dans certains cas particuliers de level design
Rendu – Transparence et z-index
Solution #2 : utiliser les shaders cutout
« The graphical sorting problems normally associated with Transparent shaders do
not occur when using this shader »
- Unity3D Documentation

Résultat :
-

L’altitude (y) des objets est bien prise en compte
Impossible d’utiliser la semi-transparence dans les textures (dégradés 0 -> 1)
Rendu – Bump Mapping

+

=

Réf. : « Legend of Dungeon - Dynamic Lighting on Sprites » http://goo.gl/hpYQFd
Rendu – Bump Mapping
Meetup Unity 3D #5
Dungeon of the Endless
Présentation

Rendu

Génération

Conclusion
Génération – Concept
Objectifs
- Infinité de combinaisons possibles
- « Maitriser l’aléatoire »

Génération semi-procédurale
- Design manuel « haut niveau »
- Concept générique = s’applique à tous les niveaux de détail (donjons, salles, props, etc)
- Extensible à volonté
Génération – Les données
Type = catégorie de contenu

Template

Ex : donjon, petite/grand salle, props pour mur/sol

> Type
> Tags[]
> Design graphique
> Design gameplay
> Slots[]

Template = contenu
Ex : contenu d’un donjon, contenu d’un petite salle
Peut contenir des slots!

Slot = emplacement clé
Ex : emplacement réservé à une petite salle dans un donjon

Tag = contrainte de génération
Ex : un slot taggé « niveau 1 » ne pourra être remplacé que par un
template taggé « niveau 1 »

Slot
> Type
> Tags[]
Génération – Exemple de templates
Donjon v1
Salle
Salle
Salle

Salle

Donjon v2

Salle

Salle

Salle
Salle

Salle

Salle

Salle

Salle

Salle

Salle

Salle

Donjon v3
Salle

Donjon v4
Salle

Salle

Salle
Salle

Salle
Salle

Salle

Salle
Salle

Salle

Salle

Salle

Salle

Salle

Salle

Salle

Salle

Salle

Salle
Génération – Exemple de templates
Salle v1

Salle v2
Props

Props

Props

Props

Props
Gros
Props

Salle v3
Props

Props

Salle v4
Props
Props

Gros
Props

Gros
Props

Props
Gros
Props
Props
Génération – L’algorithme
// Tant qu’il y a des slots à remplacer
while (slots.Count > 0)
{

// Sortir un slot de la liste
slot = slots.GetRandom();
slots.Remove(slot);

// Piocher au hazard un template du même type respectant les contraintes (tags)
template = templates.GetRandomTemplateMatching(slot.type, slot.tags);

// Remplacer le slot par ce template
templateInstance = Instantiate(template, slot.position, slot.rotation);
Destroy(slot);

// Ajouter les (éventuels) slots contenus dans le template à la liste
slots.AddRange(templateInstance.Slots);
}
Génération – Exemple de génération

Donjon
Génération – Exemple de génération
Donjon v3
Salle

Salle
Salle

Salle

Salle

Salle
Salle

Salle
Génération – Exemple de génération

Salle v4 Salle v1

Salle v3
Salle v2

Salle v2

Salle v2

Salle v1
Salle v3
Génération – Exemple de génération

etc...
Meetup Unity 3D #5
Dungeon of the Endless
Présentation

Rendu

Génération

Conclusion
Conclusion – Unity3D
Unity3D
Excellent outil de prototypage
Idéal pour le développement itératif

Unity2D (4.3)
Sprite Editor -> utilisé pour le découpage de nos sprite sheets de décors
Animation de sprites -> solution in-house tant que les shaders « sprite » ne supporteront
pas le shadow casting
Contact
Sébastien Dubois
Lead programmer Unity3D
sdubois@amplitude-studios.com
@GFX47

Dungeon of the Endless
store.steampowered.com/app/249050
Meetup Unity 3D #5
Dungeon of the Endless
Annexes – Pixel Perfect
Le problème « Half-Pixel VS Half-Texel » (DirectX9)

Réf. : « Understanding Half-Pixel and Half-Texel Offsets » http://goo.gl/xkwPlz

Meetup unity#5 dungeonoftheendless (1)

  • 1.
    Meetup Unity 3D#5 Dungeon of the Endless
  • 2.
    Hello world! Sébastien Dubois Leadprogrammer Unity3D sdubois@amplitude-studios.com @GFX47
  • 3.
    Meetup Unity 3D#5 Dungeon of the Endless Présentation Rendu Génération Conclusion
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
    Présentation – Dungeonof the Endless Réf. : « Dungeon of the Endless – Early Access Trailer » http://goo.gl/y0WsVI
  • 10.
  • 11.
    Présentation – Dungeonof the Endless Michaël BREYTON Simon Perin Associate producer Pixel Artist Arthur Prudent Sébastien Dubois Game Designer Lead programmer
  • 12.
    Présentation – Dungeonof the Endless Game Design Playtests Implémentation QA / VIP Public
  • 13.
    Présentation – Dungeonof the Endless Début (avril 2013) … Early access Steam (décembre 2013) + 1 update / 2 semaines … Bêta (??/??/2014) … Gold (??/??/2014) o/ Réf. : « Dungeon of the Endless - Steam » store.steampowered.com/app/249050
  • 14.
    Meetup Unity 3D#5 Dungeon of the Endless Présentation Rendu Génération Conclusion
  • 15.
    Rendu – PixelPerfect - Caméra : - Type orthographique - « orthographic size » = hauteur d’écran (pixels) / 2 - Textures : - Filtre « point » Désactiver les mip maps Compression RGBA 32 bit (« True color with alpha ») Dimensions = puissance de 2 - Scaling : - 1 pixel = 1 unité de distance
  • 16.
    Rendu – DynamicLighting/Shadows Eclairage dynamique => scène 3D Scène 3D + Pixel perfect => angle de la caméra spécifique cos(60°) = ½ sin(60°) = 0,866 => scale.y = 2 scale.z = 1,155 (1 / ½) (1 / 0,866) yx2
  • 17.
    Rendu – DynamicLighting/Shadows y 60° z
  • 18.
    Rendu – DynamicLighting/Shadows yx2 x z x 1,155
  • 19.
    Rendu – DynamicLighting/Shadows Caméra orthographique => Forward rendering « Yes, it's an unfortunate performance choice we had to do - deferred does not work with orthographic cameras. » - Aras (Unity3D Lead Graphics Programmer) Forward rendering => pas d’ombres dynamiques « Forward Rendering supports one directional light with shadows » - Unity3D Documentation
  • 20.
    Rendu – DynamicLighting/Shadows Solution #1 : tricher - Caméra perspective Field of view proche de 0° (min = 1) Caméra placée très loin de la scène (vraiment très loin) « Far clipping » très élevé Résultat : - 80% pixel perfect (lignes verticales… ou pas) Nombreux bugs graphiques (« erreurs de flottant »)
  • 21.
    Rendu – DynamicLighting/Shadows Solution #2 : forcer la main au shader « fullforwardshadows - Support all shadow types in Forward rendering path » - Unity3D Documentation #pragma surface surf Lambert fullforwardshadows Résultat : - 99% pixel perfect (angle de caméra => « erreurs de flottant »)
  • 22.
    Rendu – Transparenceet z-index Shader transparent => z-index aléatoire « Using transparent objects in your game can be tricky, as there are traditional graphical programming problems that can present sorting issues in your game » - Unity3D Documentation
  • 23.
    Rendu – Transparenceet z-index Solution #1 : render queue index private void Awake() { // Transparent + 1 this.renderer.sharedMaterial.renderQueue = 3001; } Résultat : - Difficile à maintenir Un material par index (plus de draw calls) Insuffisant dans certains cas particuliers de level design
  • 24.
    Rendu – Transparenceet z-index Solution #2 : utiliser les shaders cutout « The graphical sorting problems normally associated with Transparent shaders do not occur when using this shader » - Unity3D Documentation Résultat : - L’altitude (y) des objets est bien prise en compte Impossible d’utiliser la semi-transparence dans les textures (dégradés 0 -> 1)
  • 25.
    Rendu – BumpMapping + = Réf. : « Legend of Dungeon - Dynamic Lighting on Sprites » http://goo.gl/hpYQFd
  • 26.
  • 27.
    Meetup Unity 3D#5 Dungeon of the Endless Présentation Rendu Génération Conclusion
  • 28.
    Génération – Concept Objectifs -Infinité de combinaisons possibles - « Maitriser l’aléatoire » Génération semi-procédurale - Design manuel « haut niveau » - Concept générique = s’applique à tous les niveaux de détail (donjons, salles, props, etc) - Extensible à volonté
  • 29.
    Génération – Lesdonnées Type = catégorie de contenu Template Ex : donjon, petite/grand salle, props pour mur/sol > Type > Tags[] > Design graphique > Design gameplay > Slots[] Template = contenu Ex : contenu d’un donjon, contenu d’un petite salle Peut contenir des slots! Slot = emplacement clé Ex : emplacement réservé à une petite salle dans un donjon Tag = contrainte de génération Ex : un slot taggé « niveau 1 » ne pourra être remplacé que par un template taggé « niveau 1 » Slot > Type > Tags[]
  • 30.
    Génération – Exemplede templates Donjon v1 Salle Salle Salle Salle Donjon v2 Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Donjon v3 Salle Donjon v4 Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle Salle
  • 31.
    Génération – Exemplede templates Salle v1 Salle v2 Props Props Props Props Props Gros Props Salle v3 Props Props Salle v4 Props Props Gros Props Gros Props Props Gros Props Props
  • 32.
    Génération – L’algorithme //Tant qu’il y a des slots à remplacer while (slots.Count > 0) { // Sortir un slot de la liste slot = slots.GetRandom(); slots.Remove(slot); // Piocher au hazard un template du même type respectant les contraintes (tags) template = templates.GetRandomTemplateMatching(slot.type, slot.tags); // Remplacer le slot par ce template templateInstance = Instantiate(template, slot.position, slot.rotation); Destroy(slot); // Ajouter les (éventuels) slots contenus dans le template à la liste slots.AddRange(templateInstance.Slots); }
  • 33.
    Génération – Exemplede génération Donjon
  • 34.
    Génération – Exemplede génération Donjon v3 Salle Salle Salle Salle Salle Salle Salle Salle
  • 35.
    Génération – Exemplede génération Salle v4 Salle v1 Salle v3 Salle v2 Salle v2 Salle v2 Salle v1 Salle v3
  • 36.
    Génération – Exemplede génération etc...
  • 37.
    Meetup Unity 3D#5 Dungeon of the Endless Présentation Rendu Génération Conclusion
  • 38.
    Conclusion – Unity3D Unity3D Excellentoutil de prototypage Idéal pour le développement itératif Unity2D (4.3) Sprite Editor -> utilisé pour le découpage de nos sprite sheets de décors Animation de sprites -> solution in-house tant que les shaders « sprite » ne supporteront pas le shadow casting
  • 39.
    Contact Sébastien Dubois Lead programmerUnity3D sdubois@amplitude-studios.com @GFX47 Dungeon of the Endless store.steampowered.com/app/249050
  • 40.
    Meetup Unity 3D#5 Dungeon of the Endless
  • 41.
    Annexes – PixelPerfect Le problème « Half-Pixel VS Half-Texel » (DirectX9) Réf. : « Understanding Half-Pixel and Half-Texel Offsets » http://goo.gl/xkwPlz