Parallax mapping seems to be inverted somehow

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Vir
Posts: 14
Joined: Thu Feb 21, 2013 10:00 pm

Parallax mapping seems to be inverted somehow

Post by Vir »

I wish I could post a screenshot, but I'm working on a commercial product, and the higher-ups have expressly forbid making anything public until it's ready for release. I hope you can follow my description of what's going on.

Anyway, when I turn on parallax mapping and apply my own color and normal maps, the object is all the way black, with only a little bit visible right on the edge of the object. It's as though it thinks the light is coming from the opposite side of the object that it's supposed to be coming from. The light and the camera are practically on top of each other, which is probably why it always seems black. So, I messed around with the tangent-space normal map in photoshop, and on a hunch, just inverted the whole thing, so it's a sort of olive-green color instead of light blue. This would have the effect of making all the normals point the opposite direction, and in fact, this did work. Sort of. The surface of the mesh looks right, but the lighting is off. If the object is centered on the screen, everything looks fine, but if it moves to one side or the other, the areas facing the light get darker, and vice versa. I tried only inverting different combinations of the RGB channels in photoshop, but that didn't seem to change much. Anyway, I think if I'm trying to fix this problem, I should really have a better solution than inverting the color scheme in photoshop.

Normal maps are in TGA format, with height encoded in the alpha channel. The mesh comes from an OBJ file, which I have Irrlicht generate the tangents for. I've only made a few minor changes to Irrlicht, but one changes the projection matrices to right-handed instead of left-handed. This was so that the coordinate system could be the same between the physics and graphics engine. I did try changing it back to the default projections though, and this didn't fix the problem. I'm compiling Irrlicht to run in 64-bit mode. Normal maps are tangent-space, and pieced together from various sources.

That's about all the relevant information I can think of.

Any ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Parallax mapping seems to be inverted somehow

Post by hybrid »

What about example 11, can you reproduce what you described here with the example?
Vir
Posts: 14
Joined: Thu Feb 21, 2013 10:00 pm

Re: Parallax mapping seems to be inverted somehow

Post by Vir »

hybrid wrote:What about example 11, can you reproduce what you described here with the example?
Actually, we made some developments on this issue. First, the problem was apparently with a directional light that was set to move with the camera. (Not my code.) It lit ordinary materials properly, but seemed to light per-pixel lighted materials backwards, for some reason. When the light was changed to either a spot light or a point light, the normal mapping and parallax mapping worked properly. We still have to implement a fixed-position directional light, but it seems pretty clear that the issue is with directional lights only, so at least we know that if it happens again, it's something that would need to be fixed by changing the light parameters.

There's no attenuation for per-pixel lighting in this scene, and no specular highlights on the materials though. We changed a lot of the light and material properties, but this never changes. Is this just a limitation of Irrlicht's shaders?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Parallax mapping seems to be inverted somehow

Post by hybrid »

Yes, also the directional light issue is easily explained this way. The shader for parallax mapping only supports up to two lights, and only point lights. No light material settings are supported. You should use your own shader for this. Examples can be found on the forum or in the opengl-es branch, but internet is also full of these types of shaders. Maybe we will add some better versions to the core engine, but for now you need to skip the built-in one for all the parameters you mentioned.
Post Reply