2017年最佳实时培训:对象池,着色器编写和粒子展开

This year has been a great year for us in Online Evangelism and next year is shaping up to be even better (and busier!). Coming into the end of the year I thought it might be a good time to take a look back and pick out some of my favorite content which I created for our Live Training series, in case there were sessions that anyone missed.

今年对我们来说是网上福音的重要一年,明年将变得更好(也更忙!)。 到今年年底,我认为现在是回顾和挑选我为现场培训系列创作的一些我最喜欢的内容的好时机,以防万一有人错过了课程。

Maybe you’ve got some time over the holidays to try out some new prototype ideas, or you’re looking for a solution for an existing project. My goal here is to share a selection of training material to educate and inspire you to take your game making to the next level.

也许您在假期中有一些时间尝试一些新的原型创意,或者您正在寻找现有项目的解决方案。 我在这里的目标是分享一些培训材料,以教育和启发您将您的游戏制作提高到一个新的水平。

蓬松鸟中的对象合并 (Object Pooling In Flappy Bird)

The first session I’d like to highlight is my session on making a Flappy Bird style game. This is a beginner friendly session for folks who have done some of the most basic Unity tutorials, like for example our 2D UFO series, and are ready to add a few concepts to their toolbox. The key areas of focus for this training were on object pooling, creating the illusion of movement by moving the world instead of the player, and creating ‘cartoon’ or unrealistic 2D physics.

我要强调的第一节是关于制作《飞鸟》风格游戏的会议。 对于那些已经完成了一些最基本的Unity教程(例如我们的2D UFO系列 )并准备在其工具箱中添加一些概念的人们来说,这是一个适合初学者的课程。 此次培训的重点重点是对象池,通过移动世界而不是玩家来创建运动的幻觉,以及创建“卡通”或不现实的2D物理。

I think the object pool concept is probably the one with the broadest possible application to many projects. Object pooling, for those who are unfamiliar, is basically recycling for GameObjects. It becomes especially important and useful in games that feature many individual objects, which are created and destroyed over time. The purpose of an object pool is to make this process performant with regard to memory usage, and specifically, garbage collection. Basically, every time you instantiate or destroy an object you create work for the garbage collection system, called an allocation. After a certain number of allocations have occurred, the garbage collector has to run. When it does, you can see a momentary and significant drop in your game’s framerate, which feels like a glitch or short freeze. This is obviously a short, simple explanation of this concept. For some great further reading on the topic of performance, I highly recommend my colleague Kerry Turner’s excellent articles on the subject, including one specifically on garbage collection, in the Performance Optimization section of the Unity Learn site.

我认为对象池的概念可能是在许多项目中应用最广泛的概念。 对于不熟悉的对象,对象池基本上是在回收GameObjects。 它在具有许多单独对象的游戏中变得尤为重要和有用,这些对象随着时间的流逝而被创建和销毁。 对象池的目的是使此过程在内存使用方面(特别是在垃圾回收方面)具有高性能。 基本上,每次实例化或销毁对象时,都会为垃圾回收系统创建工作,称为分配。 在发生一定数量的分配后,必须运行垃圾收集器。 当出现这种情况时,您会看到游戏帧速率出现短暂而显着的下降,这感觉就像是故障或短暂的冻结。 显然,这是对此概念的简短说明。 要获得有关性能主题的更多精彩读物,我强烈推荐我的同事Kerry Turner在该主题上的出色文章,其中包括一篇专门关于垃圾回收的文章,位于Unity Learn网站的Performance Optimization部分。

Clearly we don’t want this to happen during gameplay, and so a way to avoid this is to not instantiate or destroy objects while the game is running. Instead, we spawn a pool of objects which are initially out of view or inactive. Then, when we need an object, for example a bullet or explosion in a shooter game, we request one from the pool. When we’re done with that object, we turn it back off and move it out of view, ready to be used again. In the linked training, we use this technique for the endless series of columns that the player flaps past.

显然,我们不希望这种情况在游戏过程中发生,因此避免这种情况的一种方法是在游戏运行时不要实例化或销毁对象。 取而代之的是,我们生成了最初看不见或不活动的对象池。 然后,当我们需要一个物体(例如射击游戏中的子弹或爆炸物)时,我们从池中请求一个物体。 处理完该对象后,我们将其关闭并移出视线,以备再次使用。 在链接训练中,我们将这种技术用于玩家挥动的无尽列。

演示地址

While we’re briefly talking about performance optimization, you also might enjoy checking out a talk on the subject of Performance Optimization For Beginners that Kerry and I gave at Unite Amsterdam 2017.

在我们简短地讨论性能优化的同时,您也可能会喜欢Kerry和我在Unite Amsterdam 2017上进行的有关针对初学者性能优化的主题。

初看着色器 (A First Look At Shaders)

One frequent, ongoing request we had from our live training community, those who join us live on Twitch and those who watch our content on YouTube, was for some training around writing your own shaders in Unity. This was a slightly scary topic for me as a trainer, since before doing the session it wasn’t something I had done before. However! The audience had spoken, and so I hit the books in an attempt to learn enough to talk for an hour without sounding like a fool or saying something terribly, terribly wrong. I stood on the shoulders of giants, and had some great research material to work from, with extra special thanks going out to the creators of the material linked in this twitter thread.

我们的实时培训社区,在Twitch上实时加入我们的人们和在YouTube上观看我们内容的人们经常提出的一项持续要求是接受一些有关在Unity中编写自己的着色器的培训。 作为培训师,这对于我来说是一个有点恐怖的话题,因为在进行本次培训之前,这不是我以前做过的事情。 然而! 听众说过话,所以我打了书,试图学到足够一个小时的说话时间,但听上去不是傻瓜,也不是说出非常可怕的话。 我站在巨人的肩膀上,准备了一些出色的研究材料,特别感谢在Twitter主题中链接的材料的创建者。

You may have heard the term shader bandied around, but basically, a shader is a program that is used to determine how things are rendered in computer graphics. Shaders are amazing and fun, and in the end were not as hard as I feared they would be to learn. The super cool thing about shaders is that they allow you to achieve graphical effects that you really can’t achieve any other way. By learning to write your own shaders, you can begin to create truly unique and novel visual effects for your games, and make them stand out from the crowd.

您可能已经听说过“ shader”一词,但基本上,shader是用于确定计算机图形中事物呈现方式的程序。 着色器既有趣又有趣,最后我不像我担心的那样辛苦学习。 着色器的超酷之处在于它们使您可以实现图形效果,而这些效果是您真正无法实现的。 通过学习编写自己的着色器,您可以开始为游戏创建真正独特和新颖的视觉效果,并使它们在人群中脱颖而出。

In this training I walk through writing your first shader, hence the title Writing Your First Shader In Unity. I assume no prior in-depth knowledge of 3D rendering or shader coding and attempt to walk you through the process in an approachable way.

在本培训中,我将逐步编写您的第一个着色器,因此标题为“在Unity中编写您的第一个着色器”。 我假设以前没有3D渲染或着色器编码的深入知识,并试图以一种可亲近的方式引导您完成整个过程。

演示地址

粒子碰撞和贴图渲染 (Particle Collisions and Decal Rendering)

The third training that I’d like to share with you is a bit more on the advanced side. That being said, if you know some C# scripting fundamentals, the training takes you step by step through the process, so don’t be put off. The title of the training is Controlling Particles Via Script. Frankly, this is a terrible, deeply boring title, which I think makes the session sound less cool than it is, but it’s what I could come up with at the time . ¯\_(ツ)_/¯

我想与您分享的第三项培训是在高级方面。 话虽如此,如果您了解一些C#脚本基础知识,那么培训将带您逐步完成该过程,因此不要耽搁。 培训的标题是“通过脚本控制粒子”。 坦率地说,这是一个可怕的,无聊的标题,我认为这会使会议听起来不那么酷,但这是我当时能想到的。 ¯\ _(ツ)_ /¯

After going through the training, you’ll be able to create a particle based decal system that allows you to fire particles into the scene and use them to ‘paint’ surfaces in your level in a performant way. For all you optimization nerds, you can paint thousands of decals all over the scene, and because it’s a particle system, they all get drawn in a single SetPass call or draw call. Yes, this is the kind of stuff I get excited about. Yes, I am a giant nerd.

完成培训后,您将能够创建基于粒子的贴花系统,该系统可以将粒子发射到场景中,并以高性能的方式使用它们“绘制”您的关卡中的曲面。 对于所有优化书呆子,您可以在整个场景中绘制成千上万的贴花,并且由于它是一个粒子系统,因此它们都可以在一个SetPass调用或draw调用中绘制。 是的,这是令我兴奋的事情。 是的,我是个大书呆子。

Most people think of particles in a fairly limited sense, as being useful for creating little animated sparkles and juice effects. The fact is that Unity’s particle system has tons of cool functionality in it, including the ability to detect collisions, return data based on those collisions, and dynamically render thousands of images in whatever configuration you define via code in a super performant way. In this training I show you how to create a gun that shoots particle bullets, and then execute code based on what was hit. This is a technique I was inspired to check out after hearing that top-down shooter game Assault Android Cactus (which has TONS of bullets on screen at a time) used Unity’s particle system for their core shooting system. My initial goal was to just shoot a particle at something, and then run some code, but once I got going I figured out that not only could I use particles in this way, but that I could use a second particle system to display the resulting splat decals, controlling everything via C# script. I had a ton of fun programming this one, and also splatting paint all over the place is super fun. I think someone made a game about that… Splat-something.

大多数人认为粒子在相当有限的意义上对创建微小的动画火花和果汁效果很有用。 事实是,Unity的粒子系统具有大量出色的功能,其中包括检测碰撞,基于这些碰撞返回数据以及以超级性能方式通过代码定义的任何配置动态渲染数千张图像的能力。 在本培训中,我将向您展示如何创建一种发射粒子子弹的枪,然后根据所击中的内容执行代码。 在听到自上而下的射击游戏《突击Android仙人掌》(一次在屏幕上显示大量子弹)将Unity的粒子系统用作其核心射击系统后,我被启发去检查这项技术。 我最初的目标是只在某个地方拍摄一个粒子,然后运行一些代码,但是一旦我知道了,我不仅可以以这种方式使用粒子,而且可以使用另一个粒子系统来显示结果splat贴花,通过C#脚本控制所有内容。 我对此编程非常有趣,而且在各处喷涂颜料非常有趣。 我认为有人为此创造了一个游戏……有些东西。

演示地址

I hope that you’ve learned something and found something useful for your own projects in this end of year round-up. If you’ve never been to one of our live sessions, I’d love to see you there! You get to learn awesome content like this AND ask questions in real-time via Twitch chat. I also usually make some hilarious, dumb mistakes, and we all get a lot of laughs at my expense. We’re live on Twitch every two weeks, and you can check out the schedule here.

我希望您在本年度末的总结中学到了一些东西,并为自己的项目找到了有用的东西。 如果您从未去过我们的现场会议之一,我很乐意在那见到您! 您可以学习类似这样的精彩内容,并通过Twitch聊天实时提出问题。 我通常也会犯一些有趣的,愚蠢的错误,而我们所有人都为此付出了很多笑声。 我们每两周在Twitch直播一次,您可以在此处查看时间表。

What is a cool technique that you learned in 2017? Let me know in the comments!

您在2017年学到了什么很酷的技术? 在评论中让我知道!

翻译自: https://blogs.unity3d.com/2017/12/16/best-live-trainings-of-2017-object-pooling-shader-writing-and-particle-splatting/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值