理解矩阵需要的基础
线性代数 (矩阵背后的几何意义)/四元数(一种简洁的坐标转换数学工具)/三维向量
推荐阅读 :三维数学基础图形与游戏开发 ()
虽然 unity大大降低了游戏开发的难度(碰撞检测/视锥裁剪)
但是深入理解有关内容对理解投影的原理是有很大好处的。
unity圣典关于矩阵的知识 :http://www.ceeger.com/Components/SL-BuiltinValues.html
unity最新关于shader的分类 :http://blog.csdn.net/liangyuqi123456/article/details/50696425 浅墨博客
简而言之 虽然现在unity提供了多种多样的shader模板 (浅墨)
在编写可编程着色器时 要使用如下矩阵 需要包含UnityCG.cginc 这个句柄。
虽然没什么太多干货 但是好的基础是写出简洁 高效的代码的第一步啊
Transformations 变换
-
float4x4 UNITY_MATRIX_MVP
-
Current model*view*projection matrix
当前物体*视*投影矩阵。(注:物体矩阵为 本地->世界)
float4x4 UNITY_MATRIX_MV
-
Current model*view matrix
当前物体*视矩阵
float4x4 UNITY_MATRIX_P
-
Current projection matrix
当前物体*投影矩阵
float4x4 UNITY_MATRIX_T_MV
-
Transpose of model*view matrix
转置物体*视矩阵
float4x4 UNITY_MATRIX_IT_MV
-
Inverse transpose of model*view matrix
逆转置物体*视矩阵
float4x4 UNITY_MATRIX_TEXTURE0 to UNITY_MATRIX_TEXTURE3
-
Texture transformation matrices
贴图变换矩阵
float4x4 _Object2World
-
Current model matrix
当前物体矩阵
float4x4 _World2Object
-
Inverse of current world matrix
物体矩阵的逆矩阵
float3 _WorldSpaceCameraPos
-
World space position of the camera
世界坐标空间中的摄像机位置
float4 unity_Scale
-
xyz components unused; .w contains scale for uniformly scaled objects.
不适用xyz分量,而是通过w分量包含的缩放值等比缩放物体。
- float4 _Time : Time (t/20, t, t*2, t*3), use to animate things inside the shaders
时间: 用于Shasder中可动画的地方。 - float4 _SinTime : Sine of time: (t/8, t/4, t/2, t)
时间的正弦值。 - float4 _CosTime : Cosine of time: (t/8, t/4, t/2, t)
时间的余弦值 - float4 _ProjectionParams : 投影参数
x is 1.0 or -1.0, negative if currently rendering with a flipped projection matrix
x为1.0 或者-1.0如果当前渲染使用的是一个反转的投影矩阵那么为负。
y is camera's near plane y是摄像机的近剪裁平面
z is camera's far plane z是摄像机远剪裁平面
w is 1/FarPlane. w是1/远剪裁平面 - float4 _ScreenParams : 屏幕参数
x is current render target width in pixels x是当前渲染目标在像素值中宽度
y is current render target height in pixels y是当前渲染目标在像素值中的高度
z is 1.0 + 1.0/width z是1.0+1.0/宽度
w is 1.0 + 1.0/height w是1.0+1.0/高度
世界坐标空间中的摄像机位置
不适用xyz分量,而是通过w分量包含的缩放值等比缩放物体
在unity实现了可视化编辑 分别就是我们的
transform的scale属性
camera的Clipping Planes 属性
这大概就是传说中的可视化编程吧 QAQ
确实降低了不少初学者 像我 这样的
昨天在看UE4也是发现 在编程时
可以选择在VS上用c++写
也可以选择蓝图系统 进行可视化的编辑
从效率上看可视化的编辑肯定是更高的
但要从底层去理解原理还是多看看源码的
顺便一提UNET 这个坑 虽然大大降低了服务器端程序的工作量但是稳定性 堪忧啊--
下面是知乎对UNET的评价
https://www.zhihu.com/question/38842804
传一张自己有段时间临摹的一张原画 发现自己还真的是爱好广泛无一精通啊