TerrainShader through code

classic Classic list List threaded Threaded
2 messages Options
Tension Tension
Reply | Threaded
Open this post in threaded view
|

TerrainShader through code

Hi,

I need to apply some vertical scale to terrain, my research lead me to terrainshader (examples shows only earth files). How can i use it through code?
Tension Tension
Reply | Threaded
Open this post in threaded view
|

Re: TerrainShader through code

I forgot: osgEarth 3.1 + osg 3.6.5

The only way i found right now is to make TerrainShaderOptions header public, then:
    osgEarth::TerrainShader::TerrainShaderOptions opt;
    osgEarth::TerrainShader::TerrainShaderOptions::Code code;
    code._source = terrainShaderSrc;
    opt.code().push_back(code);
    _mapNode->addExtension(osgEarth::Extension::create("terrainshader", opt));

I guess i can do it even without public TerrainShaderOptions but with Config instead.

My other questions is:
- can i somehow change uniform of this shader (scale in this case) in runtime?
- can i make it properly work with ContourMapLayer?
- can i do something with terrain cull when my camera is close to terrain?

Thanks.