Author Topic: How to correctly apply bumpMaps  (Read 2158 times)

Offline neo187

  • int
  • **
  • Posts: 73
    • View Profile
How to correctly apply bumpMaps
« on: January 06, 2012, 02:03:04 pm »
Hello

I am trying to fix the Bump Map set up for my editor. Am using software renderer, currently the object's texture is set up using the setTexture(Texture t) method. Afterwards I have an option to browse for a normal map file and then this is how I am applying it, following the instructions on the JavaDoc that say to enable environment map first:
Code: [Select]
obj.setBumpmapped(Object3D.BUMPMAPPING_ENABLED);
obj.setEnvmapped(Object3D.ENVMAP_ENABLED);
obj.setEnvmapDirection(Object3D.ENVMAP_YZ);
obj.setBumpmapTexture(bumpTextName);

But this is the result I get:


The bottom image is the result in JPCT.... it's actually more brownish, i got this screenshot from using a different texture but same bump.... the resolution of both textures is 256x256....

Am I doing something wrong? Thank you very much

« Last Edit: January 06, 2012, 03:11:11 pm by neo187 »

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to correctly apply bumpMaps
« Reply #1 on: January 06, 2012, 09:10:26 pm »
Oh boy...this feature is oooold. I can't remember when i used this myself the last time, so i had to look it up too...The most important thing to know is, that this kind of bump mapping works only in the software renderer and some preconditions have to be met for this to work. But if they are met, you can't use the same scene in the OpenGL renderers, so if you are planning to use this for objects that might be rendered using hardware too, it won't work.

Anyway...this kind of bump mapping isn't "real" bump mapping. It's a fake effect created by a pertubed environment map. For this to work, you need a base map (which is bascially what you have on the left), a bump map (which should be what you have on the right, but that's a normal map...the software renderer needs something else...i'll come to this later) and an environment map (something like http://www.pauldebevec.com/Probes/kitchen_probe.jpg). At least the environment and the bump map should be 256*256 pixels in size...i'm not sure about the base map ATM. You can set all three with Object3D.setAllTextures(<String>, <String>, <String>);
Now about the actual bump map: The software renderer only uses G and B of an RGB picture for creating the effect. G pertubs up/down, B left/right, 128 is normal. What i usually did is this: Take a normal map (maybe apply a soften filter to it) or emboss the normal texture map and convert it into a grayscale image. Tweak the brightness so that flat parts have a color value of 128/128/128 and use that as a bump map. It's complete nonsense, but might look fine.

This is an example from over 10 years ago: http://www.flipcode.com/archives/04-09-2001.shtml



Offline neo187

  • int
  • **
  • Posts: 73
    • View Profile
Re: How to correctly apply bumpMaps
« Reply #2 on: January 06, 2012, 09:25:03 pm »
Thank you Egon....

Well I am not really using bumpmapping in my project since it's  JPCTAE app and that feature doesn't seem to exist there... It was just to add an extra feature to the jBrush Editor since I saw the option in the JavaDOC... so there's no other more "modern" way to achieve the effect with the Software renderer? Things like Unity or UDK usually allow you to apply the normal map that I have on the right to the texture on the left and you quickly get the feel of depth on the surface and the object would be lit accordingly... but I guess that it's their shaders working in the background...

Thanks as for your help Egon

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to correctly apply bumpMaps
« Reply #3 on: January 06, 2012, 09:27:13 pm »
You can of course use shaders in jPCT and jPCT-AE (assuming that you are using OpenGL ES 2.0) and you can write yourself (or copy one from the wiki/forum) a shader that applies the normal map. But this has nothing to do with the way the software renderer does it. The two implementations are 100% incompatible. You can either use one way or the other.

Offline AGP

  • quad
  • ******
  • Posts: 1515
    • View Profile
Re: How to correctly apply bumpMaps
« Reply #4 on: January 07, 2012, 05:56:03 pm »
I wish there were more software and hardware stuff on jpct. These days the tendency seems to be for hardware-only things and now this is software-only. At the very least, you could make it so that the hardware basically ignores the effect of this, so that the diffuse channel doesn't suffer in hardware. And things like the other things (non-shader) things that jpct does, it should do on the software level as well, even if it would strain current hardware. Don't you think?

Online EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: How to correctly apply bumpMaps
« Reply #5 on: January 07, 2012, 06:01:06 pm »
IIRC, you'll get simple environment mapping in hardware mode instead of the bump mapping. Honestly, the software renderer doesn't have much priority nowadays. It's nice to have it as an option and with the addition of multi-threaded rendering, it scales really well on current machines, but i'm not going to make it mimic the GL pipeline. Actually, it can do almost everything that the fixed function gl pipeline can do except for multi-texturing.

Offline AGP

  • quad
  • ******
  • Posts: 1515
    • View Profile
Re: How to correctly apply bumpMaps
« Reply #6 on: January 07, 2012, 08:24:48 pm »
The software renderer is one of my favorite things about jpct. I have not one, but three good laptops (one of which a Corei7), with bad video cards that produce a black screen with the hardware renderer. I'm neither kidding nor exaggerating. So I always write my jpct programs to use both renderers.