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
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.
需要做更多的工作才能使这一切变得全面,但这应该是一个合理的起点。