Anne Quinn
Anne Quinn

Reputation: 13040

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?

Upvotes: 32

Views: 1816

Answers (5)

David C. Bishop
David C. Bishop

Reputation: 6615

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).

Upvotes: 21

Russell Borogove
Russell Borogove

Reputation: 19057

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.

Upvotes: 6

Uday
Uday

Reputation: 150

If you have DX11 class hardware then you could tessellate the polygon and then apply displacement mapping. See http://developer.nvidia.com/node/24. But then it gets a little complicated to get it running and develop something on top of it.

Upvotes: 3

genpfault
genpfault

Reputation: 52166

You may also be thinking of displacement mapping.

Upvotes: 13

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81724

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

Upvotes: 14

Related Questions