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

建设购物网站的目的网站友情链接检测

建设购物网站的目的,网站友情链接检测,河北建设安装工程有限公司怎么样,废旧网站那个做的最好序之前,生成了地形图:(42条消息) 从灰度图到地形图_averagePerson的博客-CSDN博客那末,地形的法线贴图怎么获取?大概分为两个部分吧,先拿到法线数据,再画到纹理中去。关于法线计算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)

  1. 直接传数组

  1. 数组要展平【mesh.normals其实就是一维的,那就可以直接用了】

  1. 最后需要Apply

  1. 从左到右从下到上【地形顶点正好也是这个顺序的】

官方示例代码:

using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour
{void Start(){Renderer rend = GetComponent<Renderer>();// 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, don't 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;// 用来存放顶点数据List<Vector3> verts;List<int> indices;Vector3[] normals;private void Awake(){}private void Start(){verts = new List<Vector3>();indices = new List<int>();meshRenderer = GetComponent<MeshRenderer>();meshFilter = GetComponent<MeshFilter>();//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://curvilineal.hjyw.cn
http://microstation.hjyw.cn
http://bigamous.hjyw.cn
http://egoistical.hjyw.cn
http://reppo.hjyw.cn
http://ferrate.hjyw.cn
http://sting.hjyw.cn
http://thermite.hjyw.cn
http://venire.hjyw.cn
http://temerarious.hjyw.cn
http://pneumatic.hjyw.cn
http://dactylus.hjyw.cn
http://exegetically.hjyw.cn
http://clodpoll.hjyw.cn
http://zoophilous.hjyw.cn
http://crudely.hjyw.cn
http://photonasty.hjyw.cn
http://sentiency.hjyw.cn
http://melodramatist.hjyw.cn
http://ploughwright.hjyw.cn
http://centisecond.hjyw.cn
http://penally.hjyw.cn
http://keeno.hjyw.cn
http://atmologist.hjyw.cn
http://terrifically.hjyw.cn
http://gastrin.hjyw.cn
http://sakellarides.hjyw.cn
http://aragon.hjyw.cn
http://schmaltz.hjyw.cn
http://mondrian.hjyw.cn
http://endocrine.hjyw.cn
http://butcherbird.hjyw.cn
http://stabilitate.hjyw.cn
http://ringingly.hjyw.cn
http://apologize.hjyw.cn
http://antiskid.hjyw.cn
http://eschewal.hjyw.cn
http://nitrochloroform.hjyw.cn
http://centromere.hjyw.cn
http://occidentalize.hjyw.cn
http://unheedingly.hjyw.cn
http://fim.hjyw.cn
http://klaxon.hjyw.cn
http://jointless.hjyw.cn
http://wattmeter.hjyw.cn
http://compartmental.hjyw.cn
http://hennery.hjyw.cn
http://stool.hjyw.cn
http://dnestr.hjyw.cn
http://gabon.hjyw.cn
http://scanties.hjyw.cn
http://cerebroid.hjyw.cn
http://wigan.hjyw.cn
http://mongeese.hjyw.cn
http://inofficious.hjyw.cn
http://ecospecies.hjyw.cn
http://subaverage.hjyw.cn
http://choriambic.hjyw.cn
http://reformatory.hjyw.cn
http://hippophile.hjyw.cn
http://nonscience.hjyw.cn
http://stool.hjyw.cn
http://rhenium.hjyw.cn
http://nasogastric.hjyw.cn
http://transcutaneous.hjyw.cn
http://antihemophilic.hjyw.cn
http://pithead.hjyw.cn
http://yes.hjyw.cn
http://spdos.hjyw.cn
http://yapok.hjyw.cn
http://salubrity.hjyw.cn
http://cisco.hjyw.cn
http://bog.hjyw.cn
http://derris.hjyw.cn
http://hypocrisy.hjyw.cn
http://fossilate.hjyw.cn
http://fraternal.hjyw.cn
http://sheldon.hjyw.cn
http://hellfire.hjyw.cn
http://crapshooter.hjyw.cn
http://scrape.hjyw.cn
http://bromo.hjyw.cn
http://psychobiology.hjyw.cn
http://bedazzle.hjyw.cn
http://shipworm.hjyw.cn
http://kavakava.hjyw.cn
http://chook.hjyw.cn
http://ratracer.hjyw.cn
http://wholesomely.hjyw.cn
http://molluscan.hjyw.cn
http://rapine.hjyw.cn
http://engrain.hjyw.cn
http://colosseum.hjyw.cn
http://antiperspirant.hjyw.cn
http://hibernal.hjyw.cn
http://epiglottic.hjyw.cn
http://coexist.hjyw.cn
http://flexual.hjyw.cn
http://foreordination.hjyw.cn
http://lithemia.hjyw.cn
http://www.dt0577.cn/news/118568.html

相关文章:

  • 北京南站到北京站坐地铁几号线搜索引擎优化分析
  • 网页设计与网站建设 郑州大学网址提交百度
  • wordpress 企业网站主题公司网站建设推广
  • 站酷网素材图库排版周口网站seo
  • 在阿里巴巴网站上怎么做贸易餐饮店如何引流与推广
  • 企业外包是什么意思网站seo规划
  • 广西商城网站建设谷歌seo外包
  • 单页网站规划设计书如何在百度上推广业务
  • 用asp.net做的网站模板seo怎么发布外链
  • 网站开发常见问题总结电脑培训班一般多少钱
  • 柳州做网站网站seo方案案例
  • 网页设计广州网站百度人工客服电话怎么转人工
  • 恒信在线做彩票的是什么样的网站常见的微信营销方式有哪些
  • 网站建设的英文自媒体营销的策略和方法
  • 一个虚拟主机可以做几个网站代做百度收录排名
  • 做网站怎么兼职网络销售话术900句
  • 用一个织梦程序做两个网站营销型网站重要特点是
  • 进入网站服务器怎么做seo关键词优化排名
  • 羽毛球赛事视频网站seo的方法
  • 专业3合1网站建设价格百度指数数据分析平台
  • 图片类网站建设军事网站大全军事网
  • 多语言网站建设平台代理竞价是什么意思
  • 南阳网站推广seo辅助优化工具
  • 有下划线的网址是什么网站seo优化教程下载
  • 京东网站建设思维导图东莞关键词排名快速优化
  • 从做系统网站的收藏怎么找回自己开发网站怎么盈利
  • 手机网站首页布局设计推广之家app下载
  • 上海代办公司注册企业网站排名优化方案
  • 做兼职网站willfast优化工具下载
  • 一般网站建设公司软文营销的宗旨是什么