[Solved] Blender to OGRE Normal map problem

Problems building or running the engine, queries about how to use features etc.
Post Reply
ppClarity
Gremlin
Posts: 194
Joined: Sat Sep 02, 2006 12:27 am

[Solved] Blender to OGRE Normal map problem

Post by ppClarity » Sat Aug 30, 2008 3:00 pm

Originally posted in Artists & Content Creators

Ogre 1-6 svn 8001
Blender 2.4.7
Ubuntu 8.0.4.1
Nvidia 173.51 driver

I created a character in makehuman, imported it into Blender, created a lowpoly mesh and used the following technique to generate the normal map: (Object to Object baking)

I exported the mesh and created a new material based on Examples/Athene/NormalMapped replacing the normal map with mine and the texture with a skintone. I would have inherited directly from the Examples version but the asm reference causes the Examples-Advanced script to fail to compile.

It looks great in Blender, but in Ogre the effect is backwards, the abs are sinking into the stomach, the spine is a dorsal ridge. Seams are super apparent in the Ogre rendered model but you need to know where to look for them in the Blender render.

Normals have been recalculated outside for both the highpoly and lowpoly meshes.


The .blend is here: http://www.projectplasma.com/BLENDER/lowpolytest.zip [warning nudity]
The .mesh and .material are here: http://www.projectplasma.com/BLENDER/problem-normal.zip

Can anybody tell what I am doing wrong?
Last edited by ppClarity on Thu Sep 04, 2008 7:02 am, edited 1 time in total.
0 x

ppClarity
Gremlin
Posts: 194
Joined: Sat Sep 02, 2006 12:27 am

Post by ppClarity » Tue Sep 02, 2008 5:27 am

Anybody?

Heck, even a workflow that I can follow would be just as valuable. Thanks.
0 x

User avatar
mcaden
Goblin
Posts: 206
Joined: Wed Jul 02, 2008 9:29 am
Location: Texas, USA
Contact:

Post by mcaden » Tue Sep 02, 2008 7:24 pm

Code: Select all

material Human
{

	technique
	{
		pass
		{
			ambient 0.3 0.3 0.3
			diffuse 1.0 1.0 0.9

			texture_unit
			{
				texture human3.png
			}
			
		}
                pass
		{
			ambient 0 0 0 
			iteration once_per_light

			scene_blend add


			texture_unit
			{
				texture mht-lp2-uv.png
				colour_op replace
			}
	}
}
That should work I believe. I'd get a more basic material working first, then add in the more advanced stuff.
0 x

ppClarity
Gremlin
Posts: 194
Joined: Sat Sep 02, 2006 12:27 am

Post by ppClarity » Thu Sep 04, 2008 7:04 am

Ran the hi and lo poly meshes through xNormal and out popped a normal map that works with the example shaders. So now I get to go bug the Blender people :D
0 x

ppClarity
Gremlin
Posts: 194
Joined: Sat Sep 02, 2006 12:27 am

Post by ppClarity » Fri Sep 05, 2008 6:08 am

Played a bit with xNormal and the Blender generated normal map tonight. Changing the X component to -X corrected the map there, so I made the following change to main_fp and similar ones to main_shadowreceiver_fp and specular_fp.

Code: Select all

void main_fp( float2 uv			: TEXCOORD0,
			float3 TSlightDir : TEXCOORD1,
			out float4 colour	: COLOR,
			uniform float4 lightDiffuse,
			uniform sampler2D   normalMap : register(s0))
{
	// retrieve normalised light vector, expand from range-compressed
	float3 lightVec = normalize(TSlightDir).xyz;

#if INVERT_X_COMPONENT
	// Blender's normal map has the X component inverted
	lightVec = float3(-lightVec.x, lightVec.y, lightVec.z);
#endif

	// get bump map vector, again expand from range-compressed
	float3 bumpVec = expand(tex2D(normalMap, uv).xyz);

	// Calculate dot product
	colour = lightDiffuse * dot(bumpVec, lightVec);

}
0 x

User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm

Re: [Solved] Blender to OGRE Normal map problem

Post by koirat » Thu Jan 06, 2011 4:21 pm

Yes.
My graphic is inverting red component of a normal map generated in blender.
It's easy to omit this normal map bugs since it looks bumpy even with not inverted normal map, it's just it's not correct and it can generate some ugly seams.
0 x
This is a block of text that can be added to posts you make. There is a 255 character limit.

scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 2

Re: [Solved] Blender to OGRE Normal map problem

Post by scrawl » Sat Dec 10, 2011 5:25 pm

Sorry to dig up this old thread. But I hope this information can help someone else:

When using Blender 2.4, invert the "Red" Channel of the normal map before using it in Ogre (as already pointed out in this thread).

But if you use Blender 2.6, you need to invert the "Green" channel.

The change is documented here: http://projects.blender.org/scm/viewvc. ... sion=35107
0 x

User avatar
saejox
Goblin
Posts: 260
Joined: Tue Oct 25, 2011 1:07 am

Re: [Solved] Blender to OGRE Normal map problem

Post by saejox » Sun Dec 11, 2011 4:57 am

scrawl wrote:Sorry to dig up this old thread. But I hope this information can help someone else:

When using Blender 2.4, invert the "Red" Channel of the normal map before using it in Ogre (as already pointed out in this thread).

But if you use Blender 2.6, you need to invert the "Green" channel.

The change is documented here: http://projects.blender.org/scm/viewvc. ... sion=35107
thank you. i knew i was doing something wrong.
i almost gave up on using blender for normal maps.
0 x
Nimet - Advanced Ogre3D Mesh/dotScene Viewer
asPEEK - Remote Angelscript debugger with html interface
ogreHTML - HTML5 user interfaces in Ogre

Post Reply