Share
Embed
Transcript
175 slides
-
Как мы делали многопользовательскую браузерную игру для HL++ с воксельной
графикой Александр Хаёров / Unit Manager / t.me/hayorov -
Who Are Indie Game Developers? Source: somewhere from the Internet
Indie is a shortform of "independent" -
Who Are Indie Game Developers? 97% men Source: somewhere from
the Internet Indie is a shortform of "independent" -
Who Are Indie Game Developers? 97% men 60% singles Source:
somewhere from the Internet Indie is a shortform of "independent" -
Who Are Indie Game Developers? 97% men 60% singles 1-3
months/game Source: somewhere from the Internet Indie is a shortform of "independent" -
Who We Are Alex Khaerov a Unit Manager at Ingram
Micro Cloud -
Who We Are and the Great Team of Engineers Alex
Khaerov a Unit Manager at Ingram Micro Cloud -
Who We Are and the Great Team of Engineers @themaxbelov
@ToxicWar @weglov @spukst3r Alex Khaerov a Unit Manager at Ingram Micro Cloud -
Who We Are @themaxbelov @ToxicWar @weglov and the Great Team
of voxel jedis, optimisation masters, gurus of the 3d, lords of the big data @spukst3r Alex Khaerov a Unit Manager at Ingram Micro Cloud -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min a social experiment by Reddit -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min 72 hours of fun a social experiment by Reddit -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min 72 hours of fun a social experiment by Reddit -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min 72 hours of fun a social experiment by Reddit -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min 72 hours of fun > 1M players a social experiment by Reddit -
/r/Place 1,000 x 1,000 px canvas pixel * user per
5 min 72 hours of fun > 1M players a social experiment by Reddit 90K simultaneously -
Background Exhibition stand at HL++2017 Reddit r/Place influence Games are
full of fun A new dev experience -
multi-player 2D 3D computer graphics hyped tech Features multi-player and
networked The Game -
multi-player 2D 3D computer graphics hyped Virtual Reality tech Features
multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech Features multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Browser Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Browser voxel “block-style” objects Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Browser voxel “block-style” objects Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Browser voxel “block-style” objects Features Concessions multi-player and networked The Game -
multi-player 2D computer graphics 2D 3D computer graphics hyped tech
hyped Virtual Reality tech client-based Browser voxel “block-style” objects Features Concessions world size 1000x1000x200 multi-player and networked The Game -
Gameplay and rules capture flags hold and earn scores find
spots with the flag -
Gameplay and rules capture flags hold and earn scores find
spots with the flag win a prize -
Active Passive + Easy to understand + More efficient -
Fragile Replication problem -
Active Passive + Robust to de-sync + Easy to understand
+ More efficient - Fragile Replication problem -
Active Passive + Robust to de-sync + Easy to understand
+ More efficient - Fragile + Easier to secure Replication problem -
Active Passive + Robust to de-sync + Easy to understand
+ More efficient - Fragile - Single point of failure + Easier to secure Replication problem -
Active Passive + Robust to de-sync + Easy to understand
+ More efficient - Fragile - Single point of failure + Easier to secure ✔ Replication problem -
“flat array” + read/write = const - memory = L^3
Data Structure -
“flat array” octree + read/write = const - memory =
L^3 Data Structure -
“flat array” octree + read/write = const - memory =
L^3 Data Structure -
“flat array” octree + read/write = const - memory =
L^3 Data Structure -
“flat array” octree + read/write = const - memory =
L^3 + lean Data Structure -
“flat array” octree + read/write = const - slower than
flat - memory = L^3 + lean Data Structure -
“flat array” octree pages/chunks + read/write = const - slower
than flat - memory = L^3 + lean Data Structure -
“flat array” octree pages/chunks + read/write = const + lazily
initialized - slower than flat - memory = L^3 + lean Data Structure -
“flat array” octree pages/chunks + read/write = const + lazily
initialized - slower than flat - memory = L^3 + lean - more complicated Data Structure -
“flat array” octree + Read/Write = const + lazily initialized
- slower than flat - Memory = L^3 + lean - more complicated Data Structure pages/chunks -
“flat array” octree + Read/Write = const + lazily initialized
- slower than flat - Memory = L^3 + lean - more complicated Data Structure pages/chunks ✔ -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) set(x, y, z) r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) set(x, y, z) r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) set(x, y, z) r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend updated() (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) set(x, y, z) r -
Protocol 1 2 3 … N 32 32 game-frontend mongoDB
> data (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object (3) ObjectId() { 7 fields } Object (4) ObjectId() { 7 fields } Object (5) ObjectId() { 7 fields } Object (6) ObjectId() { 7 fields } Object (7) ObjectId() { 7 fields } Object (8) ObjectId() { 7 fields } Object game-backend updated() (1) ObjectId() { 7 fields } Object (2) ObjectId() { 7 fields } Object userActivity() “{Username} joined the game” String { "_id" : ObjectId(), "x" : 435, "y" : 377, "z" : 0, “color" : "#5b8c9c", "name" : null, "updated" : ISODate() } get(x, y, z, r) set(x, y, z) r -
Game-backend Python 3.6 + aiohttp uvloop implemented in Cython and
uses libuv motor full-featured, non-blocking MongoDB driver for Python -
Game-backend Python 3.6 + aiohttp uvloop implemented in Cython and
uses libuv motor full-featured, non-blocking MongoDB driver for Python gunicorn Python WSGI HTTP Server for UNIX -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks AABB: Bounding volume -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks AABB: Bounding volume A 3D model with its bounding box drawn in dashed lines. -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks AABB: Bounding volume -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting AABB: Bounding volume -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting AABB: Bounding volume Ray casting -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting AABB: Bounding volume -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting AABB: Bounding volume Textures -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting AABB: Bounding volume player with controls Textures -
Game-frontend Native JavaScript and WebGL? Native JavaScript and WebGL? Voxel.js
an open source voxel game building toolkit for modern web browsers a-la minecraft world (X, Y, Z) voxels (blocks) / chunks Ray casting game events (tick/setBlock/collision/renderChunk) AABB: Bounding volume player with controls Textures -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Game-frontend voxel.js your code three.js WebGL Browser Hardware OpenGL Driver
Display Mngt System Creating the scene var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); function animate() { requestAnimationFrame( animate ); renderer.render( scene, camera ); } -
Oculus Rift + resolution and refresh rate + it’s true
VR + very comfortable -
Oculus Rift - too numerous wires + resolution and refresh
rate + it’s true VR + very comfortable -
Oculus Rift - no SDK for macOS/Linux - too numerous
wires + resolution and refresh rate + it’s true VR + very comfortable -
Oculus Rift - no SDK for macOS/Linux - NVIDIA GTX
970 / AMD 290 + - too numerous wires + resolution and refresh rate + it’s true VR + very comfortable -
A-Frame virtual reality framework works on Vive, Rift, Daydream, GearVR,
desktop based on top of HTML -
A-Frame virtual reality framework works on Vive, Rift, Daydream, GearVR,
desktop based on top of HTML <html> <head> <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> </head> <body> <a-scene> <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box> <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane> <a-sky color="#ECECEC"></a-sky> </a-scene> </body> </html> -
A-Frame virtual reality framework works on Vive, Rift, Daydream, GearVR,
desktop based on top of HTML <html> <head> <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> </head> <body> <a-scene> <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box> <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane> <a-sky color="#ECECEC"></a-sky> </a-scene> </body> </html> -
Optimizations Use Mesher FPS ↑ Enable compression for WebSocket (RFC
7692) Traffic ↓ (5MB -> 1.8MB) Pre-process voxel models Voxels count ↓ (-78%)