Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL, How to create a "bumpy Polygon"?

I am unsure of how to describe what I'm after, so I drew a picture to help:

OpenGL question

My question, is it possible within OpenGL to create the illusion of those pixel looking bumps on a single polygon, without having to resort to using many polygons? And if it is, what's the method?

like image 328
Anne Quinn Avatar asked Sep 20 '11 17:09

Anne Quinn


4 Answers

I think what your looking for is actually Parallax mapping (Or Parallax Occlusion mapping).

Demos:
http://www.youtube.com/watch?v=01owTezYC-w
http://www.youtube.com/watch?v=gcAsJdo7dME&NR=1
http://www.youtube.com/watch?v=njKdLvmBl88

Parralax mapping basically works by using the height map to alter the texture UV coordinate being used.

The main disadvantage to parallax is that anything that appears to be 'outside' the polygon will be clipped (think of looking at an image on a 3D tv), so it's best for things indented in a surface rather than sticking out of it (although you can reduce this by making the polygon lager than the visible texture area). It's also fairly complex and would need to be combined with other shader techniques for a good effect.

Bump mapping works by using a texture for normal's, this makes the light's shading appear to be 3D however it does not change 3D data depending on the position of the viewer only the shading. Bump mapping would also be fairly useless for the OP's sample image since the surface is all the same angle just at different heights, bump mapping relies on the changes in the surfaces angles. You would have to slope the edges like this.

Displacement mapping/tessellation uses a texture to generate more polygons rather than just being 1 polygon.

There's a video comparing all 3 here

EDIT: There is also Relief mapping, which is a similar to parallax. See demo. There's a comparison video too (it's a bit lowquality but relief looks like it gives better depth).

like image 117
David C. Bishop Avatar answered Sep 24 '22 03:09

David C. Bishop


I think what you're after is bump mapping. The link goes to a simple tutorial.

like image 23
Ernest Friedman-Hill Avatar answered Sep 26 '22 03:09

Ernest Friedman-Hill


You may also be thinking of displacement mapping.

like image 33
genpfault Avatar answered Sep 23 '22 03:09

genpfault


Of the techniques mentioned in other people's answers:

  • Bump mapping is the easiest to achieve, but doesn't do any occlusion.
  • Parallax mapping is probably the most complex to achieve, and doesn't work well in all cases.
  • Displacement mapping requires high-end hardware and drivers, and creates additional geometry.
  • Actually modeling the polygons is always an option.

It really depends on how close you expect the viewer to be and how prominent the bumps are. If you're flying down the Death Star trench, you'll need to model the bumps or use displacement mapping. If you're a few hundred meters up, bumpmapping should suffice.

like image 35
Russell Borogove Avatar answered Sep 23 '22 03:09

Russell Borogove