[WIP][SBDL] Bump Mapping

SkyBerron SBDL Bump Mapping test.

SkyBerron Bump Mapping.bin.1_speed

SkyBerron Bump Mapping.bin.2_speed

SkyBerron Bump Mapping.bin (135.8 KB)

Edit: I forgot to remove an integer division from the inner loop :man_facepalming:. Now it should run at a higher frame rate.

Previous version:

SkyBerron Bump Mapping.bin.1_speed

SkyBerron Bump Mapping.bin.2_speed

SkyBerron Bump Mapping.bin (135.7 KB)

2 Likes

Looks really nice!
Is it possible to animate the bumb map to make the text appear on the flat surface?

Thanks, @Hanski. It’s the closest I could get to the equivalent pixel shader.

It’s not possible currently because the bump map textures are 8bpp height map images the same resolution as the screen, so it takes about 40 kb in flash for each texture. But it could be possible if the texture resolution is lowered. If the resolution is lower than screen, then you get a nice empty border unless you resort to doubling pixels or interpolation. I preferred full screen and no interpolation to run the test using the most CPU demanding settings.

How about dynamically scaling the bumb map values at run time? May it is too slow.

The bump map renderer is very tight on cpu load. Of course, you could generate the texture on the fly, row by row and render that row inmediately afterwards (in fact you only need two full rows to compute gradients in the inner loop). Anyway it’s usually easier to modify the input texture before rendering starts.

You can prolly speed it up by converting the bump map to normal map beforehand, i.e. precomputing the gradient.

Thanks, @drummyfish. I tried that approach in previous tests. I found that a height map had got enough dynamic range with just 8bpp, but a normal map needs more than 8bpp to get enough dynamic range (I can be wrong, of course). So I had to sacrifice speed for a smaller texture size. Anyway, two extra texture look-ups and two extra subs in the inner loop are not that bad. The worst part was computing vector length in the inner loop, but that’s another (horror) story that I want to forget asap…