所有像素的有效像素着色器的总和 [英] Efficient pixel shader sum of all pixels

查看:149
本文介绍了所有像素的有效像素着色器的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能有效地计算所有像素的总和图像中,通过使用首次置业贷款计划像素着色器?我感兴趣的是支持Pixel Shader 2.0,我可以援引作为一个WPF着色效果。

How can I efficiently calculate the sum of all pixels in an image, by using a HSLS pixel shader? I'm interested in Pixel Shader 2.0, that I could invoke as a WPF shader effect.

推荐答案

有一个更简单的解决方案不使用着色器:加载图像作为纹理,创造的mipmap链和回读最后的mipmap(1x1像素)的值。这一招在比赛中广泛使用来计算,例如,一个场景的平均brigthness(以适用HDR色调映射)。这是一个伟大的技巧,如果你看重简单性和效率超过准确性。

There is a much simpler solution that doesn't use shaders: load the image as a texture, create a mipmap chain and read back the value of the last mipmap (1x1 pixel). This trick is used in games extensively to calculate, for example, the average brigthness of a scene (in order to apply HDR tonemapping). It's a great trick if you value simplicity and efficiency over accuracy.

这篇关于所有像素的有效像素着色器的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆