zoukankan      html  css  js  c++  java
  • unity quaternion vector

    做脚印呢

    做了曲面细分和decal两种

    先用正交camera生成 高度图 

    采样uv由pos 从world到camera space生成

    unity对tessellation的支持限制还是比较大的 只能用surfaceshader 

    并且开tesse的 surfaceshader就不支持自己vs 到ps 传自定义数据了

    不配合光照的话 (normal)新增的顶点 看不清楚

    unity的 surfaceshader如果不能支持 tessellation 生成的顶点normal传到ps 这功能就没多少意义

    要生成朝向角色运动方向的脚印 需要生成一组顶点数据 

    这个朝向我用四元数算的 

    temp = rot * new Vector3(-1f * scale, 0, 1f * scale);//在原点用quaternionXvector3 得到朝向 
    va[x++] = pos + temp;              //之后应用到 点所在的位置 ,就相当于 挪到loacalspace rotation之后到world space

                            //不这么做直接rotationXpos得到的是 ((0,0,0)-point)这个vector沿着quarternion旋转之后的vector

                              //Debug.DrawLine(start, dir, Color.green);可以用来debug
    temp = rot * new Vector3(-1f * scale, 0, -1f * scale);
    va[x++] = pos + temp;

    temp = rot * new Vector3(1f * scale, 0, -1f * scale);
    va[x++] = pos + temp;
    temp = rot * new Vector3(1f * scale, 0, 1f * scale);
    va[x++] = pos + temp;

    {
    mesh = new Mesh();
    mesh.hideFlags = HideFlags.DontSave;
    mesh.vertices = va;
    mesh.uv = ta;
    mesh.SetIndices(ia, MeshTopology.Triangles, 0);
    }

    Graphics.DrawMesh(mesh, Matrix4x4.identity, markMat, 16, camHeight);//16 layer decal

  • 相关阅读:
    《图解HTTP》简单的HTTP协议
    《图解HTTP》web及网络基础
    尚硅谷--雷丰阳--ElasticSearch 7.4.2版本 -- 有道云笔记
    ElasticSearch _bulk批量插入报错
    SpringBoot利用Filter来解决跨域问题
    js中数组的常用方法
    Mysql时间加减函数
    mybatis映射文件中不能使用">""<""&"问题
    博客园样式第二版
    GO学习笔记之 map
  • 原文地址:https://www.cnblogs.com/minggoddess/p/8962970.html
Copyright © 2011-2022 走看看