今天又出现了shader的问题,编译到真机效果就没了,后来仔细还是因为浮点数精度的问题,后来仔细查找了些资料,才发现自己太粗心,没有看清楚 fixed-point 数据类型就乱用,这是个范围在 [-1,+1]或者[-1,+2]之间的浮点数,我却当做普通的浮点数用,导致很多数据溢出,所以才丢失原有的效果,得注意了!

不明白的就去看 http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter03.html 的3.3.2小节吧

重点:Continuous quantities are not limited to integer values. When programming a CPU, programmers typically use floating-point data types to represent continuous values because floating-point types can represent fractional values. Continuous values processed by GPUs, particularly at the fragment level, have been limited to narrow ranges such as [0, 1] or [-1, +1], rather than supporting the expansive range provided by floating-point. For example, colors are often limited to the [0, 1] range, and normalized vectors are, by definition, confined to the [-1, +1] range. These range-limited data types are known as "fixed-point," rather than floating-point.

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-11-07
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-12-03
  • 2022-02-25
  • 2021-07-31
  • 2021-09-03
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案