or Creating an IR effect in WorldWind Java

或者在WorldWind Java中创建一个IR效果。

I need to emulate an infrared (IR) view in WorldWind, and I'm not sure about the best way to go about this. I should point out that I do not need to simulate IR (i.e. no heat maps) -- I just need to produce a reasonable facsimile of a black-and-white IR display. I have very limited graphics knowledge and no prior experience with OpenGL, JOGL, or WorldWind.

我需要在WorldWind模拟一个红外(IR)视图,我不确定最好的方法是什么。我应该指出,我不需要模拟IR(也就是没有热图)——我只需要制作一个黑白红外显示器的合理的传真。我的图形知识非常有限,没有OpenGL, JOGL,或WorldWind的经验。

Based on my research so far, it seems that the best approach is to use a custom shader. However, as far as I can tell, WorldWind provides no high-level shader support.

根据我目前的研究,最好的方法似乎是使用自定义着色器。然而,据我所知,WorldWind没有提供高级的着色支持。

I found the following relevant threads on a WorldWind forum, but I'm still not sure how to proceed:

我在一个WorldWind论坛上找到了以下相关的帖子,但我仍然不知道该如何进行:

  • GLSL Shader support that renders tiles correctly
  • GLSL着色支持,以正确地渲染贴图。
  • Updating GLSL support with new JOGL
  • 使用新的JOGL更新GLSL支持。
  • Normal mapping (GLSL shader)
  • 正常的映射(GLSL材质)
  • GLSL fragment shader problem
  • GLSL片段着色器问题

To clarify my question(s):

澄清我的问题:

How do I integrate a GLSL shader into a WorldWind application, if that is in fact the best approach? If not, how should I implement this effect?

如果这是最好的方法,我如何将一个GLSL着色器集成到一个WorldWind应用程序中呢?如果没有,我该如何实现这个效果?

1 个解决方案

#1


1

This turned out to be fairly straightforward, thanks to the contributions of tve and what_nick in this thread: GLSL Shader support that renders tiles correctly. Specifically, I reused the GLSL class contributed by tve (in shader_support_051308.zip) and modified what_nick's sample code.

由于tve和这个线程中的what_nick的贡献,这个结果非常简单:GLSL着色支持可以正确地渲染贴图。具体来说,我重用了tve(在shader_support_051308.zip)中提供的GLSL类,并修改了what_nick的样例代码。

I defined a DecoratedLayer class that allows any layer to be "decorated" with a new rendering strategy, then defined a ShadingDecorator that sets up the GLSL shader before delegating to the underlying layer's render method:

我定义了一个DecoratedLayer类,它允许任何层使用新的呈现策略“修饰”,然后定义一个ShadingDecorator,它在委托给底层的呈现方法之前设置GLSL着色器:

public class DecoratedLayer implements Layer {
    private final Layer _layer;
    private final I_LayerDecorator _decorator;

    public DecoratedLayer(Layer layer, I_LayerDecorator decorator) {
        _layer = layer;
        _decorator = decorator;
    }

    @Override
    public void preRender(DrawContext dc) {
       _decorator.preRender(dc, _layer);
    }

    @Override
    public void render(DrawContext dc) {
       _decorator.render(dc, _layer);
    }

    // all other methods delegate to _layer
}

public class ShadingDecorator implements I_LayerDecorator {
    private GLSL glsl;
    private final File vertfile;
    private final File fragfile;

    public ShadingDecorator(final File vertexShaderFile, 
                            final File fragmentShaderFile) {
        vertfile = vertexShaderFile;
        fragfile = fragmentShaderFile;
    }

    @Override
    public void preRender(DrawContext dc, Layer layer) {
        if (glsl == null) {
            glsl = new GLSL(dc.getGL());
            glsl.loadVertexShader(vertfile);
            glsl.loadFragmentShader(fragfile);
        }
        layer.preRender(dc);
    }

    @Override
    public void render(DrawContext dc, Layer layer) {
        if (glsl != null) {
            glsl.useShaders();
            glsl.startShader();
            GL gl = dc.getGL();
            gl.glUniform1i(glsl.getUniformLocation("tile_image"), 0);

            layer.render(dc);

            glsl.endShader();
        }
    }
}

More work is needed to make this fully general, but this should be a reasonable starting point.

需要做更多的工作才能使这一切变得全面,但这应该是一个合理的起点。

更多相关文章

  1. spring框架中一个跟String的trim方法一样的方法
  2. 为可执行文件夹提供自定义图像
  3. 当只使用get()和set()方法时,用原始类型替换AtomicBoolean?
  4. java中循环遍历删除List和Set集合中元素的方法
  5. jsp中如何使用javabeans,如何使用一个已经定义好的类
  6. 80端口占用异常解决方法java.net.BindException: Address alread
  7. java写入文件的几种方法小结
  8. OOP面向对象编程(一)-------方法的重载
  9. Java之美[从菜鸟到高手演变]之Java学习方法

随机推荐

  1. Google地图不显示[重复]
  2. IFrame中的Div没有达到给定的高度
  3. Django和Html有什么区别?
  4. jQuery更改活动类图标的状态
  5. 如何让我的固定宽度移动网站始终显示“完
  6. HTML5用户身份认证源代码:注册、登录、会
  7. Eclipse中以html格式高亮显示velocity文
  8. ExtJS的使用方法汇总(4)——拖放以及弹出
  9. HTML5晃动DeviceMotionEvent事件
  10. CSS3列 - 添加第二个元素后的额外宽度