Unity5 怎么把Mesh渲染成unity rendertexturee

天极传媒:天极网全国分站
您现在的位置:
& &&Unity 5 引领开发引擎进入次时代!
Unity 5来了!引擎进入次时代!(附官方说明)天极网游戏频道 10:54
【百万玩家最喜爱的游戏娱乐媒体,把最带劲的娱乐资讯,最权威的游戏推荐,最齐全的手游礼包放进你的口袋,却不用你多***一个APP,还等什么?赶紧就关注微信号 【kdyx91】 每日七点不见不散~】
  Unity Technologies今天宣布:备受期待的次时代多平台引擎开发工具——Unity 5正式发布!这是Unity迄今为止最强大的版本,含有大量的图形改进和扩展的编辑器功能集,让开发者具备跨越21个平台创造出色、创新游戏的潜力。此外,Unity还发布了Unity Cloud Build,这使得开发者能够通过云计算更有效率地进行游戏和的开发。
  为了实现Unity 让开发大众化的长远目标,随着Unity 5的正式发布,我们通过改进授权方式逐步向所有开发者开放了整个引擎和编辑器。这不仅仅对大型工作室或者公司意义重大,也为爱好者和刚起步的开发者平添了巨大力量。Unity 5有两个版本:
  Unity 5 Professional Edition(专业版)
  Unity 5 Professional Edition(专业版)包含了Unity Cloud Build Pro、Team License、Game Performance、Asset Store Level 11、Unity Analytics Pro等功能。无论是2-3人的小型工作室,还是超过100人的大型团队,仅以75美元/月的低价便可获得,从而享受这些更为高效和更有价值的增值功能。
  Unity 5 Personal Edition(个人版)
  Unity 5 Personal Edition(个人版)是一款免费解决方案,为爱好者、独立开发者和刚起步的工作室提供Unity引擎中所有的强大功能和编辑器,如Profiler、Occlusion Culling、Render-to-Texture和Post-Processing Special Effects,以及Unity 5的所有重要功能,如PBS、Enlighten和反射探头。
  Unity首席执行官John Riccitiello表示: “Unity 5是Unity 的重要里程碑,它使开发人员能够制作出更精美绝伦的游戏和应用,在更多的平台触及更多的受众。我们希望每个人都能获得并使用Unity 5,所以我们增加了免费的个人版。Unity 5专业版具备Unity 5.0的基本功能,并增加了拥有增值功能的一些工具,如Unity Cloud Build Pro和Team License。Unity 5个人版是针对刚起步的开发者,并免费提供引擎和编辑器的所有功能。”
  世界各地的开发人员已通过使用Unity 5取得了巨大成功,如Camouflaj最近发布的《Republique Remastered(共和国)》和即将推出的游戏《Ori》,以及Moon Studios的《Blind Forest》和Space Ape的《Rival Kingdoms》。
  Unity 5还添加了重要功能,使开发人员能够跨越任何风格、流派及平台,制作令人叹为观止的视觉效果:
  强大的图形工具
  Unity 5极大地增强了图形功能,如基于物理的阴影、凭借Enlighten的实时全局光和反射探头,使开发人员能够创建震撼的视觉。
  功能丰富且高度灵活的编辑器
  Unity 全面、省时省力、可扩展的编辑器在Unity 5变得更为强大,支持64位,具备前所未有的音频工具,动画系统的重大改善,庞大的物理系统升级,以及更多功能。凭借Unity 5,开发者拥有可任其创造力自由驰骋的能力和灵活性。
  业界领先的多平台支持
  Unity 5业界领先的多平台支持使开发者可跨越21个不同的平台,包括新的WebGL,以及游戏主机、和移动设备。所有的繁复的技术工作都由Unity 承担,您只需要专注创造令人惊叹的游戏或者应用内容即可。
  在云端无与伦比的效率提升
  随着Unity Cloud Build 云功能的发布,Unity性的开发效率达到了新的高度,由此进一步提高了生产力,并使开发者可专注于制作出色的游戏。Unity Cloud Build现已推出,欲了解其详情,请访问/cloudbuild。
  下载:Unity 5 Personal Edition(个人版)和Professional Edition(专业版)今天可在/cn/get-unity立即下载。
  下一页为Unity 5 官方说明文档
1分页导航1.Unity 5来了2.
(作者:官方责任编辑:薛嘉炯)
天极新媒体&最酷科技资讯扫码赢大奖
* 网友发言均非本站立场,本站不在评论栏推荐任何网店、经销商,谨防上当受骗!
数码整机手机软件
砛","channel_href_1":"/"}-->Unity的渲染相关问题?
1. 请问Unity是否至少需要一个相机作为主相机?2. 使用相机的setTargetBuffer方法后,怎么取出colorBuffer中的数据?3. Graphics.SetRenderTarget() 有什么作用?它设置的是什么渲染目标?和设置主相机的渲染目标有什么不同的地方?4. 调用camera.render()进行手动渲染,与自动进行的渲染有什么不同?可否关闭自动渲染?怎么关闭。。。问题有点多,还请各位大牛们不吝赐教,谢谢!
1 maincamera 只是一个打了 tag的camera, 可以没有 ,这样 用到camera.main的代码就会失败例如xffect的代码2:setTargetBuffers 将 rendertexture的buffer设置为相机的渲染对象, 因此要获取buffer数据,需要将 对应的rendertexture 设置为active, 接着调用texture2d 的readpixels可以读取 colorbuffer里面的数据 到 texture2d里面, 参考
如果要读取 depthbuffer里面的数据 参考 参考unity builtin shader 里面关于depthtexture 的shader以及CGInclude 里面的头文件,查看如何获得depthbuffer的数据3:Graphics 是unity的底层API,Camera是Unity的上层API,Camera渲染的是相机自身看到的场景中的物体,而Graphics 直接操作的是 rendertexture,mesh,以及纹理texture,以及GPU生成的几何体这些对象的处理和渲染,
两个操作的对象是不同的,两个API 所处的 游戏引擎 层级也是不同的。4: camera.render 用于手动精确控制 渲染顺序,例如想要对游戏中玩家对象渲染两次,第一次用正常Camera 渲染玩家模型,LateUpdate 函数里面 第二次用相同位置的另外一个camera,手动调用render
再render一边模型。例如想给主角加一个阴影,第二遍可以用replace shader渲染一下人物阴影,接着调整一下阴影的rendertexture的alpha值,接着用于地面混合一下,这样就可以制作出 动态实时 半透明阴影了。只要disable掉 camera组件 就可以 关闭主动渲染。
已有帐号?
无法登录?
社交帐号登录Issue#162985: Unity - Releasing render texture that is set as Camera.targetTexture!
You are concerned by Issue#162985: Unity - Releasing render texture that is set as Camera.targetTexture!, so please do not hesitate to share any informations or solutions, to help people that are looking for assistance to fix it.
I'm getting this error as of the update to 5.3.2p3, where I wasn't getting it in any previous version. Is there some way that I can request that more information be provided with this error? Which rendertexture is being released, what is it its name? What camera is it attached to? What is the stack trace of the method that is releasing it? This error has crippled my builds and I can't track it down.
Sorry, your answer is too short !
Answer now
After upgrading to Unity 5.3.4 we're seeing the error &Releasing render texture that is set to be Camera.targetTexture!& whenever we change anything screen related (resolution, vsync, alt+tab, etc).
There's no stack or useful information whatsoever but it's obviously obliterating our RenderTextures. This has not happened prior to 5.3.4. So far we've worked around it by disabling and screen changes in-game but this is not ideal and does not stop the problem occuring when alt+tabbing....
Releasing render texture that is set to be Camera.targetTexture!
Posting this here as not getting much response in the support forum.
After upgrading to Unity 5.3.4 we're seeing the error &Releasing render texture that is set to be Camera.targetTexture!& whenever we change anything screen related (resolution, vsync, alt+tab, etc).
There's no stack or useful information whatsoever but it's obviously obliterating our RenderTextures. This has not happened prior to 5.3.4. So far we've worked around it by disabling and screen changes in-game but this...
Releasing render texture that is set to be Camera.targetTexture! since 5.3.4
Hello everybody,
I need to capture the screenshot of a canvas, here is my code
Code (CSharp):
void TakeScreenShotF(bool isTakingBeforeChange = true)
& & {
& & & & _normalCanvas.renderMode = RenderMode.ScreenSpaceC
& & & & _normalCanvas.worldCamera = _
& & & & // get the camera's render texture
& & & & RenderTexture rendText = new RenderTexture(Screen.width, Screen.height, 24);
& & & & _camera.targetTexture = rendT
& & & & RenderTexture.active = _camera.targetT...
Camera render texture issue
Releasing render texture that is set to be RenderTexture.active!
RenderTexture warning: Destroying active render texture. Switching to main context.
Does anyone have a good explanation as to why this error is occurring, or how to prevent it? As far as I can tell it doesn't happen in the editor, and this error seems to occur when loading a level that doesn't have a camera which uses a render texture when the previous one did. I've tried releasing the active render texture before loading,...
Standalone only error: Releasing render texture that is set to be RenderTexture.active!
I've written a disposable wrapper for temporary render textures, you can see the code here:
https://bitbucket.org/snippets/Wahooney/oKakz
Any idea why I'm getting this error:
&Attempting to release RenderTexture that were not gotten as a temp buffer&
As you can see in the code, I definitely am creating a temporary texture. Is it a threading/scope thing?
is there any way how to force Camera to render to target texture and the same also to monitor?
any ideas ?
Many thanks.
This is an unexpected behavior for me... I have two cameras in identical spots, one renders to a texture, while the second one renders the scene, and then uses the rendered texture as a full-screen overlay to do some special effects.
I noticed that the elements in the render to texture camera would move normally at run time on the vertical axis of the framebuffer, but that as I change the viewport aspect ratio of the rendering window, the elements move at a rate of change about equal to...
Render to texture forcing aspect ratio change on camera?
I've got an issue with rendering though it does not appear on all Android devices. It's been reported on the HTC 10. My original setup was one perspective camera that rendered background, foreground, and gui. An orthographic camera that renders ui tiles for the player to select. All working fantastic. I then decided to blur the background but not foreground, so my existing perspective camera now renders all layers bar foreground layer. This camera has depth of field and bloom added to it. I...
HTC 10 camera render issue
So I have a minimap that uses a camera projected on a Raw Image using a Render Texture. Everything worked fine until I added this new tree - as you can see, the tree's leaves don't seem to render, and they show up as transparent, so the map has &holes& in it. This is only at the start though, and I can then move around, and the map moves fine and the trees look fine, but these cutouts stay in the same position and never go away. Anyone ever seen anything like this, and have any idea what...
Raw Image / Render Texture tree leaves issue
Is it possible to render Canvas into texture when RenderMode is set to something different than WorldSpace? I can't get it to work.
At first, sorry for my bad at English.
In my 2D game:
- I use an addition Camera(called FxCam) to render all objects of Light layer
- Then I use Camera.targetTexture to get the image from FxCam as TextureMask for MainCam to present lights in game.
- It work pretty good on Windows Build and Editor but only work on Osx Editor. On Osx Build, Camera.targetTexture returns a Black screen, no light object in this one.
Need Help. Thanks so much!!
I have a Render Texture for a mini HUD for the center console of my cockpit. I want a UI to be displayed there so I decided to use the Unity UI interface. The HUD on the center console is via a Render Texture. I used a simple image to test out the scaling and when I move my ship the image flickers in an out of phase.
I tried changing the clipping, and plane distance with no solution. I really need the UI to work on the center console as it is crucial for in-game feedback.
If anyone has...
UI Flicker (Screen Space Overlay -& Render Texture)
I am using render texture to implement mirror reflection. It work fine in editor and non VR mode. But once I build to GearVR with VR mode on, the texture become black. I tried play with Target Eye and GLES versions but nothing works. Any insight?
Image #1 is in non-VR mode, the cube has render texture from a camera which look at the sphere
Image #2, the same scene, just turn on VR mode. the sphere and the plane disappear in render texture...
I need to render four views of the same object from four cameras - off screen basically. I then want to image each cameras view to an image in the canvas. Seems easy enough, just haven't had much luck googling so far.
I've got camera collision sorted for the most part, the only trouble is that you can still peak through walls if you line the camera up so that it's just about to collide with the wall - so in other words, the camera is almost parallel to the wall, It's probably best to take a look at the image to understand what's going on.
In the image, I'm able to peek through a wall with a thickness of 1.
View attachment 172417
I'm raycasting from the player to the camera but of course in...
Camera Collision - Camera FoV issue
So let's assume you were making a 3D remake of &The Legend of Zelda&, meaning that Link traverses the map by going from 'square' to 'square', and when he gets to the edge of a square, the map slides over, and places Link on the opposite side of the screen. (If he was on the left side of the screen, when switching squares, he'd start from the right)
In 3D - The camera is sitting at an angle above and tilted down at the play area (in perspective mode, not ortho, lets assume this...
Is there a way to render a camera to a bounding cube / object?
So I have a container with a grid layout component and a mask. At run time, it's populated with instantiated panels that are children of my container. These panels contain, among other bits, a image component hooked up as a RenderTexture.
My problem is, the mask of the container seems to ignore the RenderTextures in it's children. So, the mask works in that it cuts off other parts of it's children- a normal image, some text etc- but the RenderTexture has not been masked by it's...
Mask Parent of Render Texture
We have a different behavior for IOS-build, which is build using Unity Cloud Build:
Scenario #1
Have 2 cameras:
one for gameobject's, second for UI. Canvas Render mode: Screen space - Camera
No UI-elements is showen when run it on device
Scenario #2
Have 1 camera, and Canvas Renderer mode is Screen Space - Overlay.
All works fine on device.
In editor all scenarios work fine.
Have anyone got ideas?
I am making a game that is based on a mental hospital, you are the person in charge of watching the cameras to make sure the people inside the hospital are safe.
Picture of TVs for Cameras: (Prototype)
View attachment 173598
I am trying to make the view output of each camera on to each of the boxes (6)
Could anyone help me with this?
I do not know wether this is the right thread to post this in or not, moderators can feel free to move if required. I have gotten a simple issue in a few of my scenes and projects, (not all) which makes me unable to get close to objects or it will hit it. Almost like my free camera in editor mode is larger then it is. You know when you go past a object you will eventually go through it and see the other side. This happens when im like 3 metres away from the object. As mentioned, this only...
Editor Camera Issue
Hi. Tried to create renderTexture with type set to Depth and depth buffer set to 24 bit, then creating camera, disabling it, seting renderTexture as camera's target texture and then calling Render() and RenderWithShader(Shader.Find(&Hidden/Camera-DepthTexture&),null) and RenderWithShader(Shader.Find(&Hidden/Camera-DepthNormalTexture&),null), but still cant get it right whe passing it to shader using SetTexture. Can someone post an example of rendering depth from non-main camera to render...
How to render a DepthTexture from specified camera into a RenderTexture and use it in a shader?
I've made a little unity android plugin, which allows you to use the camera preview image with all it's advantages like auto focus. My question to you guys is whether you could test the .apk for me and say if it works.
Downloadlink: /download/1i4obil6a6vus9v/Live_Picture_Example.apk
View attachment 149139
View attachment 149138
I have a mesh that I am deforming in script (to give it a curve) that is positioned over an icon.
At certain camera angles, the icon draws on top of the arrow, even though it's farther back
The arrow is using the Unity 5 standard shader set to Fade (also occurs with Transparent)
The icon is using Unlit/Transparent. Issue persists if I change it to Standard with Fade or Transparent.
Issue disappears if either is opaque (or arrow is cutout). But I'm trying to keep draw...
Sorting issue with transparent materials at certain camera angles
Hello All,
I have just installed Unity5 and I want to render what I see in the Camera Preview window to disk as an image sequence.
Is there a button for that?
Or do I need a script?
The characters in my project are quad meshes in 3D space that are viewed through orthographic projection (isometric). The sprites are animated and consist of sprites for 8 directions.
This is done using one single texture that is a sprite sheet, this sheet is rescaled and cycles between offsets programmatically to give the idea of an animated sprite.
They display properly in the Unity editor, but when deployed to WebGL there's some really weird stretching going on.....
WebGL Texture offset/scale issue?
I'm using Unity 5.3.2.f1 Personal and I'm trying to author a UI which is generally rendered to a texture to appear in the main game scene as an image on a computer monitor. The player can &lock on& to this monitor at which point we transition to a full screen view of the UI.
I've achieved this by the following means:
1. Create a camera in the scene with a render target which is a texture (with a 16:9 aspect ratio)
2. Create a canvas which in mode &Screen Space - Camera&, and created my...
Authoring UI for both render to texture and to the screen
Hi! This is my first time posting here, so please be nice to me (or however you like :s)&I've got an issue where my green leaves render weirdly with the light or environment or anything really. They seem to leave behind parts of the black box surrounding the image. However once I render it away from the scene and lighting, the plant seems to work fine.But I can't figure out why, and I need the scene with the lighting and the plants. I am using a volumetric lighting in the background. The whole thing is supposed to be an underwater scene. I'm using a texture on one of the lights to simulate the underwater light reflection on the ground.&Every Help is much appreciated!CheersFelix&&&
I've been having issues with getting a render texture working on windows phones 10 for a few versions now. It works fine in Windows 10 PC releases but not for mobile. Any ideas?
Is is possible to define what should be rendered in a render texture - ie. exlude rendering certain parts?
We want to render 50% on one PC and render the remaining 50% on another PC to get optimal performance.
Appriciate any input on this.
View attachment 175516[Unity3D]图形渲染优化、渲染管线优化、图形性能优化
转载请留下本文原始链接,谢谢。本文会不定期更新维护,最近更新于
主要内容也可以参考:
/Documentation/Manual/OptimizingGraphicsPerformance.html
最简单的优化建议:
1.PC平台的话保持场景中显示的顶点数少于200K~3M,移动设备的话少于10W,一切取决于你的目标GPU与CPU。
2.如果你用U3D自带的SHADER,在表现不差的情况下选择Mobile或Unlit目录下的。它们更高效。
3.尽可能共用材质。
4.将不需要移动的物体设为Static,让引擎可以进行其批处理。
5.尽可能不用灯光。
6.动态灯光更加不要了。
7.尝试用压缩贴图格式,或用16位代替32位。
8.如果不需要别用雾效(fog)
9.尝试用OcclusionCulling,在房间过道多遮挡物体多的场景非常有用。若不当反而会增加负担。
10.用天空盒去“褪去”远处的物体。
11.shader中用贴图混合的方式去代替多重通道计算。
12.shader中注意float/half/fixed的使用。
13.shader中不要用复杂的计算pow,sin,cos,tan,log等。
14.shader中越少Fragment越好。
15.注意是否有多余的动画脚本,模型自动导入到U3D会有动画脚本,大量的话会严重影响消耗CPU计算。
16.注意碰撞体的碰撞层,不必要的碰撞检测请舍去。
1.为什么需要针对CPU(中央处理器)与GPU(图形处理器)优化?
CPU和GPU都有各自的计算和传输瓶颈,不同的CPU或GPU他们的性能都不一样,所以你的游戏需要为你目标用户的CPU与GPU能力进行针对开发。
2.CPU与GPU的限制
GPU一般具有填充率(Fillrate)和内存带宽(Memory
Bandwidth)的限制,如果你的游戏在低质量表现的情况下会快很多,那么,你很可能需要限制你在GPU的填充率。
CPU一般被所需要渲染物体的个数限制,CPU给GPU发送渲染物体命令叫做DrawCalls。一般来说DrawCalls数量是需要控制的,在能表现效果的前提下越少越好。通常来说,电脑平台上DrawCalls几千个之内,移动平台上DrawCalls几百个之内。这样就差不多了。当然以上并不是绝对的,仅作一个参考。
往往渲染(Rendering)并不是一个问题,无论是在GPU和CPU上。很可能是你的脚本代码效率的问题,用Profiler查看下。
关于Profiler介绍:/Documentation/Manual/Profiler.html
需要注意的是:
在GPU中显示的RenderTexture.SetActive()占用率很高,是因为你同时打开了编辑窗口的原因,而不是U3D的BUG。
3.关于顶点数量和顶点计算
CPU和GPU对顶点的计算处理都很多。GPU中渲染的顶点数取决于GPU性能和SHADER的复杂程度,一般来说,每帧之内,在PC上几百万顶点内,在移动平台上不超过10万顶点。
CPU中的计算主要是在蒙皮骨骼计算,布料模拟,顶点动画,粒子模拟等。GPU则在各种顶点变换、光照、贴图混合等。
【个人认为,具体还是看各位的项目需求,假设你项目的是3D游戏。你游戏需要兼容低配置的硬件、流畅运行、控制硬件发热的话,还要达到一定效果(LIGHTMAP+雾效),那么顶点数必定不能高。此时同屏2W顶点我认为是个比较合适的数目,DRAWCALL最好低于70。另,控制发热请控制最高上限的帧率,流畅的话,帧率其实不需要太高的。】
4.针对CPU的优化----减少DRAW CALL 的数量
为了渲染物体到显示器上,CPU需要做一些工作,如区分哪个东西需要渲染、区分开物体是否受光照影响、使用哪个SHADER并且为SHADER传参、发送绘图命令告诉显示驱动,然后发送命令告诉显卡删除等这些。
假设你有一个上千三角面的模型却用上千个三角型模型来代替,在GPU上花费是差不多的,但是在CPU上则是极其不一样,消耗会大很多很多。为了让CPU更少的工作,需要减少可见物的数目:
a.合并相近的模型,手动在模型编辑器中合并或者使用UNITY的Draw call批处理达到相同效果(Draw call
batching)。具体方法和注意事项查看以下链接:
Draw call batching :
/Documentation/Manual/DrawCallBatching.html
b.在项目中使用更少的材质(material),将几个分开的贴图合成一个较大的图集等方式处理。
如果你需要通过脚本来控制单个材质属性,需要注意改变Renderer.material将会造成一份材质的拷贝。因此,你应该使用Renderer.sharedMaterial来保证材质的共享状态。
有一个合并模型材质不错的插件叫Mesh Baker,大家可以考虑试下。
c.尽量少用一些渲染步骤,例如reflections,shadows,per-pixel light 等。
d.Draw call batching的合并物体,会使每个物体(合并后的物体)至少有几百个三角面。
假设合并的两个物体(手动合并)但不共享材质,不会有性能表现上的提升。多材质的物体相当于两个物体不用一个贴图。所以,为了提升CPU的性能,你应该确保这些物体使用同样的贴图。
另外,用灯光将会取消(break)引擎的DRAW CALL BATCH,至于为什么,查看以下:
Forward Rendering Path Details:
/Documentation/Components/RenderTech-ForwardRendering.html
e.使用相关剔除数量直接减少Draw Call数量,下文有相关提及。
5.优化几何模型
最基本的两个优化准则:
a.不要有不必要的三角面。
b.UV贴图中的接缝和硬边越少越好。
需要注意的是,图形硬件需要处理顶点数并跟硬件报告说的并不一样。不是硬件说能渲染几个点就是几个点。模型处理应用通展示的是几何顶点数量。例如,一个由一些不同顶点构成的模型。在显卡中,一些集合顶点将会被分离(split)成两个或者更多逻辑顶点用作渲染。如果有法线、UV坐标、顶点色的话,这个顶点必须会被分离。所以在游戏中处理的实际数量显然要多很多。
6.关于光照
若不用光肯定是最快的。移动端优化可以采用用光照贴图(Lightmapping)去烘培一个静态的贴图,以代替每次的光照计算,在U3D中只需要非常短的时间则能生成。这个方法能大大提高效率,而且有着更好的表现效果(平滑过渡处理,还有附加阴影等)。
在移动设备上和低端电脑上尽量不要在场景中用真光,用光照贴图。这个方法大大节省了CPU和GPU的计算,CPU得到了更少的DRAWCALL,GPU则需要更少顶点处理和像素栅格化。
Lightmapping :
/Documentation/Manual/Lightmapping.html
7.对GPU的优化----图片压缩和多重纹理格式
Compressed Textures(图片压缩):
/Documentation/Components/class-Texture2D.html
图片压缩将降低你的图片大小(更快地加载更小的内存跨度(footprint)),而且大大提高渲染表现。压缩贴图比起未压缩的32位RGBA贴图占用内存带宽少得多。
之前U3D会议还听说过一个优化,贴图尽量都用一个大小的格式(512 * 512 , 1024 *
1024),这样在内存之中能得到更好的排序,而不会有内存之间空隙。这个是否真假没得到过测试。
MIPMAPS(多重纹理格式):
/Documentation/Components/class-Texture2D.html
跟网页上的略缩图原理一样,在3D游戏中我们为游戏的贴图生成多重纹理贴图,远处显示较小的物体用小的贴图,显示比较大的物体用精细的贴图。这样能更加有效的减少传输给GPU中的数据。
8.LOD 、 Per-Layer Cull Distances 、 Occlusion
LOD (Level Of Detail)
是很常用的3D游戏技术了,其功能理解起来则是相当于多重纹理贴图。在以在屏幕中显示模型大小的比例来判断使用高或低层次的模型来减少对GPU的传输数据,和减少GPU所需要的顶点计算。
摄像机分层距离剔除(Per-Layer Cull
Distances):为小物体标识层次,然后根据其距离主摄像机的距离判断是否需要显示。
遮挡剔除(Occlusion
Culling)其实就是当某个物体在摄像机前被另外一个物体完全挡住的情况,挡住就不发送给GPU渲染,从而直接降低DRAW
CALL。不过有些时候在CPU中计算其是否被挡住则会很耗计算,反而得不偿失。
以下是这几个优化技术的相关使用和介绍:
Level Of Detail :
/Documentation/Manual/LevelOfDetail.html
Per-Layer Cull Distances :
/Documentation/ScriptReference/Camera-layerCullDistances.html
Occlusion Culling :
/Documentation/Manual/OcclusionCulling.html
9.关于Realtime Shadows(实时阴影)
实时阴影技术非常棒,但消耗大量计算。为GPU和CPU都带来了昂贵的负担,细节的话参考下面:
/Documentation/Manual/Shadows.html
10.对GPU优化:采用高效的shader
a.需要注意的是有些(built-in)Shader是有mobile版本的,这些大大提高了顶点处理的性能。当然也会有一些限制。
b.自己写的shader请注意复杂操作符计算,类似pow,exp,log,cos,sin,tan等都是很耗时的计算,最多只用一次在每个像素点的计算。不推荐你自己写normalize,dot,inversesqart操作符,内置的肯定比你写的好。
c.需要警醒的是alpha test,这个非常耗时。
d.浮点类型运算:精度越低的浮点计算越快。
在CG/HLSL中--
float :32位浮点格式,适合顶点变换运算,但比较慢。
half:16位浮点格式,适合贴图和UV坐标计算,是highp类型计算的两倍。
fixed: 10位浮点格式,适合颜色,光照,和其他。是highp格式计算的四倍。
写Shader优化的小提示:
/Documentation/Components/SL-ShaderPerformance.html
11.另外的相关优化:
a.对Draw Call Batching的优化
/Documentation/Manual/DrawCallBatching.html
b.对Rendering Statistics Window的说明和提示:
/Documentation/Manual/RenderingStatistics.html
c.角色模型的优化建议
用单个蒙皮渲染、尽量少用材质、少用骨骼节点、移动设备上角色多边形保持在300~1500内(当然还要看具体的需求)、PC平台上内(当然还要看具体的需求)。
/Documentation/Manual/ModelingOptimizedCharacters.html
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

参考资料

 

随机推荐