当前位置: 首页 > news >正文

茶网站建设wordpress 网络公司主题

茶网站建设,wordpress 网络公司主题,广告最多的网站,便宜高端网站设计推荐序之前#xff0c;生成了地形图#xff1a;(42条消息) 从灰度图到地形图_averagePerson的博客-CSDN博客那末#xff0c;地形的法线贴图怎么获取#xff1f;大概分为两个部分吧#xff0c;先拿到法线数据#xff0c;再画到纹理中去。关于法线计算Unity - Scripting API: M…序之前生成了地形图(42条消息) 从灰度图到地形图_averagePerson的博客-CSDN博客那末地形的法线贴图怎么获取大概分为两个部分吧先拿到法线数据再画到纹理中去。关于法线计算Unity - Scripting API: Mesh.RecalculateNormals (unity3d.com)这个链接讲的是法线的计算它是什么空间下的无所谓了……这里也不对地形搞什么几何变换而且它是方向模型空间世界空间是一个结果。获取Unity - Scripting API: Mesh.normals (unity3d.com)直接一个等于号然后这个法线是对顶点不是对三角形面片。就这两点没了。存到纹理中构造Unity - Scripting API: Texture2D (unity3d.com)这个变量好像在unity shader里也经常出现嘞要把法线数据存到Texture2D里首先得构造一下对象啊构造函数是什么Unity - Scripting API: Texture2D.Texture2D (unity3d.com)RGBA32构造RenderTexture的时候也有你。怎么赋值赋值Unity - Scripting API: Texture2D.SetPixels (unity3d.com)直接传数组数组要展平【mesh.normals其实就是一维的那就可以直接用了】最后需要Apply从左到右从下到上【地形顶点正好也是这个顺序的】官方示例代码using UnityEngine; using System.Collections;public class ExampleClass : MonoBehaviour {void Start(){Renderer rend GetComponentRenderer();// duplicate the original texture and assign to the materialTexture2D texture Instantiate(rend.material.mainTexture) as Texture2D;rend.material.mainTexture texture;// colors used to tint the first 3 mip levelsColor[] colors new Color[3];colors[0] Color.red;colors[1] Color.green;colors[2] Color.blue;int mipCount Mathf.Min(3, texture.mipmapCount);// tint each mip levelfor (int mip 0; mip mipCount; mip){Color[] cols texture.GetPixels(mip);for (int i 0; i cols.Length; i){cols[i] Color.Lerp(cols[i], colors[mip], 0.33f);}texture.SetPixels(cols, mip);}// actually apply all SetPixels, dont recalculate mip levelstexture.Apply(false);} }试一试根据文档调api就行了。代码计算法线的using System.Collections; using System.Collections.Generic; using UnityEngine;public class Terrian : MonoBehaviour {public int N 10;public Texture2D texture2dHeightMap;[Range(1,100)]public float heightRatio 30.0f;//一个系数控制地形总体的高度的public Texture2D normalTex;MeshRenderer meshRenderer;MeshFilter meshFilter;// 用来存放顶点数据ListVector3 verts;Listint indices;Vector3[] normals;private void Awake(){}private void Start(){verts new ListVector3();indices new Listint();meshRenderer GetComponentMeshRenderer();meshFilter GetComponentMeshFilter();//normalTex new Texture2D(texture2dHeightMap.width, texture2dHeightMap.height, TextureFormat.RGB24,-1,false);normalTex new Texture2D(N,N, TextureFormat.RGB24, -1, false);//2.5D的地形顶点的法线法线贴图规模不是灰度图规模}private void Update(){Generate();normals new Vector3[N * N];normals meshFilter.mesh.normals;for(int i 0; i 10; i){print(normals[i]);}Color[] colors new Color[N * N];for(int i 0; i N * N; i){colors[i] new Color(normals[i].x, normals[i].y, normals[i].z);}normalTex.SetPixels(colors);normalTex.Apply(false);}public void Generate(){ClearMeshData();// 把数据填写好AddMeshData();// 把数据传递给Mesh生成真正的网格Mesh mesh new Mesh();mesh.vertices verts.ToArray();mesh.triangles indices.ToArray();mesh.RecalculateNormals();mesh.RecalculateBounds();meshFilter.mesh mesh;}void ClearMeshData(){verts.Clear();indices.Clear();}void AddMeshData(){//01填充顶点数据for (int z 0; z N; z)//按先x后z的顶点排列顺序所以先循环的是z{for(int x 0; x N; x){int u Mathf.FloorToInt(1.0f * x / N * texture2dHeightMap.width);int v Mathf.FloorToInt(1.0f * z / N * texture2dHeightMap.height);float grayValue texture2dHeightMap.GetPixel(u,v).grayscale;float height grayValue*heightRatio;Vector3 temp new Vector3(x, height, z);verts.Add(temp);}}//02填充索引数据for(int z 0; z N - 1; z){for(int x 0; x N - 1; x){int index_lb z * N x;//index of the left bottom vertex. lb left bottomint index_lt (z 1) * N x;int index_rt (z 1) * N x 1;int index_rb z * N x 1;indices.Add(index_lb);indices.Add(index_lt);indices.Add(index_rt);indices.Add(index_rt);indices.Add(index_rb);indices.Add(index_lb);}}}}显示法线贴图的。这个是在摄像机上的——屏幕后处理嘛using System.Collections; using System.Collections.Generic; using UnityEngine;public class ShowTexture2D : MonoBehaviour {public Terrian terrian;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){}private void OnRenderImage(RenderTexture source, RenderTexture destination){Graphics.Blit(terrian.normalTex, destination);}}结果看着……走势差不多吧。而且绿色的表示向上符合的。对不对在这种情况下没法看出来。只能接着往下做然后拔出萝卜带出泥巴。纯平面是纯绿色高度系数越大颜色越深
http://www.hkea.cn/news/14439161/

相关文章:

  • 网页制作网站首页设计付费抽奖网站怎么做
  • 为网站做电影花絮申请注册商标的流程
  • 杭州网站设计优异柚v米科技国内网站空间购买
  • jsp网站开发登陆做网站卖彩票
  • 西安企业网站开发品牌网站设计服务
  • 网站设计机构网站建设哪个
  • 网站页面缺点分析案例网页设计制作公司价格便宜
  • 做面食专业网站台州做网站公司
  • 网站建设服务文案dw做网站菜单栏
  • 做渔家乐哪个网站最好企业邮箱什么意思
  • 网站建设中图片联系方式工程建设项目
  • 服务器网站别名设置淘宝店群软件定制开发
  • 建设部网站查询通报多平台网站开发
  • 网站项目意义动态链接做网站外链图
  • 网站建设规划公司网站空间已到期 请尽快续费开通
  • 招商信息发布网站大全wordpress搭建网盘
  • 网站开发项目管理步骤网站背景图片怎么做
  • 还有用的网站做网站维护需要会什么
  • 四大门户网站是哪些电竞网站开发需求报告
  • 算命购物网站建设Wordpress免费版插件
  • 上海市杨浦区建设小学网站云南省住房和城乡建设厅网站首页
  • 信息图表网站公司网站不备案吗
  • 电商平台投诉找哪个部门企业网站搜索优化外包
  • 宣城网站建设 有限公司哪个网站做投票链接模板好看
  • 企业模板网站手机小程序怎么制作
  • 江苏省建设执业资格注册中心网站网站的策划和建设
  • 网站设计师介绍泰安网络犯罪案件
  • 家装室内设计案例分析图文网页seo如何优化
  • 保定建设信息网站商融交通建设工程有限公司网站
  • 网站开发用什么语言写建设工程合同分类有哪些