如何解决Unity 片段着色器:webgl 中的缓冲区问题
我想在片段着色器中使用结构化缓冲区在 Unity 中绘制一些线条。在编辑器中工作时一切正常,但在 WebGL 构建中无法编译相同的代码。 我将问题隔离到着色器中的这个简化代码:
StructuredBuffer<float4> _Lines;
fixed4 frag (v2f i) : SV_Target
{
fixed4 color = 1;
float4 test= _Lines[0];
color.x = test.x; // without this line the script compile in WebGL build
return color ;
}
设置缓冲区的C#代码:
var lines = new List<Vector4>();
lines.Add(new Vector4(0,1,1));
Material material = GetComponent<Renderer>().material;
int dimStride = System.Runtime.InteropServices.Marshal.SizeOf(typeof(Vector4));
var buffer = new ComputeBuffer(lines.Count,dimStride,ComputeBufferType.Default);
buffer.SetData(lines);
material.SetBuffer("_Lines",buffer);
我想念什么?是否可以在 WebGL 中的片段着色器中使用结构化缓冲区?还是问题出在其他地方?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。