<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://old.web3d.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Plesch</id>
		<title>Web3D.org - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://old.web3d.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Plesch"/>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php/Special:Contributions/Plesch"/>
		<updated>2026-04-25T19:58:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.25.1</generator>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8982</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8982"/>
				<updated>2015-07-27T03:51:52Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Implementation and concrete examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range.&lt;br /&gt;
&lt;br /&gt;
One of the examples shows how it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This requires the &amp;quot;NEAREST&amp;quot; magnificationFilter of the TextureProperty node, as well as &amp;quot;CLAMP&amp;quot; boundary modes.&lt;br /&gt;
&lt;br /&gt;
The python matplotlib library offers a large number of color maps:&lt;br /&gt;
&lt;br /&gt;
https://github.com/matplotlib/matplotlib/blob/48841158e4eb81fcc79b42747a705cb36920ee1b/lib/matplotlib/_cm.py&lt;br /&gt;
&lt;br /&gt;
It would be perhaps worthwhile to convert those to 1d PixelTexture, with 5, 10, 20, 50, and 100 colors.&lt;br /&gt;
&lt;br /&gt;
Here is a even larger selection of color maps&lt;br /&gt;
&lt;br /&gt;
http://www.ncl.ucar.edu/Document/Graphics/color_table_gallery.shtml&lt;br /&gt;
&lt;br /&gt;
which are available in a simple rgb format:&lt;br /&gt;
&lt;br /&gt;
http://www.ncl.ucar.edu/Document/Graphics/ColorTables/Files/&lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question is if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary/beneficial to introduce a GeoTextureCoordinateGenerator node ? A GeoTextureCoordinateGenerator node would have a geoSystem field which would define the reference ellipsoid for the custom height range.  &lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light node direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.&lt;br /&gt;
&lt;br /&gt;
Here is a scene which shows how it is possible to use a SphereSensor to interactively control the light direction:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture//terrain_spheresensor.xhtml&lt;br /&gt;
&lt;br /&gt;
In it the SphereSensor rotation output is routed to a transform which rotates the light with its initial direction.&lt;br /&gt;
&lt;br /&gt;
The scene also uses x3dom experimental shadowing which appears to produce pretty correct shadows.&lt;br /&gt;
&lt;br /&gt;
It should be possible to restrict lights to certain objects, eg. use light scoping. This way one could have shaded relief with a low sun on terrain but &amp;quot;normal&amp;quot; lighting for all other objects. However, x3dom currently does not support light scoping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. &lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if &lt;br /&gt;
it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8981</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8981"/>
				<updated>2015-07-26T12:18:06Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range.&lt;br /&gt;
&lt;br /&gt;
One of the examples shows how it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This requires the &amp;quot;NEAREST&amp;quot; magnificationFilter of the TextureProperty node, as well as &amp;quot;CLAMP&amp;quot; boundary modes.&lt;br /&gt;
&lt;br /&gt;
The python matplotlib library offers a large number of colormaps:&lt;br /&gt;
&lt;br /&gt;
https://github.com/matplotlib/matplotlib/blob/48841158e4eb81fcc79b42747a705cb36920ee1b/lib/matplotlib/_cm.py&lt;br /&gt;
&lt;br /&gt;
It would be perhaps worthwhile to convert those to 1d PixelTexture, with 5, 10, 20, 50, and 100 colors. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question is if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary/beneficial to introduce a GeoTextureCoordinateGenerator node ? A GeoTextureCoordinateGenerator node would have a geoSystem field which would define the reference ellipsoid for the custom height range.  &lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light node direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.&lt;br /&gt;
&lt;br /&gt;
Here is a scene which shows how it is possible to use a SphereSensor to interactively control the light direction:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture//terrain_spheresensor.xhtml&lt;br /&gt;
&lt;br /&gt;
In it the SphereSensor rotation output is routed to a transform which rotates the light with its initial direction.&lt;br /&gt;
&lt;br /&gt;
The scene also uses x3dom experimental shadowing which appears to produce pretty correct shadows.&lt;br /&gt;
&lt;br /&gt;
It should be possible to restrict lights to certain objects, eg. use light scoping. This way one could have shaded relief with a low sun on terrain but &amp;quot;normal&amp;quot; lighting for all other objects. However, x3dom currently does not support light scoping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. &lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if &lt;br /&gt;
it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8980</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8980"/>
				<updated>2015-07-26T12:13:33Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Additional considerations for specification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range.&lt;br /&gt;
&lt;br /&gt;
One of the examples shows how it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This requires the &amp;quot;NEAREST&amp;quot; magnificationFilter of the TextureProperty node, as well as &amp;quot;CLAMP&amp;quot; boundary modes.&lt;br /&gt;
&lt;br /&gt;
The python matplotlib library offers a large number of colormaps:&lt;br /&gt;
&lt;br /&gt;
https://github.com/matplotlib/matplotlib/blob/48841158e4eb81fcc79b42747a705cb36920ee1b/lib/matplotlib/_cm.py&lt;br /&gt;
&lt;br /&gt;
It would be perhaps worthwhile to convert those to 1d PixelTexture,&lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question is if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary/beneficial to introduce a GeoTextureCoordinateGenerator node ? A GeoTextureCoordinateGenerator node would have a geoSystem field which would define the reference ellipsoid for the custom height range.  &lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light node direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.&lt;br /&gt;
&lt;br /&gt;
Here is a scene which shows how it is possible to use a SphereSensor to interactively control the light direction:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture//terrain_spheresensor.xhtml&lt;br /&gt;
&lt;br /&gt;
In it the SphereSensor rotation output is routed to a transform which rotates the light with its initial direction.&lt;br /&gt;
&lt;br /&gt;
The scene also uses x3dom experimental shadowing which appears to produce pretty correct shadows.&lt;br /&gt;
&lt;br /&gt;
It should be possible to restrict lights to certain objects, eg. use light scoping. This way one could have shaded relief with a low sun on terrain but &amp;quot;normal&amp;quot; lighting for all other objects. However, x3dom currently does not support light scoping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. &lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if &lt;br /&gt;
it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8977</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8977"/>
				<updated>2015-07-26T01:04:11Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Implementation and concrete examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range.&lt;br /&gt;
&lt;br /&gt;
One of the examples shows how it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This requires the &amp;quot;NEAREST&amp;quot; magnificationFilter of the TextureProperty node, as well as &amp;quot;CLAMP&amp;quot; boundary modes.&lt;br /&gt;
&lt;br /&gt;
The python matplotlib library offers a large number of colormaps:&lt;br /&gt;
&lt;br /&gt;
https://github.com/matplotlib/matplotlib/blob/48841158e4eb81fcc79b42747a705cb36920ee1b/lib/matplotlib/_cm.py&lt;br /&gt;
&lt;br /&gt;
It would be perhaps worthwhile to convert those to 1d PixelTexture,&lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light node direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.&lt;br /&gt;
&lt;br /&gt;
Here is a scene which shows how it is possible to use a SphereSensor to interactively control the light direction:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture//terrain_spheresensor.xhtml&lt;br /&gt;
&lt;br /&gt;
In it the SphereSensor rotation output is routed to a transform which rotates the light with its initial direction.&lt;br /&gt;
&lt;br /&gt;
The scene also uses x3dom experimental shadowing which appears to produce pretty correct shadows.&lt;br /&gt;
&lt;br /&gt;
It should be possible to restrict lights to certain objects, eg. use light scoping. This way one could have shaded relief with a low sun on terrain but &amp;quot;normal&amp;quot; lighting for all other objects. However, x3dom currently does not support light scoping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. &lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if &lt;br /&gt;
it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8976</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8976"/>
				<updated>2015-07-26T00:58:04Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Shaded relief effects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light node direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.&lt;br /&gt;
&lt;br /&gt;
Here is a scene which shows how it is possible to use a SphereSensor to interactively control the light direction:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture//terrain_spheresensor.xhtml&lt;br /&gt;
&lt;br /&gt;
In it the SphereSensor rotation output is routed to a transform which rotates the light with its initial direction.&lt;br /&gt;
&lt;br /&gt;
The scene also uses x3dom experimental shadowing which appears to produce pretty correct shadows.&lt;br /&gt;
&lt;br /&gt;
It should be possible to restrict lights to certain objects, eg. use light scoping. This way one could have shaded relief with a low sun on terrain but &amp;quot;normal&amp;quot; lighting for all other objects. However, x3dom currently does not support light scoping.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. &lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if &lt;br /&gt;
it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8975</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8975"/>
				<updated>2015-07-25T19:02:58Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Shaded relief effects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
Using a geolocated directional light works quite well. Here is an animated example:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
The example uses an NormalInterpolator node routed to the light direction field. The GeoLocation makes sure that the light direction is rotated such that the horizontal orientation corresponds to the local tangential plane to the geoid. This way the light direction can be specified in the standard X3D reference system, with (0 0 1) pointing to the north.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to ]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8974</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8974"/>
				<updated>2015-07-25T17:59:40Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Motivation and initial discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height. Special modes for geocentric coordinates would address this requirement.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction. This is the approach which was adopted.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8973</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8973"/>
				<updated>2015-07-25T17:30:54Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Motivation and initial discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
: Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
# It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
# Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
# If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8972</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8972"/>
				<updated>2015-07-25T17:26:56Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Shaded relief effects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be quite insightful to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8971</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8971"/>
				<updated>2015-07-25T17:25:15Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* shaded relief effects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== Shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8970</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8970"/>
				<updated>2015-07-25T17:24:49Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== Motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== Planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New modes proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
In map making, relief shading is a standard method and GIS systems often base such shading on a custom sun location and local slope.  http://www.reliefshading.com/ covers this method in depth. Using vertically exaggerated terrain and/or a low altitude of the sun are often used to bring out subtle features in high resolution DEMs. &lt;br /&gt;
&lt;br /&gt;
It may be possible to replicate this type of relief shading with a slope based texture in another mode of TextureCoordinateGenerator with parameters for the sun location and artificial vertical exaggeration. However, this shading would compete with the regular (light defined) X3D shading. It would be a sort of baked in shading. In many case, a good but more demanding solution may be to have a lower resolution terrain mesh, and a higher resolution image texture showing the detailed relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes with X3D standard methods, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such. This is even more interesting since it turns out that x3dom experimental shadowing works pretty well geospatial terrain.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8969</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8969"/>
				<updated>2015-07-25T17:03:38Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* new modes proposal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope. http://www.reliefshading.com/ covers this method in depth. However, this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In many cases it would be preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
=== implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== New Modes Proposal ===&lt;br /&gt;
&lt;br /&gt;
This request for feedback and consideration was distributed and added to web3d Mantis tracker:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8968</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8968"/>
				<updated>2015-07-25T16:55:41Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* additional considerations for specification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope. http://www.reliefshading.com/ covers this method in depth. However, this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In many cases it would be preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
=== implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
=== additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
Above suggests to use degrees as a unit to define a custom range for slopes with the parameter field. However, X3D generally uses radians as a unit for angles. It may be more consistent, though somewhat less intuitive, to use radians for a custom slope range as well.&lt;br /&gt;
&lt;br /&gt;
Looking farther ahead, it may become a suggestion to deprecate the CoordinateTextureGenerator node and favour shader use for dynamic generation of texture coordinates. In this case, a similar node with a name like CoordinateTextureSource which produces static texture coordinates based on a mode may make sense to introduce.&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8967</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8967"/>
				<updated>2015-07-25T16:44:57Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* additional considerations for specification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope. http://www.reliefshading.com/ covers this method in depth. However, this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In many cases it would be preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
=== implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
=== additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates, eg. if accumulated parent transformation need to be taken into account. Implementation considerations for both outside and inside of shaders favour local coordinates. GEO-HEIGHT is relative to the ellipsoid defined by the geoSystem used by (coordinates) of the parent mesh. GEO-SLOPE is relative to the local vertical direction at mesh positions.&lt;br /&gt;
&lt;br /&gt;
Another question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator which is otherwise not part of the geospatial component in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8966</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8966"/>
				<updated>2015-07-25T16:31:56Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for convenient ways to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator node were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope. http://www.reliefshading.com/ covers this method in depth. However, this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In many cases it would be preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
=== implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
=== additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates.  &lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8965</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8965"/>
				<updated>2015-07-25T15:27:14Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start with such an effort. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
The idea came up to use slope and height together to address a 2D Texture in a HEIGHT-SLOPE mode. This would allow for things like white snow not covering steep spots which could remain brown. Another application would be to use a color map with increasing intensity or saturation or darkness of color in the T direction to emphasize steep slopes but still have elevation contouring. This would compete with light-derived shading but may be interesting.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope. http://www.reliefshading.com/ covers this method in depth. However, this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In many cases it would be preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
=== implementation and concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Following the concepts outlined in the discussion the new modes were implemented in a fork of x3dom:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/#geoElevationGrid-texture&lt;br /&gt;
&lt;br /&gt;
All examples benefit from reading the descriptons and in particular from looking at the x3d content in the html source.&lt;br /&gt;
&lt;br /&gt;
The implementation plugs into the calcTexCoords() function in the x3dom Mesh.js file:&lt;br /&gt;
&lt;br /&gt;
https://github.com/andreasplesch/x3dom/blob/heightmode/src/Mesh.js#L342 &lt;br /&gt;
&lt;br /&gt;
In this implementation no transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. This means that two identical shapes would be textured identically even after one is translated vertically by a parent transform.  This is what may work best in most cases but important to keep in mind when using the parameters field to define a custom height range. The height range refers to the local, untransformed height range. &lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
=== additional considerations for specification ===&lt;br /&gt;
&lt;br /&gt;
It needs to be decided if height and slope are derived from world or local coordinates.  &lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8964</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8964"/>
				<updated>2015-07-25T14:23:02Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new (GEO-)HEIGHT and (GEO-)SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new modes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8963</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8963"/>
				<updated>2015-07-25T14:21:21Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* planning discussion on the TextureCoordinateGenerator node */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new HEIGHT and SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new nodes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
In summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8962</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8962"/>
				<updated>2015-07-25T14:20:22Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: texturecoordinategenerator discussion&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new HEIGHT and SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new nodes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== planning discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. For example, x3dom implements the SPHERE mode in code inserted into the full shader used for rendering. Other modes, such as SPHERE-LOCAL are implemented outside the shader because they are static with respect to the eye position/orientation.&lt;br /&gt;
&lt;br /&gt;
A SLOPE mode would be somewhat similar SPHERE-LOCAL mode in that it would use components of the local normal, here the z component for S and 0 for T. This should would work for non-geospatial meshes where the XZ plane is horizontal. Similarly, it should be possible to add a HEIGHT mode which uses the normalized Y coordinate for S.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this as part of the shader code as well although in x3dom it is harder to see where to start. Perhaps follow how the SPHERE mode is coded ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way and could be similar to a HEIGHT mode. It does not seem to be implemented in x3dom.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes it makes sense to define a specialized mode,  a GEO-HEIGHT mode, to indicate that the coordinate system is geocentric. It would be first necessary to derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates but this would not work for geocentric geosystem.&lt;br /&gt;
&lt;br /&gt;
By default, S would be scaled to full height range of the mesh. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier.&lt;br /&gt;
&lt;br /&gt;
For a GEO-SLOPE mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal, or undo the rotation.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node ?&lt;br /&gt;
&lt;br /&gt;
IN summary, leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. In x3dom, it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8961</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8961"/>
				<updated>2015-07-25T13:54:22Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* motivation and initial discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new HEIGHT and SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new nodes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or to color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if this technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. We could use this node ... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8960</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8960"/>
				<updated>2015-07-25T13:47:16Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new HEIGHT and SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new nodes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. We could use this node ... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8959</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8959"/>
				<updated>2015-07-25T13:36:42Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Summary of discussion on geospatial email list in 7/2015 ===&lt;br /&gt;
&lt;br /&gt;
Looking for a way to color contour elevation or slope of terrain (or other surfaces), new HEIGHT and SLOPE modes for the TextureCoordinateGenerator were proposed and developed. With this modes, it is only necessary to provide a colormap as a 1d texture in the Appearance node and the TextureCoordinateGenerator node with one of the new nodes with a geometry node such (Geo)ElevationGrid in order to achieve the desired effect. An implementation of the new modes is available in a github fork of x3dom.&lt;br /&gt;
&lt;br /&gt;
[[File:Example.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. We could use this node ... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8958</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8958"/>
				<updated>2015-07-25T12:41:39Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on the TextureCoordinateGenerator node ===&lt;br /&gt;
&lt;br /&gt;
The TextureCoordinateGenerator mode appears to be designed to enable dynamic updates of texture coordinates based on eye position/orientation, vertex positions and vertex normals using a number of modes which correspond to fixed functions of these inputs. As an OpenGL function this concept is replaced by fully programmable shaders. We could use this node ... &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8957</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8957"/>
				<updated>2015-07-25T12:24:38Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* initial discussion and motivation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&lt;br /&gt;
=== motivation and initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to contour terrain DEMs or color by them elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to map colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data including IndexedFaceSets leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on how to use the TextureCoordinateGenerator node ===&lt;br /&gt;
...&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8956</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8956"/>
				<updated>2015-07-25T03:27:37Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* initial discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&lt;br /&gt;
=== initial discussion and motivation ===&lt;br /&gt;
&lt;br /&gt;
It is very common to color a DEM by elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is easily possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data such as IndexedFaceSet leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on how to use the TextureCoordinateGenerator node ===&lt;br /&gt;
...&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8955</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8955"/>
				<updated>2015-07-25T03:25:02Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&lt;br /&gt;
=== initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to color a DEM by elevation. A recommended solution on the x3dom-user mailing list was to define texture coordinates as [normalized height, 0] for each grid point and then use a 1d texture to colors to height. This is a good solution since it allows for easily swapping out the color scale. For example, it is easily possible to limit the number of colors for a striped, contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to use this solution for a (Geo)Elevationgrid: calculate the texture coordinates from the height field and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this procedure much more accessible in some way. At first, introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height was considered.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be achieved with higher fidelity by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, the source for texture coordinates would need to be prioritized:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Testing for correctness should be possible by comparing manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Other considerations from an application perspective are:&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; &lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
Finding a general solution for mesh data such as IndexedFaceSet leads to the suggestion to define a new mode for TextureCoordinateGenerator. Then it would be necessary distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using normals which are calculated or provided for mesh vertices. Since geocentric positions are used, it would be necessary to use a reference vertical direction.&lt;br /&gt;
&lt;br /&gt;
The advantage of using colors would be that a color node may be a bit more user friendly than textures. However, X3D only has rgb colors, not palleted colors, and pixel textures effectively allow for using color values similar to color nodes.&lt;br /&gt;
&lt;br /&gt;
=== discussion on how to use the TextureCoordinateGenerator node ===&lt;br /&gt;
...&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
...&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
...&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8954</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8954"/>
				<updated>2015-07-24T18:37:01Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
=== new modes proposal ===&lt;br /&gt;
&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
=== initial discussion ===&lt;br /&gt;
&lt;br /&gt;
It is very common to color a DEM by elevation. The recommended solution on the mailing list was to define texture coordinates  as [normalized height, 0] for each grid point and then use a 1d texture to look up the color by height. To me this is a good solution since it allows for easily swapping out the color scale. For example, it is easily possible to limit the number of colors to say four for a contoured appearance.&lt;br /&gt;
&lt;br /&gt;
It is very possible to just do that for a GeoElevationgrid: calculate the texture coordinates and put them in a texture coordinate node. However, since it is such a common situation and since there is a (minor) calculation involved, it would make sense to make this calculation generally available by&lt;br /&gt;
introducing a (convenience) boolean option &amp;quot;heightTexCoords&amp;quot; to GeoElevationgrid which automatically generates the texture coordinates based on height.&lt;br /&gt;
&lt;br /&gt;
By default the option would determine min. and max. of the height field and generate texture coordinates (height-min.)/(max.-min.) , 0 for each node.&lt;br /&gt;
&lt;br /&gt;
It would then be also very useful to able to specify min. and max. height directly by a MFDouble field  &amp;quot;height_range&amp;quot; [min., max.] .&lt;br /&gt;
&lt;br /&gt;
Another option may be discretization of the texture coordinates into a limited number of values by a SFInt32 field &amp;quot;height_steps&amp;quot;: U_discrete = int(U * hsteps)/hsteps or so where U is the normalized height. This effect can be accomplished by a discretized texture map as well but would be convenient to have. For example, it would be straightforward to generate 100m contours by providing a height_range of [-3000,0] and height_steps of 30. Some more discussion and thought would be required since the contours would not be very accurate due to information loss. It would be probably better to have such a discretization option for the texture map.&lt;br /&gt;
&lt;br /&gt;
If multiple options are provided, texture coordinates are chosen by priority:&lt;br /&gt;
&lt;br /&gt;
1) explicitly defined: TextureCoordinate node&lt;br /&gt;
2) heightTexCoords&lt;br /&gt;
3) default as in spec.&lt;br /&gt;
&lt;br /&gt;
Looking at x3dom, it turns out that support for the texCoord field is currently missing but could be added based on the Elevationgrid code. Then support for automatically generating texture coordinates based on height as outlined should also be possible. Testing for correctness should be possible by comparing then manually added texture coordinates with automatically generated texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
these are great ideas, and I had thought about somehow finding a general solution for mesh data such as IndexedFaceSet. The way to do that maybe to define a new mode for TextureCoordinateGenerator. However, one then would have to distinguish between geocentric coordinates and regular coordinates to determine height, making the problem a little complex.&lt;br /&gt;
&lt;br /&gt;
Slope or dip based coloring/texturing could be quite interesting and is something we actually do quite a bit in geosciences. It would be possible to calculate slope (and aspect) for each grid node, for example according to&lt;br /&gt;
&lt;br /&gt;
http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000vz000000&lt;br /&gt;
&lt;br /&gt;
using the 3x3 grid around a node. At the borders, one could just use the closest values to fill in. It should also be possible to use the calculated mesh normals.&lt;br /&gt;
&lt;br /&gt;
Another approach would be using shaders since in a shader the normal at each drawn fragment is already calculated. Since geocentric positions are used, it would be necessary to use a reference vertical direction, for smaller scenes. It maybe fruitful asking on the x3dom list how to do this but it will be complicated since then the shader is responsible for the complete rendering.&lt;br /&gt;
&lt;br /&gt;
I do not see an advantage using colors especially since X3d only has rgb colors, not palleted colors.&lt;br /&gt;
&lt;br /&gt;
Andreas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Thu, Jul 16, 2015 at 12:12 PM, Mike McCann &amp;lt;mccann@mbari.org&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
Hello Andreas,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That posting on x3dom-user intrigued me too. I'm glad that you are considering implementing a height color texture feature in GeoElevationGrid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here are considerations that come to mind:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. It would be nice if technique could be applied to mesh data as well as grid data; my limited understanding is that the main difference would be calculating the texture coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Marine geologists and geophysicists like to shade the color according to slope magnitude or synthetic illumination (see the man page for mbm_grdtiff). With X3D we can add a light to the scene and get synthetic illumination, but shading by slope magnitude would have to be done some other way. The mbm_grdtiff tool has several options that serve to distill decades of use case capture – maybe some of these are optional attributes that could go along with a new heightTexCoords attribute.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. If a color node is used there should be a way to pass in a color lookup table. (An advantage of using the more general texture approach is that the x3d author specifies the color lookup with the texture.)&lt;br /&gt;
&lt;br /&gt;
***&lt;br /&gt;
&lt;br /&gt;
I was looking around a bit more and found the function which deals with TextureCoordinateGenerator modes if they are not directly handled in shaders such as &amp;quot;SPHERE&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
https://github.com/x3dom/x3dom/blob/master/src/Mesh.js#L342&lt;br /&gt;
&lt;br /&gt;
This is probably called from all geometry nodes which generate meshes and I believe would be the place to calculate texture coordinates based on height or slope. As an experiment, I might just add a &amp;quot;slope&amp;quot; mode which would be quite similar to the implemented &amp;quot;sphere-local&amp;quot; mode and would use the (asin of the) z component of the normal for U and 0 for V. This should would work for non-geospatial meshes where the XZ plane is horizontal. I start to like this idea more. Similarly, it should be possible to add a &amp;quot;height&amp;quot; mode which uses normalized Y for U.&lt;br /&gt;
&lt;br /&gt;
One presumably could do this somewhere in the shader code as well although I am unsure about touching it. Where would I start looking ? Follow the spheremapping ?&lt;br /&gt;
&lt;br /&gt;
There is a &amp;quot;COORD&amp;quot; mode in the spec.&lt;br /&gt;
&lt;br /&gt;
(http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/texturing.html#t-Texturecoordgeneration)&lt;br /&gt;
&lt;br /&gt;
which uses vertex coordinates in some way but how is it supposed to work ? I do not think it is implemented.&lt;br /&gt;
&lt;br /&gt;
For geospatial meshes, for a &amp;quot;geoheight&amp;quot; mode, it would be first necessary to (re-)derive the heights from the geocentric mesh coordinates (potentially taking into account GeoOrigin transformations). This should be doable. The other option would be to look into the parent node, and use the height field in case of GeoElevationGrid, or the z-component of GeoCoordinates (would not work for geocentric geosystem).&lt;br /&gt;
&lt;br /&gt;
Then U would be normalized height, and V would be zero. One could use the parameter field of the TextureCoordinateGenerator node to specify a custom height range and perhaps a discretization as outlined earlier. This could work.&lt;br /&gt;
&lt;br /&gt;
For a &amp;quot;geoslope&amp;quot; mode, it would be necessary to calculate the angle between the provided normal and the local Up (or Down) direction. For rotateYUp scenes presumably one could just use the normal.&lt;br /&gt;
&lt;br /&gt;
That brings up the question if it is acceptable to introduce geo-modes to TextureCoordinateGenerator in terms of x3d components and profiles. It may be necessary to introduce a GeoTextureCoordinateGenerator node.&lt;br /&gt;
&lt;br /&gt;
Leaning towards using new TextureCoordinateGenerator modes instead of new GeoElevationGrid fields  would cover more use cases. However, it requires some more processing to deal with the geocentric coordinates, eg. may be a bit harder to implement. Also it would touch Mesh.js which is used by a lot of nodes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
A 2d &amp;quot;height-slope&amp;quot; mode would be easy enough to add since all pieces are already there. The main application I see would be to use a color map with increasing intensity or saturation or darkness of color in the V (T) direction to emphasize steep slopes but still have elevation contouring. Not sure how it looks together with shading but probably worth trying.&lt;br /&gt;
&lt;br /&gt;
Another standard but not very common use of a 2d color map is to visualize slope and aspect - the direction of slope - together. However, this gets quite far into GIS processing and may be better handled outside of X3D, eg. by customized texture coordinates.&lt;br /&gt;
&lt;br /&gt;
Another idea using a 2d texture map with increasing darkness in T would be to add standard relief shading based on custom sun location and slope but this may be inconsistent and strange looking together with the regular (light defined) shading. It would be a sort of baked in shading. It often helps to bring out subtle features. In most cases it would be probably preferable to have a lower resolution mesh, and a higher resolution image texture showing the relief shading draped on top.&lt;br /&gt;
&lt;br /&gt;
-Andreas&lt;br /&gt;
&lt;br /&gt;
On Mon, Jul 20, 2015 at 2:53 AM, Simon Thum &amp;lt;simon.thum@igd.fraunhofer.de&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
 Hi,&lt;br /&gt;
 this looks great! Have you thought about using slope and height together to address a 2D Texture? Could be another mode, and allow for funny things like snow not covering steep spots. Just an idea.&lt;br /&gt;
&lt;br /&gt;
=== first concrete examples ===&lt;br /&gt;
&lt;br /&gt;
Here is an example of slope based texturing of an IndexedFaceSet using the &amp;quot;slope&amp;quot; mode of TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
It is possible to use the parameter field to define a data range (min. and max. color) to map to the texture in degrees. By default the range is 0 to 90.&lt;br /&gt;
&lt;br /&gt;
Following the same approach I also added a &amp;quot;height&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
It works as expected. By default, the whole range of heights (Y component of positions) is used but the parameter field can be used to define a custom data range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I am slowly working towards something that I may be able to use or get help with for my potential  application, that is exactly point: trying to make it easy to add contours with a reasonable default setting. I think it would even be advantageous to have a few standard color bars, eg. 1d texture maps provided with x3d(om). But that likely exceeds the scope of x3d or x3dom as it is perceived, and could be a sort of add-on. I can see a standard x3d file that just has bunch of named pixeltextures or imagetextures with a dataurl that can be inlined and then be used. With javascript one could update the url field or replace the whole imagetexture node.&lt;br /&gt;
&lt;br /&gt;
I am not sure if currently changing the texture map url field or the parameter field (or an additional TextureTransform node) triggers the appropriate updates but it may or should be doable once the new modes are working.&lt;br /&gt;
&lt;br /&gt;
The x3d way of shaded relief is probably a (few) potentially directional light(s) which can be moved around. It should be possible to GeoLocate a light. This way one could use geographic coordinates and some elevation although this is probably not the best way to specify a sun position.&lt;br /&gt;
&lt;br /&gt;
I made some progress on the &amp;quot;geo-height&amp;quot; mode which now works with non-geoOrigin meshes:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/globe_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
(uses UTM coordinates and does not currently use a geoOrigin)&lt;br /&gt;
&lt;br /&gt;
Next, I want to take into account a geoOrigin if it is given with the parent node or with a parent's geoCoordinate node in order to derive proper heights from the mesh vertex positions.&lt;br /&gt;
&lt;br /&gt;
Also, I need to make sure that Mesh.js otherwise still works without a loaded geospatial component, and perhaps add a note in the log that geo-height is requested but needs the geospatial component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Having gone through GeoTransform helped in relatively painlessly adding support for a provided GeoOrigin when deriving heights for the &amp;quot;GEO-HEIGHT&amp;quot; mode for TextureCoordinateGenerator:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-height.xhtml&lt;br /&gt;
&lt;br /&gt;
It appears to work correctly.&lt;br /&gt;
&lt;br /&gt;
I also added a warning and falling back to default texture coordinates in the case that somebody tries out the geo-height mode without having the geospatial component available.&lt;br /&gt;
&lt;br /&gt;
I do not believe that any transformations by parent transform, geolocation or geotransform nodes were applied to the mesh coordinates at the stage when the texture coordinates are generated. I think this is what works best in most cases but important to keep in mind when using the parameters field to define a custom height range.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
****&lt;br /&gt;
&lt;br /&gt;
Since I had a pretty good idea of how to go about slope calculation from the normal and the local vertical orientation given by the geocentric position of a vertex, I added the &amp;quot;GEO-SLOPE&amp;quot; mode to Mesh.js. Here is an example without and with GeoOrigin use:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_geoOrigin_geo-slope.xhtml&lt;br /&gt;
&lt;br /&gt;
I also added all the test scenes to the examples list on&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/&lt;br /&gt;
&lt;br /&gt;
to have quick way to look at all of them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== shaded relief effects ===&lt;br /&gt;
&lt;br /&gt;
http://www.reliefshading.com/&lt;br /&gt;
&lt;br /&gt;
For shaded relief purposes, let's think about using a directional light since the sun's rays are effectively parallel.&lt;br /&gt;
&lt;br /&gt;
http://suncalc.net/ shows the sun's position in the sky anywhere, anytime. It uses https://github.com/mourner/suncalc to calculate the sun's position in the sky. It could be fun to use this with geospatial x3dom to predict/reconstruct the lighting situation at some time, perhaps for accident reconstruction and such.&lt;br /&gt;
&lt;br /&gt;
Shaded relief shading should be simpler. Since azimuth and elevation of the sun for shaded relief purposes is defined with respect to local north and the local horizontal, it should be possible use a GeoLocation node with a location close the geoelevationgrid in order to rotate the directional light orientation properly with respect to the orientation of the local tangential plane. The directional light orientation would be just azimuth and elevation as a vector.&lt;br /&gt;
&lt;br /&gt;
One could use the NormalInterpolator node to vary the sun light orientation. The node uses a spherical interpolation. Interpolating say from horizontal NE towards SW orientation (-1, 0, -1) to vertical downwards (0, -1, 0) to horizontal SW to NE (1, 0, 1) and routing to the orientation field of the light should produce a nice variation of shading to explore. I may try that.&lt;br /&gt;
&lt;br /&gt;
[Alternatively, it should be also possible to use an OrientationInterpolator node routed to a transform node.]&lt;br /&gt;
&lt;br /&gt;
Another important option for shaded relief purposes is to exaggerate the vertical for more pronounced shading. So it would be nice to have option to do this without actually vertically exaggerating the vertex positions. I suspect the shaders in x3dom use the mesh normals to produce the default shading based on the lights in the scene. If not provided as is often the case, the normals are calculated from the vertex positions. It would be possible to manipulate the normal calculation to use a scaled up Y coordinate of a vertex. However, this would not work for geocentric coordinates. For GeoElevationGrid it may be possible to calculate exaggerated normals, then non-exaggerated normals and positions, and texMode based texcoords, and finally replace the normals with exaggerated normals.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea of using a geolocated directional light worked quite well. Here is an animated example along the lines I had described:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_sun.xhtml&lt;br /&gt;
&lt;br /&gt;
Shaded relief in 3d looks pretty good. It should be possible to restrict lights to certain objects, eg. lights are supposed to be only applied to the objects in their parent group. This way one could have shaded relief on terrain but &amp;quot;normal&amp;quot; lighting for all other objects.&lt;br /&gt;
&lt;br /&gt;
Since this works well, I do not think it is very advantageous to do much about vertical exaggeration for shading purposes.&lt;br /&gt;
&lt;br /&gt;
The last item would be to see if it is possible to use a PixelTexture to define a stepwise color function, eg. to have a limited number of color bands for a striped appearance mimicking actual contour lines. This probably requires the &amp;quot;NEAREST&amp;quot; magFilter of the TextureProperty node.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8953</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8953"/>
				<updated>2015-07-24T18:11:00Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: new modes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
In data visualization it is often useful to color the y component (height) of a mesh. This is particularly evident for ElevationGrids where contouring is a proven visualization method. Therefore it would be very useful to have a new HEIGHT mode which generates texture coordinates based on the y coordinate. The most useful default would be to automatically scale to the range in height of the mesh. The parameter field could be used to define a custom range in height which corresponds to the 0 to 1 range of the S texture coordinate. T would be set to 0, eg. a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here is an example of the use a height mode:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_height.xhtml&lt;br /&gt;
&lt;br /&gt;
which was tentatively implemented in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
Similary, it is often useful to visualize the spatial gradient of a surface or the slope. A new SLOPE mode for TextureCoordinateGenerator would generate texture coordinates based on the local slope angle ( implementations could derive the slope on the local normal ). By default slopes from 0 to 90 degrees would be scaled to the 0 to 1 range of the S texture coordinate. The  parameter field could be used to define a custom range. T would be set to 0 and a 1d texture map would be expected.&lt;br /&gt;
&lt;br /&gt;
Here are two examples:&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/puddle_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/face_slope.xhtml&lt;br /&gt;
&lt;br /&gt;
using a tentative implementation in a forked x3dom (Mesh.js).&lt;br /&gt;
&lt;br /&gt;
One could also imagine (and quite easily implement) another mode &amp;quot;HEIGHT-SLOPE&amp;quot; which uses both attributes as S and T respectively  and a 2d texture map as suggested by Simon Thum on the geospatial list.&lt;br /&gt;
&lt;br /&gt;
These modes would be somewhat similar to the existing VERTEX and SPHERE-LOCAL modes but aimed at 1d texture maps.&lt;br /&gt;
&lt;br /&gt;
Finally, geospatially registered meshes would need equivalent modes using height above the geoid and slope relative to the local tangential plane to the geoid.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8952</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8952"/>
				<updated>2015-07-24T17:41:05Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Summary of discussion on geospatial email list in 7/2015 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion on geospatial email list in 7/2015 ==&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8951</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8951"/>
				<updated>2015-07-24T17:40:24Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary of discussion geospatial email list in 7/2015 ==&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8950</id>
		<title>Terrain height/slope visualization via autogenerated texture coordinates</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=Terrain_height/slope_visualization_via_autogenerated_texture_coordinates&amp;diff=8950"/>
				<updated>2015-07-24T17:31:13Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: proposed TextureCoordinateGenerator modes allow easy contouring of meshes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Summary of discussion geospatial email list in 7/2015&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=X3D_Earth&amp;diff=8949</id>
		<title>X3D Earth</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=X3D_Earth&amp;diff=8949"/>
				<updated>2015-07-24T17:29:25Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Documents */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The X3D Earth Working Group supports the X3D Graphics Geospatial Component.&lt;br /&gt;
&lt;br /&gt;
* Nearby:  [http://www.web3d.org/working-groups/x3d-earth X3D Earth Home Page]&lt;br /&gt;
* Web3D Consortium member? Go to [http://www.web3d.org/member/wiki/x3d-earth X3D-Earth members-only wiki]&lt;br /&gt;
&lt;br /&gt;
==Executive Summary==&lt;br /&gt;
&lt;br /&gt;
The X3D Earth Working Group will use the Web architecture, XML languages, and open protocols to build a standards-based X3D Earth specification usable by governments, industry, scientists, academia, and the general public. X3D-Earth efforts encompass client-side, server-side, authoring, and conversion technologies. Much work has been accomplished already.&lt;br /&gt;
&lt;br /&gt;
* ''Vision''. Make it easier to create and use 3D spatial data.&lt;br /&gt;
* ''Mission''. Promote spatial data use within X3D via open architectures.&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
The X3D Earth Working Group works to ensure that the X3D specification is capable of handling all manners of geospatial data representations. We interact with other standards development organizations (including the Open Geospatial Consortium and the World Wide Web Consortium) and vendors to employ open protocols and content standards to provide an interoperable framework for visualizing and interacting with geospatial data. These standards-based specifications will be used to create systems and content that is usable, and re-usable, over the long term.&lt;br /&gt;
&lt;br /&gt;
The X3D-Earth effort encompasses client-side, server-side, authoring, and conversion technologies. It's goals include:&lt;br /&gt;
&lt;br /&gt;
* Providing ability to use publicly and privately available terrain and imagery datasets&lt;br /&gt;
* Capitalizing on X3D capabilities (e.g. scripting and HTML 5 browser support) for displaying geospatial data &lt;br /&gt;
* Promoting its use as an alternative to proprietary solutions&lt;br /&gt;
&lt;br /&gt;
==Mailing List==&lt;br /&gt;
&lt;br /&gt;
* X3D Earth [http://web3d.org/mailman/listinfo/x3d-earth_web3d.org Mailing List] subscriptions&lt;br /&gt;
* X3D Earth Mailing List Archives&lt;br /&gt;
** [http://web3d.org/mailman/private/x3d-earth_web3d.org April 2009 - present]&lt;br /&gt;
** [http://web3d.org/membership/login/list_archives/x3d-earth September 2006 - March 2009]&lt;br /&gt;
&lt;br /&gt;
Our working group continues meeting by teleconference every two weeks.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
=== Software: Players ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.bitmanagement.de/en/products/interactive-3d-clients/bs-contact-geo BS Contact Geo] browser plugin and standalone application for X3D geospatial rendering by BitManagement&lt;br /&gt;
* [http://www.instantreality.org/ Instant Reality] standalone application for X3D geospatial rendering by Fraunhofer&lt;br /&gt;
* [https://savage.nps.edu/Savage/developers.html#Xj3D Xj3D] open-source Java application for X3D geospatial rendering&lt;br /&gt;
* [http://freewrl.sourceforge.net/ FreeWrl/FreeX3D]  open-source C++ application for X3D geospatial rendering&lt;br /&gt;
&lt;br /&gt;
=== Software: Authoring Tools ===&lt;br /&gt;
&lt;br /&gt;
* [https://savage.nps.edu/X3D-Edit X3D-Edit] authoring tool includes full support for authoring X3D geospatial nodes&lt;br /&gt;
* MBARI MB-System&lt;br /&gt;
&lt;br /&gt;
Potential future work:&lt;br /&gt;
&lt;br /&gt;
* The [http://www.3dcitydb.net 3D City Database Importer/Exporter] uses CityGML for KML/COLLADA portrayal preprocessing. It is a well-documented open-source Java codebase.  There is an interesting development opportunity to follow the design pattern of adding another exporter for X3D output that is similar to the existing KML/Collada exporter.  Inquiries are welcome.&lt;br /&gt;
&lt;br /&gt;
=== Documents ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.mbari.org/staff/mccann/x3d/docs/Web3D2008_X3D-Earth_Mashups_Tutorial.ppt X3D-Earth Tutorial] presentation by Mike McCann and Alan Hudson at Web 3D Symposium 10 August 2008 in Los Angeles&lt;br /&gt;
* [http://x3dgraphics.com/slidesets/X3dForAdvancedModeling/GeospatialComponentX3dEarth.pdf Geospatial Component X3D Earth] tutorial slideset by Don Brutzman&lt;br /&gt;
* Tourtelotte, Dale, [http://edocs.nps.edu/npspubs/scholarly/theses/2010/Sep/10Sep%5FTourtelotte.pdf X3D-Earth:  Full-Globe Coverage Utilizing Multiple Datasets], Masters Thesis, Naval Postgraduate School, Monterey California, September 2010.  Advisor Don Brutzman, second readers Byounghyun Yoo and Don McGregor.&lt;br /&gt;
* [[Examine mode behavior for exploring geospatial worlds]]&lt;br /&gt;
* [[Terrain height/slope visualization via autogenerated texture coordinates]]&lt;br /&gt;
&lt;br /&gt;
=== Specifications ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.web3d.org/files/specifications/19775-1/V3.2/Part01/components/geodata.html Extensible 3D (X3D) Graphics Geospatial component] version 3.2&lt;br /&gt;
* Proposed changes for [http://www.web3d.org/files/specifications/19775-1/V3.3/Part01/components/geodata.html X3D Geospatial component] version 3.3&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.web3d.org/x3d/content/examples/Basic/GeoSpatial/ X3D Basic Examples Archive, GeoSpatial Examples]&lt;br /&gt;
* TODO Byounghyun Yoo's scripts&lt;br /&gt;
* TODO Fraunhofer?&lt;br /&gt;
* TODO Bit Management?&lt;br /&gt;
* TODO NPS internal supercomputer cluster nightly build&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	<entry>
		<id>https://old.web3d.org/wiki/index.php?title=X3D_Earth&amp;diff=8948</id>
		<title>X3D Earth</title>
		<link rel="alternate" type="text/html" href="https://old.web3d.org/wiki/index.php?title=X3D_Earth&amp;diff=8948"/>
				<updated>2015-07-24T17:29:02Z</updated>
		
		<summary type="html">&lt;p&gt;Plesch: /* Documents */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The X3D Earth Working Group supports the X3D Graphics Geospatial Component.&lt;br /&gt;
&lt;br /&gt;
* Nearby:  [http://www.web3d.org/working-groups/x3d-earth X3D Earth Home Page]&lt;br /&gt;
* Web3D Consortium member? Go to [http://www.web3d.org/member/wiki/x3d-earth X3D-Earth members-only wiki]&lt;br /&gt;
&lt;br /&gt;
==Executive Summary==&lt;br /&gt;
&lt;br /&gt;
The X3D Earth Working Group will use the Web architecture, XML languages, and open protocols to build a standards-based X3D Earth specification usable by governments, industry, scientists, academia, and the general public. X3D-Earth efforts encompass client-side, server-side, authoring, and conversion technologies. Much work has been accomplished already.&lt;br /&gt;
&lt;br /&gt;
* ''Vision''. Make it easier to create and use 3D spatial data.&lt;br /&gt;
* ''Mission''. Promote spatial data use within X3D via open architectures.&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
The X3D Earth Working Group works to ensure that the X3D specification is capable of handling all manners of geospatial data representations. We interact with other standards development organizations (including the Open Geospatial Consortium and the World Wide Web Consortium) and vendors to employ open protocols and content standards to provide an interoperable framework for visualizing and interacting with geospatial data. These standards-based specifications will be used to create systems and content that is usable, and re-usable, over the long term.&lt;br /&gt;
&lt;br /&gt;
The X3D-Earth effort encompasses client-side, server-side, authoring, and conversion technologies. It's goals include:&lt;br /&gt;
&lt;br /&gt;
* Providing ability to use publicly and privately available terrain and imagery datasets&lt;br /&gt;
* Capitalizing on X3D capabilities (e.g. scripting and HTML 5 browser support) for displaying geospatial data &lt;br /&gt;
* Promoting its use as an alternative to proprietary solutions&lt;br /&gt;
&lt;br /&gt;
==Mailing List==&lt;br /&gt;
&lt;br /&gt;
* X3D Earth [http://web3d.org/mailman/listinfo/x3d-earth_web3d.org Mailing List] subscriptions&lt;br /&gt;
* X3D Earth Mailing List Archives&lt;br /&gt;
** [http://web3d.org/mailman/private/x3d-earth_web3d.org April 2009 - present]&lt;br /&gt;
** [http://web3d.org/membership/login/list_archives/x3d-earth September 2006 - March 2009]&lt;br /&gt;
&lt;br /&gt;
Our working group continues meeting by teleconference every two weeks.&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
&lt;br /&gt;
=== Software: Players ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.bitmanagement.de/en/products/interactive-3d-clients/bs-contact-geo BS Contact Geo] browser plugin and standalone application for X3D geospatial rendering by BitManagement&lt;br /&gt;
* [http://www.instantreality.org/ Instant Reality] standalone application for X3D geospatial rendering by Fraunhofer&lt;br /&gt;
* [https://savage.nps.edu/Savage/developers.html#Xj3D Xj3D] open-source Java application for X3D geospatial rendering&lt;br /&gt;
* [http://freewrl.sourceforge.net/ FreeWrl/FreeX3D]  open-source C++ application for X3D geospatial rendering&lt;br /&gt;
&lt;br /&gt;
=== Software: Authoring Tools ===&lt;br /&gt;
&lt;br /&gt;
* [https://savage.nps.edu/X3D-Edit X3D-Edit] authoring tool includes full support for authoring X3D geospatial nodes&lt;br /&gt;
* MBARI MB-System&lt;br /&gt;
&lt;br /&gt;
Potential future work:&lt;br /&gt;
&lt;br /&gt;
* The [http://www.3dcitydb.net 3D City Database Importer/Exporter] uses CityGML for KML/COLLADA portrayal preprocessing. It is a well-documented open-source Java codebase.  There is an interesting development opportunity to follow the design pattern of adding another exporter for X3D output that is similar to the existing KML/Collada exporter.  Inquiries are welcome.&lt;br /&gt;
&lt;br /&gt;
=== Documents ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.mbari.org/staff/mccann/x3d/docs/Web3D2008_X3D-Earth_Mashups_Tutorial.ppt X3D-Earth Tutorial] presentation by Mike McCann and Alan Hudson at Web 3D Symposium 10 August 2008 in Los Angeles&lt;br /&gt;
* [http://x3dgraphics.com/slidesets/X3dForAdvancedModeling/GeospatialComponentX3dEarth.pdf Geospatial Component X3D Earth] tutorial slideset by Don Brutzman&lt;br /&gt;
* Tourtelotte, Dale, [http://edocs.nps.edu/npspubs/scholarly/theses/2010/Sep/10Sep%5FTourtelotte.pdf X3D-Earth:  Full-Globe Coverage Utilizing Multiple Datasets], Masters Thesis, Naval Postgraduate School, Monterey California, September 2010.  Advisor Don Brutzman, second readers Byounghyun Yoo and Don McGregor.&lt;br /&gt;
* [[Examine mode behavior for exploring geospatial worlds]]&lt;br /&gt;
* Terrain height/slope visualization via autogenerated texture coordinates&lt;br /&gt;
&lt;br /&gt;
=== Specifications ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.web3d.org/files/specifications/19775-1/V3.2/Part01/components/geodata.html Extensible 3D (X3D) Graphics Geospatial component] version 3.2&lt;br /&gt;
* Proposed changes for [http://www.web3d.org/files/specifications/19775-1/V3.3/Part01/components/geodata.html X3D Geospatial component] version 3.3&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
* [http://www.web3d.org/x3d/content/examples/Basic/GeoSpatial/ X3D Basic Examples Archive, GeoSpatial Examples]&lt;br /&gt;
* TODO Byounghyun Yoo's scripts&lt;br /&gt;
* TODO Fraunhofer?&lt;br /&gt;
* TODO Bit Management?&lt;br /&gt;
* TODO NPS internal supercomputer cluster nightly build&lt;/div&gt;</summary>
		<author><name>Plesch</name></author>	</entry>

	</feed>