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. svn clean up 出错解决方案

    问题描述:svn执行clean up命令时报错"Previous operation has not finished; run 'cleanup' if it was interrupte ...

  2. TypeScript 学习四 面向对象的特性,泛型,接口,模块,类型定义文件*.d.ts

    1,面向对象的特性一:类,继承,见上一篇博客: 2,面向对象的特性二: 泛型(generic):参数化的类型,一般用来限制集合的内容:指定只能放某个类型的元素 如下图中的尖括号中的Person,就代表 ...

  3. css基础和心得(二)

    css中的某些样式是具有继承性的.它允许样式不仅应用于某个特定html标签元素 而且应用于其后代.如: p{color:red;}  <p>dsffd<spans>sdfasd ...

  4. 一篇顺手的Ubuntu+caffe配置笔记

    主要参考: https://github.com/lbzhang/dl-setup http://ouxinyu.github.io/Blogs/20151108001.html http://www ...

  5. Tiny6410之LED裸机驱动

    操作步骤: 第一步:查看开发板电路原理图 找到LED 的管脚所对应的寄存器 nLED_1 - GPK4 nLED_2 - GPK5 nLED_3 - GPK6 nLED_4 - GPK7 由原理图可知 ...

  6. redis cluster中添加删除重分配节点例子

    redis cluster配置好,并运行一段时间后,我们想添加节点,或者删除节点,该怎么办呢. 一,redis cluster命令行     //集群(cluster)  CLUSTER INFO 打 ...

  7. mysql denied for user 'root'@'localhost'

    Access[root@log01 ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'r ...

  8. 非root用户搭建hadoop伪分布式

    0.安装软件列表 jdk-7u25-linux-x64.tar.gz hadoop-2.5.0.tar.gz hadoop-native-64-2.5.0.tar   1.准备Linux环境(root ...

  9. php 设置白名单ip

    //检查白名单ip private function _checkAllowIp() { $allowIp = ['203.195.156.12']; $ip = $this->getIp(); ...

  10. vue 相对其他热门 框架 优点 --- 待续

    react vs  vue 1. 处理动画 vue 更有优势 , 这是由于 React 有大量的检查机制 2.性能更高, 在React中,你需要在每个地方去实现 shouldComponentUpda ...