Problem with normal maps and repeating textures

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Problem with normal maps and repeating textures

Post by Agar »

I'm having trouble with normal maps.

When I'm normal mapping a mesh with "tiled textures" (meaning the same texture is drawn several times on the same mesh, like walls/floors in videogames), texture is stretched badly. Everything works fine when texture is not tiled (like when mapping a character/object in a videogame).

Here are a few screenshots to give you a better idea :

Image

No matter which format I use (I tried .X, .MS3D and even .BSP maps), problem stays. This is really annoying as I won't be able to design normal/parallax/bump mapped levels without tiling textures.

Using MakePlanarTextureMapping() fix this, but I lose all texture alignment. And this function tiles all textures on the map the same way, something I don't want.

Do you have any clue on how to fix this?

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

Post by hybrid »

Try if OpenGL makes some better results. It seems as if the texture coordinates are clamped to 0..1 in both axes, so maybe some wrong declaration in the shader. But the directx and OpenGL shader work differently such that it could help to track down the problem at least.
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Post by Agar »

Yes!

Thanks, hybrid, I've tried with OpenGL and it works now. I guess the bug is on Irrlicht side, not mine. Someone should tell Niko that the DirectX shader does not clamp normal maps correctly.

Still, I'd like to use a DirectX renderer (All my custom-made materials use DirectX shaders).

I'll try to find a way to make it work with DirectX, if you have any idea, please tell me.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'm not sure, I did not find it while going through the shaders. The only clamping occurs in positions where no texture coords are calculated. Do you have the same effects when using normal maps or parallax maps?
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Post by Agar »

Well, I always use PARALLAX_MAP_SOLID, and I never thought about testing it with NORMAL_MAP_SOLID... Looks like I should spend more time experimenting in the future before posting in the forums :D .

It works ok using Direct3D 9 with NORMAL_MAP_SOLID. The problem only appears when using PARALLAX_MAP_SOLID.

This is good as I can do with NORMAL_MAP_SOLID for the moment. Nevertheless, it is still a very strange bug.

Have you tried reproducing it on your machine ?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, I don't have a windows machine here, it usually takes some time until I have time for testing the windows parts.
Unfortunately, the parallax mapping is implemented in shader 1.4 and 2.0 - I just learned 1.1 for answering your post :(
But there's another thing that would help: Do you have pixel shader 2.0 support, or does your machine use the 1.4 version? Maybe you can even try to use the 1.4 version even if you have 2.0 support as they are rather different. I did not find an obvious bug in these shaders, either, but as they use different texture access I might just not get it. Maybe a shader expoert could help here, too!?
Anteater
Posts: 266
Joined: Thu Jun 01, 2006 4:02 pm
Location: Earth
Contact:

Post by Anteater »

I've been having the same texture problems with my program in DX (See my post, 'washed out parallax mapped textures'). It seems to be a bug in Irrlicht.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hey anteater, now you can see how good screenshots make a difference :wink: I really did not see what you meant when you showed those very dark walls - although you also mentioned all important stuff.
Anyway, it'll need some shader experience to fix this stuff.
Agar
Posts: 22
Joined: Wed May 03, 2006 7:14 pm
Location: France
Contact:

Post by Agar »

hybrid wrote:Do you have pixel shader 2.0 support, or does your machine use the 1.4 version? Maybe you can even try to use the 1.4 version even if you have 2.0 support as they are rather different.
My video card (GeForce 5950Ultra) uses pixel shader 2.0. I'd like to try with the 1.4 version, but how do you tell Irrlicht you want to use it instead of 2.0 ?
World of Ideas : an Irrlicht-powered versus fighting game
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You'll have to change Irrlicht source code and either replace the 2.0 shader with the 1.4 one, or remove the decision where Irrlicht chooses the 2.0 version.
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

Post by gfxstyler »

there are apps for ati cards to force a certain pixel/Vertex shader version (ati tray tools), maybe something like that exists for nvidia cards?
needforhint
Posts: 322
Joined: Tue Aug 30, 2005 10:34 am
Location: slovakia

Post by needforhint »

hmmm
annoing problem. Try this pixel shader, target 2.0, if it gets the texture coords normaly <b>http://www.medeal.sk/irr/displaynormals.zip</b>.
From the picture I cant say which texture, if layer 1 or 2 is messed up, but usaly theese 2 layers share one taccoords, anyway, you can see it in the shader file data/showbi.hlsl , if you want to test texcoords of 2nd layer

Code: Select all

struct VS_INPUT 
{
   float4 Position: POSITION0;
   float2 TexCoord: TEXCOORD0; // here change to TEXCOORD1 
   float3 Normal:   NORMAL0;
   float3 Binormal: BINORMAL0;
   float3 Tangent:  TANGENT0;
   
};
you can also compile it, if you want to test your mesh right away, source is there, set up your own scene.

And maybe you could also state how exactly you did that tiling...
what is this thing...
Post Reply