gpt4 book ai didi

opengl - `sqrt` 在 GLSL 中对于负值有何表现?

转载 作者:行者123 更新时间:2023-12-02 10:01:36 26 4
gpt4 key购买 nike

我一直想知道 GLSL 中的 sqrt(num) 是否等于 sqrt(abs(num)) 。这正是该函数在 this shader 中的行为方式。我无法找到有关此行为的任何文档或引用资料。在此着色器中,形成单位圆,并且 sqrt 内部的值对于圆的外部像素为负,但结果就像在应用 sqrt< 之前已获取 abs 一样。/.

最佳答案

根据the spec

sqrt returns the square root of x. i.e., the value √x. Results are undefined if x<0.

这意味着任何事情都可能发生,但某些实现只会忽略参数上的符号位并返回正数。

关于opengl - `sqrt` 在 GLSL 中对于负值有何表现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26381431/

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