`precision mediump float`是什么意思? [英] What does `precision mediump float` mean?

查看:35
本文介绍了`precision mediump float`是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

learningwebgl 教程1中,我在片段着色器中发现了一条有趣的行.

In the learningwebgl tutorial1 I've found an interesting line in the fragment shader.

precision mediump float;

我找到了一篇关于它的文章 在这里,但我还是不明白是什么意思?

I've found an article about it here, but I still can't understand what does it mean?

如果我删除这条线,什么都不会改变.一切都是一样的.那么precision mediump float是什么意思呢?

And if I remove this line, nothing changes. Everything is the same. So what does precision mediump float mean?

推荐答案

这决定了 GPU 在计算浮点数时使用的精度.highp 是高精度的,当然比 mediump(中精度)和 lowp(低精度)更密集.

This determines how much precision the GPU uses when calculating floats. highp is high precision, and of course more intensive than mediump (medium precision) and lowp (low precision).

有些系统根本不支持highp,这会导致代码在这些系统上根本无法运行.

Some systems do not support highp at all, which will cause code not to work at all on those systems.

在支持 highp 的系统上,您会看到性能下降,应尽可能使用 mediumplowp.我看到的一个很好的经验法则是:
- highp 用于顶点位置,
- mediump 用于纹理坐标,
- lowp 用于颜色.

On systems that DO support highp, you will see a performance hit, and should use mediump and lowp wherever possible. A good rule of thumb that I saw was:
- highp for vertex positions,
- mediump for texture coordinates,
- lowp for colors.

希望有帮助!

这篇关于`precision mediump float`是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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