Shader之ECEF——LLH
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的更多相关文章
- OpenGL shader 中关于顶点坐标值的思考
今天工作中需要做一个事情: 在shader内部做一些空间距离上的计算,而且需要对所有的点进行计算,符合条件的显示,不符合条件的点不显示. 思路很简单,在vertex shader内知道顶点坐标,进行计 ...
- CSharpGL(14)用geometry shader渲染模型的法线(normal)
+BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(14)用geometry shader渲染模型的法线(normal) +BIT祝威+悄悄在此留下版了个权的信息说: 2016-08-13 ...
- 【译】Unity3D Shader 新手教程(6/6) —— 更好的卡通Shader
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 动机 如果你想了解以下几件事,我建议你阅读以下这篇教程: 想知道如何写一个multipass的toon shade ...
- 【译】Unity3D Shader 新手教程(5/6) —— Bumped Diffuse Shader
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 动机 如果你满足以下条件,我建议你阅读这篇教程: 你想学习片段着色器(Fragment Shader). 你想实现 ...
- 【译】Unity3D Shader 新手教程(4/6) —— 卡通shader(入门版)
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 暗黑系 动机 如果你满足以下条件,我建议你阅读这篇教程: 你想了解更多有关表面着色器的细节知识. 你想实现一个入门 ...
- 【译】Unity3D Shader 新手教程(3/6) —— 更加真实的积雪
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 如果你满足以下条件,我建议你阅读这篇教程: 你想知道如何在表面着色器中进行混色(blend colour) 你想实 ...
- 【译】Unity3D Shader 新手教程(2/6) —— 积雪Shader
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 如果你是一个shader编程的新手,并且你想学到下面这些酷炫的技术,我觉得你可以看看这篇教程: 实现一个积雪效果的 ...
- 【译】Unity3D Shader 新手教程(1/6)
本文为翻译,附上原文链接. 转载请注明出处--polobymulberry-博客园. 刚开始接触Unity3D Shader编程时,你会发现有关shader的文档相当散,这也造成初学者对Unity3D ...
- 多材质(Shader)实现
最近在cocos creator上打算写个U3D中shader功能的插件(能在属性面板调整shader属性). 对其中一个功能有点疑惑,就是U3D中一个渲染物体上可以挂多个材质,后来查询了下,一个物体 ...
随机推荐
- python 算法练习
根据给定的线性函数来确定函数的表达形式: examples: get_function([0,1,2,3,4]) => f(x)=x get_function([1,4,7,10,13]) =& ...
- unity3d使用litjson中文显示的问题
我们在使用litjson时它的编码方式是unicode的,所以我将json转成string输出时显示的是unicode的编码.这样我们显示或者保存中文时不是很方便.我们可以将中文的unicode转成能 ...
- CodeForces 711A Bus to Udayland
简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...
- Signalr 实现心跳包
项目分析: 一个实时的IM坐席系统,客户端和坐席使用IM通信,客户端使用android和ios的app,坐席使用web. web端可以保留自己的登录状态,但为防止意外情况的发生(如浏览器异常关闭,断网 ...
- openstack私有云布署实践【11.2 计算nova - compute节点配置(办公网环境)】
这里我只使用compute1节点配置为示例,其它节点的配置基本是一样的,只是声明的管理IP不同而已 计算节点 # yum install openstack-nova-compute sysfsu ...
- 《C++反汇编与逆向分析技术揭秘》——观察各种表达式的求值过程
---恢复内容开始--- 加法: 示例: 常量相加,则在编译期间就计算出两个常量相加后的结果,直接将这个结果参与运算,减少了运行期的计算.当有变量参与运算时,会先取出内存中的数据,放入通用寄存器中,再 ...
- 关于FlagsAttribute
最近在看C#本质论,有介绍FlagsAttribute的特性,看了下源码,发现只是一个简单的特性class和一个构造函数. 调试了一下.NET的源码,发现在console.writeline(***) ...
- CentOS 6.5静态IP的设置(NAT和桥接都适用)
CentOS 6.5静态IP的设置(NAT和桥接都适用) 为了方便,用Xshell来.并将IP设置为静态的.因为,在CentOS里,若不对其IP进行静态设置的话,则每次开机,其IP都是动态变化的,这样 ...
- tomcat解压版安装(摘自网络)
配置Tomcat[解压版] 选择解压版的Tomcat的理由是可以让我们使用多个Tomcat,但是配置上就会出现一些问题,需要我们手动进行更改配置.我的Tomcat版本是:apache-tomcat-6 ...
- swift label不同颜色、不同字体
let string = "点击注册按钮,即表示您已同意隐私条款和服务协议" let ranStr = "同意" let attrstring:NSMutabl ...