uniform mat4 osg_ViewMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform mat4 osg_ModeViewMatrix;
uniform mat4 osg_ProjectionMatrix;
uniform float osg_SimulationTime;
uniform sampler2D ocean_data;
const float radiusEquator = 6378137.0;
const float radiusPolar = 6356752.3142;
vec3 ECEF_TO_LLH(in vec3 xyz)
{
float p = sqrt(xyz.x * xyz.x + xyz.y * xyz.y);
float theta = atan(xyz.z * radiusEquator,(p * radiusPolar));
float eDashSquared = (radiusEquator * radiusEquator - radiusPolar * radiusPolar)/(radiusPolar * radiusPolar);
float sin_theta = sin(theta);
float cos_theta = cos(theta); float flattening = (radiusEquator - radiusPolar)/radiusEquator;
float eccentricitySquared = * flattening - flattening * flattening;
float latitude = atan((xyz.z + eDashSquared * radiusPolar * sin_theta * sin_theta * sin_theta)/(p - eccentricitySquared * radiusEquator * cos_theta * cos_theta * cos_theta));
float longitude = atan(xyz.y,xyz.x);
float sin_latitude = sin(latitude);
float N = radiusEquator /sqrt(1.0 - eccentricitySquared * sin_latitude * sin_latitude);
float h = p/cos(latitude) - N;
latitude = degrees(latitude);
longitude = degrees(longitude);
return vec3(latitude, longitude, h);
} vec3 LLH_TO_ECEF(in vec3 llh)
{
float flattening = (radiusEquator - radiusPolar)/radiusEquator;
float eccentricitySquared = * flattening - flattening * flattening;
float sin_latitude = sin(llh.x);
float cos_latitude = cos(llh.x);
float sin_longitude = sin(llh.y);
float cos_longitude = cos(llh.y);
float N = radiusEquator / sqrt(1.0 - eccentricitySquared * sin_latitude * sin_latitude);
float x = (N + llh.z) * cos_latitude * cos_longitude;
float y = (N + llh.z) * cos_latitude * sin_longitude;
float z = (N * ( - eccentricitySquared) + llh.z) * sin_latitude;
return vec3(x, y, z);
}

Shader之ECEF——LLH的更多相关文章

  1. OpenGL shader 中关于顶点坐标值的思考

    今天工作中需要做一个事情: 在shader内部做一些空间距离上的计算,而且需要对所有的点进行计算,符合条件的显示,不符合条件的点不显示. 思路很简单,在vertex shader内知道顶点坐标,进行计 ...

  2. CSharpGL(14)用geometry shader渲染模型的法线(normal)

    +BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(14)用geometry shader渲染模型的法线(normal) +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 ...

  3. 【译】Unity3D Shader 新手教程(6/6) —— 更好的卡通Shader

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 动机 如果你想了解以下几件事,我建议你阅读以下这篇教程: 想知道如何写一个multipass的toon shade ...

  4. 【译】Unity3D Shader 新手教程(5/6) —— Bumped Diffuse Shader

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 动机 如果你满足以下条件,我建议你阅读这篇教程: 你想学习片段着色器(Fragment Shader). 你想实现 ...

  5. 【译】Unity3D Shader 新手教程(4/6) —— 卡通shader(入门版)

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 暗黑系 动机 如果你满足以下条件,我建议你阅读这篇教程: 你想了解更多有关表面着色器的细节知识. 你想实现一个入门 ...

  6. 【译】Unity3D Shader 新手教程(3/6) —— 更加真实的积雪

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 如果你满足以下条件,我建议你阅读这篇教程: 你想知道如何在表面着色器中进行混色(blend colour) 你想实 ...

  7. 【译】Unity3D Shader 新手教程(2/6) —— 积雪Shader

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 如果你是一个shader编程的新手,并且你想学到下面这些酷炫的技术,我觉得你可以看看这篇教程: 实现一个积雪效果的 ...

  8. 【译】Unity3D Shader 新手教程(1/6)

    本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 刚开始接触Unity3D Shader编程时,你会发现有关shader的文档相当散,这也造成初学者对Unity3D ...

  9. 多材质(Shader)实现

    最近在cocos creator上打算写个U3D中shader功能的插件(能在属性面板调整shader属性). 对其中一个功能有点疑惑,就是U3D中一个渲染物体上可以挂多个材质,后来查询了下,一个物体 ...

随机推荐

  1. CAD打开缓慢问题解决方法

    打开AutoCAD很卡,大概需要1分钟 打开Internet Explorer,点击工具菜单,打开"Internet选项",去勾选"检查发行商的证书是否吊销", ...

  2. mysql与oracle在groupby语句上的细节差异

    前言 之所以去纠那么细节的问题,是因为之前有过一个这样的场景: 有个同学,给了一条数据库的语句给我,问,为啥这样子的语句在oracle语句下执行不了. select * from xx where x ...

  3. 项目中dubbo的使用

    导语:Dubbo是阿里巴巴的一个分布式服务的开源框架,致力于提供高性能和透明化的RPC远程服务调用方案,是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000 ...

  4. 在CentOS上安装第三方软件库EPEL

    Extra Packages for Enterprise Linux (EPEL)[企业版 Linux 附加软件包(以下简称 EPEL)]是一个由特别兴趣小组创建.维护并管理的,针对 红帽企业版 L ...

  5. MFC多线程各种线程用法 .

    http://blog.csdn.net/qq61394323/article/details/9328301 一.问题的提出 编写一个耗时的单线程程序: 新建一个基于对话框的应用程序SingleTh ...

  6. java 打开浏览器 url

    public class openBrowers { public static void main(String[] args) { try { //String url = "http: ...

  7. 手动安装VS code 插件

    现在安装包: 通过修改下面的地址参数:https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publish ...

  8. Knockout js 绑定 radio 时,当绑定整形的时候,绑定不生效

    解决方案: 使用checkedValue和checked 组合,如下代码. <div><input type="radio" name="flavorG ...

  9. winform开线程,避免页面假死

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. H264帧内预测模式编号的编码过程

    1 本文词汇约定 宏块:H264编码基本单元,16x16像素(或采样)构成 块:   由8x8像素(或采样)构成的单位 子块:   由4x4像素(或采样)构成的单位 2 帧内亮度预测模式 H264规范 ...