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. Sublime Text3下如何快速搭建开发环境

    安装好Sublime Text3之后,简单几步就可以搭建一个好用的开发环境. sublime的设置包括自定义设置以及插件系统. 打开菜单Preferences -> Settings,编辑自定义 ...

  2. yarn的调度器

    三种调度器 1.FIFO Scheduler 把应用按提交的顺序排成一个队列,这是一个先进先出队列,在进行资源分配的时候,先给队列中最头上的应用进行分配资源,等最前面的应用需求满足后再给下一个分配,以 ...

  3. winform自动更新并实现文件的批量异步下载

    public partial class update : Form    {        private WebClient client;        int downfilenum = 0; ...

  4. CentOS7安装Zabbix

    一.Zabbix简介 Zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案. Zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系 ...

  5. laravel 添加第三方扩展库

    确定需要安装的位置 common.php测试代码 打开cmd 跳转到项目根目录下运行命令 composer install 打开文件 vender/composer/autoload_classmap ...

  6. 设计模式 -- 代理模式 (Proxy Pattern)

    定义: 为其他对象提供一种代理以控制对这个对象的访问: 角色: 1,抽象主题类,(接口或者抽象类),抽象真实主题和代理的共有方法(如下Subject类): 2,具体实现的主题类,继承或者实现抽象主题类 ...

  7. CodeForces 711D Directed Roads

    计数,模拟. 首先观察一下给出的图的特点: $1.$一定存在环. $2.$可能存在多个环. 我们对每个环计算方案数,假设环$C$上包含$x$条边,那么把环$C$破坏掉的方案数有${2^x} - 2$种 ...

  8. javabean+servlet+jsp实现分页

    前端实现用ligerUI实现分页,感觉用框架确实简单,闲着无聊,模拟着liger的分页界面实现了一遍(只要是功能,样式什么无视) 这里用基础的三层架构+servlet+jsp实现,思路很简单,把所有分 ...

  9. Centos 下安装Zabbix Linux 客户端

    今天在linux上安装了客户端,过程如下: (1)下载zabbix客户端软件 wget www.zabbix.com/downloads/2.0.3/zabbix_agents_2.0.3.linux ...

  10. centos php nginx 添加到service

    1. nginx A. # vi /etc/init.d/nginx B. #!/bin/sh # Comments to support chkconfig on RedHat Linux # ch ...