统一通过 CommandBuffer 更新计算着色器中的值

问题描述

我正在尝试更新 CommandBuffer 中的几个浮点数和一个向量。

var clickTypeLocation = Shader.PropertyToID("ClickType");
drawPipelineBuilder.computePipeline.SetComputeFloatParam(compute,clickTypeLocation,mouse1 ? UNSET : SET);

var mouseRadiusPowLocation = Shader.PropertyToID("MouseRadiusPow");
drawPipelineBuilder.computePipeline.SetComputeFloatParam(compute,mouseRadiusPowLocation,Mathf.Pow(mouseRadius,2));

var mousePoslocation = Shader.PropertyToID("MousePos");
drawPipelineBuilder.computePipeline.SetComputeVectorParam(compute,mousePoslocation,mousePos);

SetComputeXParam 函数只接受值而不接受引用,因此每次我在代码中执行 Graphics.ExecuteCommandBuffer(drawPipeline); 时都是相同的。除了简单地避免使用 CommandBuffer,即在执行 CommandBuffer 之前使用 compute.SetFloat 之外,还有其他方法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)