Home > Net >  What is the smallest type that can be used for a render texture in a compute shader
What is the smallest type that can be used for a render texture in a compute shader

Time:06-21

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...

CodePudding user response:

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 by unorm float. There is a table in Unity Manual that summarize the different RenderTextureFormat and there equivalent in HLSL for compute shader.

  • Related