Unity的Compute Pander是否也可以使用_texelsize后缀?
根据 Unity Documentation 在Shader代码中,我们可以获得我们的大小纹理带有{texturename} _texelsize
中命名的变量。我在编写计算着色器时尝试但失败了。所以我想知道这是否是因为_texelsize
后缀在计算着色器中不起作用?
我尝试的内容如下。
我在计算着色器中定义了以下两个变量
Texture<float4> _MyTexture;
float4 _MyTexture_TexelSize;
,并在C#代码中设置_myTexture,
ComputeShader myComputeShader;
Texture2D myTexture;
// ...
myComputeShader = myComputeShader.SetTexture(0, "_MyTexture", myTexture);
我也尝试更改_MYTEXTURE的类型
到示例2d
,但它不起作用。
我的目标是用_MYTEXTURE
使用_MYTEXTURE_TEXELSIZE
在阴沉器代码中,而无需在C#代码中设置它。
According to the Unity documentation, in shader code we can get the size of a texture with variables named in {TextureName}_TexelSize
. I tried but failed when writing compute shader. So I wonder if it's because the _TexelSize
suffix doesn't work in compute shader?
What I've tried is as follows.
I defined the following two variables in my compute shader
Texture<float4> _MyTexture;
float4 _MyTexture_TexelSize;
and set _MyTexture in C# code
ComputeShader myComputeShader;
Texture2D myTexture;
// ...
myComputeShader = myComputeShader.SetTexture(0, "_MyTexture", myTexture);
I've also tried to change the type of _MyTexture
to sample2D
but it doesn't work.
My goal is to get the size of _MyTexture
with _MyTexture_TexelSize
in shader code without setting it in C# code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
手动设置值:
Set the value manually: