Is there a way to use height map with SceneKit?

1.6k views Asked by At

Can I use a height map with SceneKit? Is there a function or api that I can use to achieve that?

I would like to make a game and it would really help me.

4

There are 4 answers

0
Nerrolken On BEST ANSWER

No way that I know of, but here is a handy converter for making normal maps out of height maps. It seems to require you to check "invert height" to work properly, but otherwise the default values work for me.

It'd be nice to be able to use height maps in SceneKit, but this is the next best thing.

1
mnuages On

SCNMaterial does not have a dedicated SCNMaterialProperty for that (like it has for a normal map) but you will probably be able to achieve what you want with shader modifiers.

0
OliverD On

I'm not sure whether this is what you're after. This uses perlin noise to make the vertices of a custom geometry plane bumpy:

https://github.com/Utsira/SceneKitBumpMapPlane

0
Flex Monkey On

I've created a custom Core Image filter that will convert your height/bump map to a normal map that you can use with SceneKit materials. You can read about it and download a sample implementation at my blog.

In a nutshell, a normal map includes displacement data for x, y and z axes mapped to red, green and blue. My filter looks at the horizontal and vertical slopes of each pixel in a monochrome bump map and outputs the red and green colors based on those. The blue and alpha channels are always set to 1.

This filter can be used with procedural sources (such as gradients) or existing images.