What are these showing in my normal map (Forward Rendering)

Started by
8 comments, last by Paul C Skertich 9 years, 7 months ago

When I output the normal map this shows up:

[attachment=23421:Snapshot1.jpg]

Would this be a normal issue inside the mesh? Funny how Brazynsoft checks to see if the parameter of cumpute normals is true or false. If not then it uses the normals from the mesh. I'm using the normals from the mesh.

The shader:


output.normal = mul(input.normal, (float3x3)worldMatrix); //-- worldMatrix is the model's world matrix.
output.tangent = mul(input.tangent, (float3x3)worldMatrix);

PS


float3 normalmap = Textures[1].Sample(ss, input.texcoord);
normalmap = 2.0f * normalmap - 1.0f;

input.normal  = normalize(input.normal);
input.tangent = normalize(input.tangent - dot(input.tangent, input.normal) * input.normal);
float3 biTangent  = cross(input.tangent, input.normal);
float3x3 texSpace = float3x3(biTangent, input.Tangent, input.normal);

input.normal = normalize(mul(normalmap, texSpace));

Or possibly this could be a result of the normal map its self.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX
Advertisement

To help debugging, temporarily edit the PS to output as a colour:

  • normalize(input.normal)*0.5+0.5
  • normalize(input.tangent)*0.5+0.5
  • normalmap (the unmodified texture sample)
  • normalize(mul(normalmap, texSpace)) (the final normal value)

Hopefully the resulting images will show you which bit of data is not quite right.

What I got was this :

[attachment=23423:Snapshot1.jpg]

Top view:

[attachment=23424:Snapshot2.jpg]

Left View

[attachment=23425:Snapshot3.jpg]

Bottom View

[attachment=23426:Snapshot4.jpg]

What colors am I looking for exactly?

I changed the PS code to be like you mentioned:


        input.normal = normalize(input.normal) * 0.5f + 0.5f;
	input.tangent = normalize(input.normal) * 0.5f + 0.5f;
	
	//input.tangent = normalize(input.tangent - dot(input.tangent, input.normal) * input.normal);

	float3 B = cross(input.normal,input.tangent);
	float3x3 texspace = float3x3(input.tangent,B,input.normal);
         input.normal = mul(normalmap,texspace);
	
Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

the normalmap texture isn't modified - just left what it was sampled. without the 2.0f * normalmap.xyz - 1.0f;

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

Sorry, those bullet points were 4 different suggestions. Edit the pixel shader to output just one of those bullet points at a time, so you can visualize each bit of input data by itself.

Your original screenshot shows a discontinuity in the data. Either the normal map, the model's normals or the model's tangents are likely to blame.

By editing the shader 3 times to output just one of those variables at a time, you can find the source of this discontinuity.

By discontinuuity what do you mean? Non-consistant?

This is the image of the normal as a color:

The hard edge is considered a discontinuity?

Normal map

[attachment=23428:Snapshot1.jpg]

input.normal as color

[attachment=23429:Snapshot1 - Copy (2).jpg]

input.tangent as color

[attachment=23430:Snapshot1 - Copy.jpg]

I'm sorry for uploading so many photos just trying to understand what you mean by discontinuity and how to debug something later in the future.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

By the way the tangent looks like - it looks like that's an issue because the normnal and the normal map gradually continues and doesn't abruplty go into a orange color like the tangent image does. What do you think?

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

This is the tangent rendered out without using color

[attachment=23432:Snapshot1 - Copy (3).jpg]

The black and the abruptness of colors I would suspect to be a issue in the tangents. So possibly I would have to re-calculate the tangents by using the normals inside the mesh.

This is the tangent data calculated.

[attachment=23433:Snapshot1.jpg]

The same edges appear as top of this thread. So possibly recacluating the tangent data would do some good.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

I hit the jack pot - I rendered Tangent data out Brayzsoft tutorial Normal Mapping and compared to mine plane.

Mine inside editor:

[attachment=23434:Snapshot1.jpg]

Brayznsoft Normal Map tutorial - Tangent Data rendered out

[attachment=23435:Brayzsoft-Normalmapsample (0-00-10-19).jpg]

Now the question is since I set the compute normals off inside Brayzansoft normal map example - I have to look deeper into why my tangents aren't working.

Thanks Hodges for giving a helping hand but I know which direction now I have to head. Focus on how the data's being loaded from the mesh and also see if I can place visual cues in the geometry shader of the normals directions too.

Thanks Hodge..

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

I've solved the issue - in BrazynerSoft Normalmapping tutorial he has it where you can compute the normals and tangents if needed to.

What I didn't notice is inside where the vertex data gets stored there's a XMFLOAT3 Tangent. If the compute normals aren't enabled - it sets the Tangent Data to black. Still resulting in proper display of the normal map without the messed up with edges that I had first post.

So, now there's no longer a weird shading issue due to proper filling of the input layout for the shader and the the vertex data. It's really funny how the input layout for the shader has to match the exact same type of vertex data going in.

Thanks again for the support!

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

This topic is closed to new replies.

Advertisement