代码中看到后收集的一些shader学习笔记


ARB_precision_hint_nicest 的意义,作用:

首先,这2命令最权威解释的地方,肯定就是openGl官网了,以下是链接:
https://www.opengl.org/registry/specs/NV/fragment_program4.txt

这里有这么一段:

+ Precision Hints(ARB_precision_hint_fastest, ARB_precision_hint_nicest)

Fragment program computations are carriedout at an implementation- dependent precision. However, some implementationsmay be able to perform fragment program computations at more than oneprecision, and may be able to trade off computation precision for performance.If a fragment program specifies the "ARB_precision_hint_fastest"program option, implementations should select precision to minimize programexecution time, with possibly reduced precision. If a fragment programspecifies the "ARB_precision_hint_nicest" program option,implementations should maximize the precision, with possibly increasedexecution time. Only one precision control option may be specified by any givenfragment program. A fragment program that specifies both the"ARB_precision_hint_fastest" and "ARB_precision_hint_nicest"program options will fail to load.

看标题也知道了,也就是精度提示。

ARB_precision_hint_fastest最快的,意思就是会用低精度(一般是指fp16),以提升片段着色器的运行速度,减少时间。

ARB_precision_hint_nicest最佳的,意思就是会用高精度(一般是指fp32),可能会降低运行速度,增加时间。

注意:这

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,您的第一个问题是关于Unity Shader学习笔记,具体是在表面着色器控制顶点变换。那么我可以回答您的问题。 在Unity,表面着色器是一种用于控制物体表面外观的程序。它们可以控制颜色、纹理和光照等方面。而在表面着色器,我们可以使用顶点变换来控制物体表面的外观。 顶点变换是一个将物体的顶点坐标从局部空间转换为世界空间或者相机空间的过程。在表面着色器,我们可以通过在CG程序编写代码来实现顶点变换。以下是一个简单的例子: ```CG // 定义变换矩阵 float4x4 worldMatrix; float4x4 viewMatrix; float4x4 projectionMatrix; // 定义输入结构体 struct appdata { float4 vertex : POSITION; }; // 定义输出结构体 struct v2f { float4 vertex : SV_POSITION; }; // 顶点变换函数 v2f vert (appdata v) { v2f o; o.vertex = mul(mul(mul(v.vertex, worldMatrix), viewMatrix), projectionMatrix); return o; } ``` 在这个例子,我们定义了三个变换矩阵:世界矩阵、视图矩阵和投影矩阵。然后定义了一个输入结构体appdata,其包含了顶点的位置信息。输出结构体v2f则只包含了顶点的位置信息,用于传递给像素着色器。 在vert函数,我们首先将顶点从局部空间转换到世界空间,然后再从世界空间转换到相机空间,最后再从相机空间转换到屏幕空间。这个过程使用了mul函数来进行矩阵乘法运算。 通过这样的方式,我们可以在表面着色器控制顶点变换,从而实现对物体表面外观的控制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值