meetup unity#5 dungeonoftheendless (1)

41
Meetup Unity 3D #5 Dungeon of the Endless

Upload: bemyapp

Post on 22-Nov-2014

472 views

Category:

Technology


3 download

DESCRIPTION

Meetup Unity 3D du 18/02/2014

TRANSCRIPT

Page 1: Meetup unity#5 dungeonoftheendless (1)

Meetup Unity 3D #5 Dungeon of the Endless

Page 2: Meetup unity#5 dungeonoftheendless (1)

Hello world!

Sébastien Dubois Lead programmer Unity3D [email protected] @GFX47

Page 3: Meetup unity#5 dungeonoftheendless (1)

Présentation Rendu Génération Conclusion

Meetup Unity 3D #5 Dungeon of the Endless

Page 4: Meetup unity#5 dungeonoftheendless (1)

Présentation - Perso

Formation Parcours pro

Page 5: Meetup unity#5 dungeonoftheendless (1)

Présentation – Amplitude Studios

Page 6: Meetup unity#5 dungeonoftheendless (1)

Présentation – Amplitude Studios

Page 7: Meetup unity#5 dungeonoftheendless (1)

Présentation – Amplitude Studios

Page 8: Meetup unity#5 dungeonoftheendless (1)

Présentation – Amplitude Studios

Page 9: Meetup unity#5 dungeonoftheendless (1)

Présentation – Dungeon of the Endless

Réf. : « Dungeon of the Endless – Early Access Trailer » http://goo.gl/y0WsVI

Page 10: Meetup unity#5 dungeonoftheendless (1)

Présentation – Dungeon of the Endless

Page 11: Meetup unity#5 dungeonoftheendless (1)

Présentation – Dungeon of the Endless

Michaël BREYTON Associate producer

Arthur Prudent Game Designer

Simon Perin Pixel Artist

Sébastien Dubois Lead programmer

Page 12: Meetup unity#5 dungeonoftheendless (1)

Présentation – Dungeon of the Endless

Game Design

Playtests Implémentation

QA / VIP

Public

Page 13: Meetup unity#5 dungeonoftheendless (1)

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

Page 14: Meetup unity#5 dungeonoftheendless (1)

Présentation Rendu Génération Conclusion

Meetup Unity 3D #5 Dungeon of the Endless

Page 15: Meetup unity#5 dungeonoftheendless (1)

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

Page 16: Meetup unity#5 dungeonoftheendless (1)

Rendu – Dynamic Lighting/Shadows

Eclairage dynamique => scène 3D Scène 3D + Pixel perfect => angle de la caméra spécifique cos(60°) = ½ => scale.y = 2 (1 / ½) sin(60°) = 0,866 scale.z = 1,155 (1 / 0,866)

y x 2

Page 17: Meetup unity#5 dungeonoftheendless (1)

Rendu – Dynamic Lighting/Shadows

60°

z

y

Page 18: Meetup unity#5 dungeonoftheendless (1)

Rendu – Dynamic Lighting/Shadows

y x 2

x z x 1,155

Page 19: Meetup unity#5 dungeonoftheendless (1)

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

Page 20: Meetup unity#5 dungeonoftheendless (1)

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 »)

Page 21: Meetup unity#5 dungeonoftheendless (1)

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 »)

Page 22: Meetup unity#5 dungeonoftheendless (1)

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

Page 23: Meetup unity#5 dungeonoftheendless (1)

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

Page 24: Meetup unity#5 dungeonoftheendless (1)

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)

Page 25: Meetup unity#5 dungeonoftheendless (1)

Rendu – Bump Mapping

+ =

Réf. : « Legend of Dungeon - Dynamic Lighting on Sprites » http://goo.gl/hpYQFd

Page 26: Meetup unity#5 dungeonoftheendless (1)

Rendu – Bump Mapping

Page 27: Meetup unity#5 dungeonoftheendless (1)

Présentation Rendu Génération Conclusion

Meetup Unity 3D #5 Dungeon of the Endless

Page 28: Meetup unity#5 dungeonoftheendless (1)

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é

Page 29: Meetup unity#5 dungeonoftheendless (1)

Génération – Les données

Type = catégorie de contenu Ex : donjon, petite/grand salle, props pour mur/sol

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 »

Template

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

Slot

> Type > Tags[]

Page 30: Meetup unity#5 dungeonoftheendless (1)

Génération – Exemple de templates

Salle

Donjon v2

Salle

Salle

Salle Salle

Salle

Salle

Donjon v1

Salle

Salle

Salle Salle

Salle

Salle Salle

Salle

Donjon v3

Salle

Salle

Salle Salle

Salle

Salle Salle

Salle

Donjon v4

Salle

Salle

Salle

Salle Salle

Salle

Salle Salle Salle

Salle

Salle

Salle

Page 31: Meetup unity#5 dungeonoftheendless (1)

Génération – Exemple de templates

Salle v1

Props Props

Props

Salle v2

Gros Props

Props

Salle v3

Props Props

Gros Props

Props

Props

Salle v4

Props

Gros Props

Props

Props

Gros Props

Page 32: Meetup unity#5 dungeonoftheendless (1)

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);

}

Page 33: Meetup unity#5 dungeonoftheendless (1)

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

Donjon

Page 34: Meetup unity#5 dungeonoftheendless (1)

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

Salle

Donjon v3

Salle

Salle

Salle Salle

Salle

Salle Salle

Page 35: Meetup unity#5 dungeonoftheendless (1)

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

Salle v2

Salle v1

Salle v3

Salle v2 Salle v2

Salle v3

Salle v4 Salle v1

Page 36: Meetup unity#5 dungeonoftheendless (1)

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

etc...

Page 37: Meetup unity#5 dungeonoftheendless (1)

Présentation Rendu Génération Conclusion

Meetup Unity 3D #5 Dungeon of the Endless

Page 38: Meetup unity#5 dungeonoftheendless (1)

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

Page 39: Meetup unity#5 dungeonoftheendless (1)

Contact

Sébastien Dubois Lead programmer Unity3D [email protected] @GFX47

Dungeon of the Endless store.steampowered.com/app/249050

Page 40: Meetup unity#5 dungeonoftheendless (1)

Meetup Unity 3D #5 Dungeon of the Endless

Page 41: Meetup unity#5 dungeonoftheendless (1)

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