什么是最小的类型,可用于计算着色器中的渲染纹理
我使用Unity的Compute着色器写入渲染纹理,以后将使用。我要输入的渲染纹理的值是0和1,因此避免使用大量无用的内存,我正在寻找可用于计算着色器中渲染纹理的较小类型。
我看到渲染纹理格式在他在CPU上的创建中可以设置为rendertextureformat.r8
,我尝试使用它,但我不知道在Compute Shader中声明渲染纹理时要使用哪种类型(它不适用于_int8
)。此外,我看到在计算着色器中声明渲染纹理时,我可以使用bool
,但是我不知道要使用哪种渲染纹理格式...
I'm using unity's compute shader to write into a render texture that will be used later. The values I want to enter into my render texture are 0 and 1, therefore to avoid using a lot of useless memory, I'm looking for the smaller type that can be used for a render texture in a compute shader.
I saw that the render texture format at his creation on CPU can be set to RenderTextureFormat.R8
, I try to used it but I don't know which type to use when declaring the render texture in compute shader (it doesn't work with _int8
). Moreover, I saw that I can use the type bool
when I declare the render texture in compute shader, but then I don't know which render texture format to use...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AS shingo 说,较小的类型是8位整数,在渲染纹理创建中通过
rendertextextureformat.r8定义
,然后在计算着色器中的呈现纹理声明中,Unorm float
。有一个表/code>,并且在
hlsl
中为Compute着色器等效。As Shingo said, the smaller type is a 8 bit integer which is defined in render texture creation by
RenderTextureFormat.R8
and then in render texture declaration in compute shader byunorm float
.There is a table in Unity Manual that summarize the different
RenderTextureFormat
and there equivalent inHLSL
for compute shader.