Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there a library like PIL (Python Imaging Library) which takes a RGB image (pixel data) and generates a bump map image? If not, how can I do that? I know the results might not be very good.

I know it will probably be slow to do in Python, it can be ported to C and called from Python later, after prototyping and seeing the results.

share|improve this question
3  
Depending on what you mean by "RGB to bump map", it doesn't need to be a heavy operation.. assuming, for instance, that RGB is height field data, and "bump map" is just normals calculated from the RGB data, it's just a few additions/substractions per pixel, maybe scaling.. – Jari Komppa Feb 1 at 10:48
No the RGB image is an ordinary color map. – user975135 Feb 1 at 11:07
1  
That doesn't really help figuring out how you want to turn a picture into a bump map =) – Jari Komppa Feb 1 at 11:15
Favorited because this gave me an idea. A really amazing filter would attempt to locate the light sources (hard to do). A complimentary filter could use the same information to neutralize the shadows. – jzx Feb 1 at 16:17
@Jari Komppa what info do you need then? It's an ordinary color texture. – user975135 Feb 1 at 17:07

2 Answers

up vote 2 down vote accepted

There's no 'proper' way to generate a bump map from a regular image because the 3D information simply isn't there. But if you know your textures are all from a similar source where directional lighting has been baked into the texture to some degree, you may be able to fake some usable bump maps via some standard image processing approaches.

PIL already offers this capability. You want one of the functions in the ImageFilter module, probably EMBOSS, eg.

import ImageFilter
import ImageOps
color_bump_map = diffuse_map.filter(ImageFilter.EMBOSS)
grey_bump_map = ImageOps.grayscale(color_bump_map)

That should allow you to take an image like one on the left below, and generate one like one that on the right:

Example of synthetic bump map via emboss and desaturation

(This example was done in Photoshop, but using the same type of filters.)

share|improve this answer
Wow, I can't believe I didn't notice the filters PIL offers. – user975135 Feb 1 at 17:08

There are plenty of tools that will create a normal map given a heightmap / bumpmap. Creating a normal map from any old photo requires a lot more guesswork (to reconstruct the height by looking at the light and shadows) and will usually not give very good results.

One tool which can do it is Njob:

http://charles.hollemeersch.net/njob

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.