For this particular application, we're loading terrain layers from an earth file for the sole purpose of pinging for terrain elevation (and terrain normal hopefully) information for a given lat/lon position. We're using the ElevationPool class for getting the elevation but we're at a loss on how to get the terrain normal information for the same position.
We do have access to the mapNode on down but we're not doing any rendering so pinging the scenegraph isn't an option for this application. Because of this, am I premature in concluding that using a shader to extract out the normal isn't an option?
Regarding the approach to use the ElevationTexture class, I understand now (thanks to your answer) on how to use the getNormal(...) in that class. What I'm unclear on is how to reference the ElevationTexture class itself. It doesn't appear to be as accessible as the ElevationPool class. Any examples on its usage in the osgEarth source appear to be used internally.
Are there examples on how an application can set it up and use it externally?
The information you provided answers a lot of questions for me.
In answer to your question, we're needing the highest resolution available from the source terrain data specified in the earth file.
It looks like there's a way forward (albeit painfully) to get the normal but I am concerned about the need to generate the normalMap each time we grab a tile to get the normal.
Given that our application needs to obtain the elevation and normal at a location as quickly as possible, this might not be acceptable unless we can do some sort of preprocessing beforehand. Creating a normalMap each time a query is being made probably won't work in our case due to lack of performance.
Is there a way to detect if we need to grab a new tile and rebuild the normalMap based on a position change?
I'm starting to think that it might be less expensive to use the ElevationPool class and use a Sobel operator on nearest height neighbors to calculate a normal. Either that or extend the current interface to return an explicit normal along with the elevation at a given location...
int samples = mapNode->getMap()->getElevationPool()->sampleMapCoords(points, &workingSet, nullptr);
My question is about the "resolution" value. I know it's supposed to be in the same coord space as the SRS (i.e. lat/lon in this case). Right now, I'm setting it to be:
resolution = 30.0 / 111000.0;
which is mapping meters to degrees. I chose 30 meters because our highest level of DTED we can reference corresponds to DTED level 2 which is a spacing of ~30 meters per elevation post.
Am I on the right track here in the usage of the resolution value in the above calls? Also, what happens if for some areas we don't have DTED level 2 and we resort to DTED level 1 or 0? Will I need to dynamically change the resolution value for the calls above? If so, how would I go about detecting the change during runtime to make the adjustment to the resolution value?