3D游戏引擎Unity的开发团队近日将该引擎的版本更新至了Unity 4.1,新版本修复了先前版本的大量Bug并新增了内存分析器(Memory Profiler),以帮助开发人员提高工作效率。
Unity引擎目前在全球拥有超过150万用户 是一个用于创建诸如3D游戏、建筑可视化、实时三维动画等互动内容的综合型创作工具,目前全球拥有用户数超过150万。Unity团队成员Thomas Petersen在官方博客中表示,过去的4.0和3.5版本发行周期较长,更新速度相对缓慢。而今年Unity团队决定缩短新版本的发行周期,在此次更新后,开发者将继续见到4.2、4.3以及4.4的新版本产品。Unity也将继续致力于打造高质量的游戏开发引擎。
内存分析器(Memory Profiler)用户界面 内存分析器(Memory Profiler)是一款强大的分析工具,引入它的主要目的是为开发人员提供更具体、更准确的游戏性能方面的信息。 旧版Unity中的内存分析工具虽然能够判断游戏动画的内存占用量,但是无法做到动态更新。而新版的内存分析器能够实时、动态地显示游戏中不同动画、不同物体的内存占用情况,通过这种方式,开发人员能够获知更加精准的内存使用情况。 在Unity引擎中,一些内部系统是相当占内存的,如:Shader Lab以及一些内部文件缓存。当游戏在编辑器上运行时,开发人员可以通过内存分析器看到这些内部系统对于内存占用所造成的影响。 此外,Unity 4.1版本在图形的着色和渲染方面有了大幅度的提升,详情可参考其原文描述: Lit Shader Replace So up to and including Unity 4.0 you have been able to do some pretty cool post processing and other things with shader replacement, but it’s always been a bit limiting, you could not have your whole scene be rendered with a different set of shaders and also include lighting. In Unity 4.1 we have made changes to how this works. Now when you use shader replacement lighting will also be calculated (if the shader you are providing supports lighting). The render path for the camera you are using for the rendering of the shader replacement will be selected (so you can use forward / deferred or vertex lit). Using lit shader replace you can write some pretty nifty effects and tools. To show an example of what can be achieved I decided to implement a view mode in the editor that shows ‘lighting only’ this is a pretty handy tool for lighting artists to debug their scene lighting and lightmaps.
Original Scene
Lighting Only
So how does it work? If you check out the Editor Script in the LightingOnly folder you will see that there is a new menu “LightingOnly” with two options. When this is called we render scene view with a replacement shader. The shader was written pretty quickly and does not cover every rendering eventuality (i.e. does not do trees & grass / if you have your own rendertype tags in the shader you will need to write a lighting only shader for them). But it gives an idea of the kind of things you can do. You can use lit shader replace to show a lot of cool things in the scene view. In addition to the scene view script there is another script ‘LightingOnlyCamera’. If you put this on the camera then it will use shader replace to render the game view. You could do many interesting effects with this. Custom Material Inspectors / Per Shader Keywords For a long time you have been able to specify shader keywords using the ‘Shader.EnableKeyword’ and ‘Shader.DisableKeyword’ this worked on a global level and would set keywords for all shaders. This isn’t really what you want all the time though. In Unity 4.1 we have added per material keywords. What this means is that you can specify keywords on a per material level. So you can have one shader that uses one or two textures and select the combination you want from a material inspector (or from scripting)! To do this you will need to extend the material inspector. If you open the shader ‘MyShader’ in the example project you will see there is a new field ‘CustomEditor’ this has the name of a C# class that will be used for the inspector. If you open up this class you will see that it extends from MaterialEditor. On the material you can simply set the keywords by passing them as a string array to the shaderKeywords property of the material. At some stage in the future we think it makes sense to convert Unity’s built in materials to be more like this so we don’t have a large number of shaders on the back end, but instead have some nice defines for enabling normal mapping and the like and a sexy inspector for them. Not sure when we will get around to this though.
One shader with defines for Texture1 And Texture2
|