找回密码
 立即注册
查看: 292|回复: 3

Unity的RenderTexture为什么会有depthBuffer?

[复制链接]
发表于 2021-12-22 09:45 | 显示全部楼层 |阅读模式
并不是
unity这个rendertexture怎么做只是为了封装一下常用的信息而已。很多时候你用rt做离屏渲染,depth buffer本身是要用的。这样把depth subelement塞进rt里方便你用。或者你想拿stencil出来做骚操作,那你就直接访问rt的stencil subelement
但是这不代表rt一定有depthbuffer,你创建rt的时候可以选择不创建对应的depth(0bits),然后再创建另一张rt专门给depth用也是可以的。
发表于 2021-12-22 09:46 | 显示全部楼层
并不是
unity这个rendertexture怎么做只是为了封装一下常用的信息而已。很多时候你用rt做离屏渲染,depth buffer本身是要用的。这样把depth subelement塞进rt里方便你用。或者你想拿stencil出来做骚操作,那你就直接访问rt的stencil subelement
但是这不代表rt一定有depthbuffer,你创建rt的时候可以选择不创建对应的depth(0bits),然后再创建另一张rt专门给depth用也是可以的。
发表于 2021-12-22 09:48 | 显示全部楼层
说说我大概的理解(可能有些偏差,因为它的应用场景应该只存在于管线开发中,我没怎么申请过zbuffer)
zbuffer是在显卡中实现的特殊的缓冲区,你所谓的不就是从GPU拿到纹理数据 其中还经过了大量提高性能成本(无损解压缩等用于解决带宽和优化速度),现代的图形显卡都有对其的特殊优化, 虽然我们每帧都在使用它但是大部分情况下的开发工作是用不到的它的
再引用下unity的官方文档来说就是这个
Under the hood

Depth textures can come directly from the actual depth buffer
, or be rendered in a separate pass, depending on the rendering path used and the hardware. Typically when using Deferred Shading or Legacy Deferred Lighting rendering paths
, the depth textures come “for free” since they are a product of the G-buffer rendering anyway.
When the DepthNormals texture is rendered in a separate pass, this is done through Shader Replacement. Hence it is important to have correct “RenderType” tag in your shaders.
When enabled, the MotionVectors texture always comes from a extra render pass. Unity will render moving GameObjects
into this buffer, and construct their motion from the last frame to the current frame.
 楼主| 发表于 2021-12-22 09:56 | 显示全部楼层
depth Buffer是用来做depth Test和stencilTest的,渲染管线本来就需要这些图,之前build in管线没有暴露出来而已,现在暴露出来给我们完全控制了
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-9-23 00:38 , Processed in 0.122529 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表