使用 WebGL 进行实时 DEM 数据渲染
我是Web编程的新手,需要使用OpenGL对大型DEM数据集进行实时渲染。 请指导我如何使用WebGL和JavaScript实现它。 我用于渲染的方法是铺有数据并加载所需的瓷砖。
另外,是否会涉及任何服务器端脚本?如果是这样,我应该使用哪种语言?
I am new to web programming and I need to do real time rendering of large DEM datasets using openGL.
Please guide me how to achieve it using WebGL and javascript.
the approach i am using for rendering is tiling the data and loading the tiles wen needed.
Also, would any server side scripting be involved in this ?If so, which language should I use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 https://github.com/OpenWebGlobe/WebViewer
you can use https://github.com/OpenWebGlobe/WebViewer
好的,这是一个很大的问题。我使用JS进行了一些地形渲染,尽管它仅限于一个瓷砖。
我认为您所描述的是WebGL和JavaScript的可能性,并且可以说是替代方案。 WebGl有很多教程(例如基于原始的Nehe OpenHE OpenGl Tutorials )。 JavaScript是一种灵活而表现力的语言,您可以在它上找到很多资源(道格·克罗克福德(Doug Crockford)拥有一些最佳的见解和准则)。
至于您的特定问题,我将为您的瓷砖生成许多描述符,包括每个瓷砖内的尺寸,位置以及最大和最小高度。然后,使用观看式挫折(在您的“相机”前可见的区域)和瓷砖的边界(由它们的位置和最大/最小高度给出)来确定哪些可见。您可以选择在给定的最大观看距离后丢弃任何。
有了一组可见的瓷砖,您现在可以单独渲染它们。
我不知道您的瓷砖是什么格式,要么是高度的网格(可以方便地存储为标准图像)或矢量描述,但这决定了您如何呈现它们。对于高度的网格,渲染它们的最简单方法是几条三角形。这意味着创建一些大型顶点缓冲区,但是您也许可以做一些聪明的事情。除了一定数量的瓷砖之外,您还必须管理哪些图块作为WebGL缓冲区数据(和未压缩图像)以及释放哪些图像。
由于您的问题是相当一般和高水平的,因此我的答案相似。这听起来像是一个有趣的项目,我会很高兴您可能会有任何更具体的问题。
Ok, this is quite a big question. I've done some terrain rendering using JS, although it was limited to one tile.
I think what you describe is certainly possible with WebGL and Javascript, and arguably better than the alternatives. There are many tutorials on getting started with WebGL (e.g. this one, based on the original NeHe OpenGL tutorials). Javascript is a flexible and expressive language, which you can find a lot of resources on (Doug Crockford having some of the best insights and guidelines).
As for your particular problem, I would generate a number of descriptors for your tiles, including size, position and maximum and minimum heights within each tile. Then use the viewing frustrum (the area visible in front of your 'camera') and the bounding cuboid of your tiles (given by their position and max/min heights) to determine which ones are visible. You may choose to discard any after a given maximum viewing distance.
Having got a set of visible tiles, you can now render them individually.
I don't know what format your tiles are in, either a grid of heights (which can conveniently be stored as standard images) or a vector description, but that determines how you will be rendering them. For the grid of heights, the simplest way to render them is as several strips of triangles. That means creating some large vertex buffers, but you may be able to do something clever. Beyond a certain number of tiles, you'll have to manage which ones are kept as WebGL buffer data (and uncompressed images) and which ones are freed.
Since your question is quite general and high level, I'll keep my answer similar. This sounds like an interesting project and I'd be happy to any more specific questions you might have.