Unity3D翻译——Platform Specific Rendering Differences

Platform Specific Rendering Differences    特定平台的渲染差异

原文地址:http://unity3d.com/support/documentation/Components/SL-PlatformDifferences.html

如有翻译不当之处,还请帮忙指出!

 

Unity runs on various platforms, and in some cases there are differences in how things behave. Most of the time Unity hides the differences from you, but sometimes you can still bump into them.

Unity运行在不同平台上,并在某些情况下某些物体会出现不同的表现形式。在大部分时间Unity为你隐藏了这些差异,但有时侯你仍然可以撞到它们。

 

Render Texture Coordinates                  渲染纹理坐标

Vertical texture coordinate conventions differ between Direct3D, OpenGL and OpenGL ES:

垂直纹理坐标在Direct3D, OpenGLOpenGL ES之间有所不同:

*      In Direct3D, the coordinate is zero at the top, and increases downwards.

*      Direct3D中,坐标在顶部为0,并向下增加。

*      In OpenGL and OpenGL ES, the coordiante is zero at the bottom, and increases upwards.

*      OpenGLOpenGL ES中,坐标在底部为0,并向上增加。

Most of the time this does not really matter, except when rendering into aRenderTexture. In that case, Unity internally flips rendering upside down when rendering into a texture on Direct3D, so that the conventions match between the platforms.

这大部分的时间内其实并不重要,除非我们需要渲染一张RenderTexture。在这种情况下,当需要在Direct3D中渲染一张纹理时,Unity会自上而下地翻转渲染次序,从而使纹理坐标可以在各项平台之间进行匹配。

One case where this does not happen, is whenImage Effects and Anti-Aliasing is used. In this case, Unity renders to screen to get anti-aliasing, and then "resolves" rendering into a RenderTexture for further processing with an Image Effect. The resulting source texture for an image effect isnot flipped upside down on Direct3D (unlike all other Render Textures).

在使用图像特效和反走样时将不会出现上述情况。Unity渲染到屏幕并获得反走样效果,然后"解析"渲染到 RenderTexture并通过图像特效来进行进一步的处理。针对一种图像特效来生成的源纹理在Direct3D上并不需要颠倒翻转(不同于所有其他渲染的纹理)。

If your Image Effect is a simple one (processes one texture at a time), this does not really matter, becauseGraphics.Blit takes care of that.

如果你的图像后处理特效是的一个简单的操作(一次处理一个纹理),那么渲染坐标纹理的次序其实并不重要,因为 Graphics.Blit会来进行管理。

However, if you're processing more than one RenderTexture together in your Image Effect, most likely they will come out at different vertical orientations (only in Direct3D, and only when anti-aliasing is used). You need to manually "flip" the screen texture upside down in your vertex shader, like this:

但是,如果你在图像特效中同时处理多个RenderTexture,最有可能它们的纹理坐标拥有不同的垂直方向(只在 Direct3D,和只在使用反走样效果时会出现这种情况)。这时,你需要在你的顶点着色器中手动"翻转"屏幕纹理,像这样:

// On D3D when AA is used, the main texture & scene depth texture
// will come out in different vertical orientations.
// So flip sampling of the texture when that is the case (main texture
// texel size will have negative Y).
#if SHADER_API_D3D9
if (_MainTex_TexelSize.y < 0)
        uv.y = 1-uv.y;
#endif


Check out Edge Detection scene inShader Replacement sample project for an example of this. Edge detection there uses both screen texture and Camera'sDepth+Normals texture.

对于这种例子,可以查看着色器变更项目中的边检测场景。边检测特效既使用屏幕纹理,又使用照相机的深度+法线纹理。

 

Using OpenGL Shading Language (GLSL) shaders with OpenGL ES 2.0        OpenGL ES 2.0中使用GLSL编写的着色器

OpenGL ES 2.0 provides only limited native support for OpenGL Shading Language (GLSL), for instance OpenGL ES 2.0 layer provides no built-in parameters to the shader.

OpenGL ES 2.0仅本地支持OpenGL着色语言 (GLSL),例如 OpenGL ES 2.0 层为着色器没有提供内置参数。

Unity implements built-in parameters for you exactly in the same way as OpenGL does, however following built-in parameters are missing:

Unity完全以OpenGL相同的方式为你实现内置参数,但是以下的内置参数将会缺失:

*      gl_ClipVertex

*      gl_SecondaryColor

*      gl_DepthRange

*      halfVector property of thegl_LightSourceParameters structure

*      gl_FrontFacing

*      gl_FrontLightModelProduct

*      gl_BackLightModelProduct

*      gl_BackMaterial

*      gl_Point

*      gl_PointSize

*      gl_ClipPlane

*      gl_EyePlaneR,gl_EyePlaneS,gl_EyePlaneT, gl_EyePlaneQ

*      gl_ObjectPlaneR,gl_ObjectPlaneS,gl_ObjectPlaneT, gl_ObjectPlaneQ

*      gl_Fog

 

iPad2 and MSAA and alpha-blended geometry             iPad2MSAAalpha混合几何

There is a bug in apple driver resulting in artifacts when MSAA is enabled and alpha-blended geometry is drawn with non RGBA colorMask. To prevent artifacts we force RGBA colorMask when this configuration is encountered, though it will render built-in Glow FX unusable (as it needs DST_ALPHA for intensity value). Also, please update your shaders if you wrote them yourself (see "Render Setup -> ColorMask" inPass Docs).

在苹果驱动程序中,当启用MSAA,并使用非RGBA colorMask进行alpha混合几何渲染时,会出现一个bug。为了防止发生这种bug,我们在遇到此种配置时强制使用RGBA colorMask,但这样做的后果会使内置Glow FX无法使用(因为它用到了DST_ALPHA所需要的强度值)。另外,如果是你自己写的着色器,请一定不要忘记更新它们(请参阅Pass Docs中的" Render Setup -> ColorMask"文档)。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值