Forum

Topographic mesh shader?

I’m looking for something that will color a mesh depending on the height of each spot on the mesh, a “topo map” kind of thing. I am NOT looking for something to produce an actual 2D topo map from a mesh, but something to color the mesh in 3D.

I am not shader-savvy enough to figure out the exact code, but it seems like in the pixel shader I need to get the world Y of that point and derive the color from that. Am I on the right track? How do I get that Y value?

Or is there some other/better way? Thanks a ton!

discussed here earlier: https://discourse.vvvv.org/t/12084
try this
https://github.com/unc-quite/dx11-vvvv-girlpower/blob/master/nodes/dx11/ConstantProjection.fx
it uses world coordinates as texcoord, just take some gradient texture and tweak it with texture transform

That does work somewhat, by fooling around with texture scaling, but I found a tradeoff on texture size when trying to put in the topo lines in the pre-made texture. They tend to get too chunky on low slopes or almost invisible. I think this might require some greater logic to take care of that.

So to get the world Y value of a mesh pixel in the shader, how would I obtain that? Thanks!

col.rgb = posWVP.yyy;

Not sure if it’s quite what you want, but had a quick hack at it, maybe it helps as a starting point.

Topographic.fx (1.2 kB)

i uploaded one i did some time ago… elevation

Thanks folks! That gives me more than enough to go on. Greatly appreciated!

Put together a contribution of what I put together: topographic-phong-shader

Thanks again folks!