Page 1 of 1

Problem with normal maps and repeating textures

Posted: Wed Jun 21, 2006 12:05 am
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!

Posted: Wed Jun 21, 2006 8:49 am
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.

Posted: Wed Jun 21, 2006 12:35 pm
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.

Posted: Wed Jun 21, 2006 2:51 pm
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?

Posted: Wed Jun 21, 2006 3:38 pm
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 ?

Posted: Wed Jun 21, 2006 4:04 pm
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!?

Posted: Wed Jun 21, 2006 4:15 pm
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.

Posted: Wed Jun 21, 2006 7:21 pm
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.

Posted: Thu Jun 22, 2006 3:33 am
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 ?

Posted: Thu Jun 22, 2006 8:09 am
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.

Posted: Thu Jun 22, 2006 11:22 am
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?

Posted: Sun Jul 02, 2006 2:12 pm
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...