Create Normal map from grayscale map
来源:互联网 发布:企业站如何优化 编辑:程序博客网 时间:2024/06/11 21:27
desTex = new Texture2D(tex.width, tex.height, TextureFormat.RGB24, false); for (int i = 0; i < tex.height; i++) { for(int j = 0; j < tex.width; j++) { Color col = tex.GetPixel(i, j); float grayscale = col.grayscale; float xLeft = tex.GetPixel(i - 1, j).grayscale; float xRight = tex.GetPixel(i + 1, j).grayscale; float yUp = tex.GetPixel(i, j + 1).grayscale; float yDown = tex.GetPixel(i, j - 1).grayscale; // 方案1 //float xDelta = ((xLeft - xRight) + 1) * .5f; //float yDelta = ((yUp - yDown) + 1) * .5f; //desTex.SetPixel(i, j, new Color(xDelta, yDelta, 1f, 1f)); // 方案2, 更靠近Unity3D的 create from grayScale, Bumpiness = 0.01 Vector3 va = new Vector3(1, 0, xRight - xLeft).normalized; Vector3 vb = new Vector3(0, 1, yUp - yDown).normalized; Vector3 bump = Vector3.Cross(va, vb).normalized; bump = (bump + Vector3.one) * 0.5f; desTex.SetPixel(i, j, new Color(bump.x, bump.y, bump.z)); } } desTex.Apply(); byte[] datas = desTex.EncodeToPNG(); System.IO.File.WriteAllBytes(Application.dataPath + "/aa.png", datas); AssetDatabase.Refresh();
参考:
http://forum.unity3d.com/threads/bumpmap-grayscale-to-normalmap-rgb.5714/
http://stackoverflow.com/questions/5281261/generating-a-normal-map-from-a-height-map
0 0
- Create Normal map from grayscale map
- Normal Map
- normal map
- Normal Map HLSL实现
- Normal map的显示
- About normal map
- 如何由Height Map生成Normal Map
- Normal map All in one
- 三维模型的normal map
- 凹凸贴图---------------- Bump Map vs Normal Map vs Parallax Map
- create source map
- Normal Map的一些细节问题
- Normal Map 的制作和使用方法
- UnityShader - 基础 - Normal Map 法线贴图
- Normal Map(法线贴图)Ⅰ(转)
- Normal Map(法线贴图)Ⅱ(转)
- create a 2D map
- create a 3D map
- JAVA中IO流的应用
- iOS10适配秘籍
- MySQL主从复制数据一致性校验和修复方法及自动化实现
- Linux下redis的安装
- node.js实现回调
- Create Normal map from grayscale map
- 图片下面出现空白4像素BUG的常用解决方法归纳
- iOS 学习笔记 uiscrollview
- 10.零拷贝原理
- iOS js oc相互调用(JavaScriptCore)
- bootstrap时间控件随滚动条一起移动bootstrap-datetimepicker.js
- 终于找到程序员无休止加班的原因了
- C语言状态机学习笔记二
- Caffe 网络结构可视化