gpt4 book ai didi

unity-game-engine - 如何统一生成颜色直方图?

转载 作者:行者123 更新时间:2023-12-02 17:49:58 25 4
gpt4 key购买 nike

我有一个统一的texture2d,我想根据每个像素的色调值生成颜色直方图。我尝试过使用 getPixels,但对于 1920x1080 纹理来说它太慢了。

if (tex == null)
{
return null;
}
tex = GetComponent<GUITexture>().texture as Texture2D;
Color32[] texColors = tex.GetPixels32();
int total = texColors.Length;

int[] Harray = new int[360];
for (int i = 0; i < total; i++)
{
float H;
float S;
float V;

Color.RGBToHSV(new Color(texColors[i].r, texColors[i].g, texColors[i].b),out H,out S,out V);
Harray[(int)H]++;
}


for (int i = 0; i < 360; i++)
{
PlotManager.Instance.PlotAdd("Hue", Harray[i]);
}

我认为着色器可能会有所帮助,但我没有着色器编程经验。着色器可以填充色调出现数组并返回它,同时保持良好的帧速率吗?

最佳答案

unity store 上有一个 Assets 使用带有 RWStructuredBuffer 的计算着色器来实现此目的:https://www.assetstore.unity3d.com/en/#!/content/15699

关于unity-game-engine - 如何统一生成颜色直方图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38562752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com