• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1SIC Games  Members

Posted 01 September 2014 - 05:36 PM

When I output the normal map this shows up:

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.

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

### #2Hodgman  Moderators

Posted 01 September 2014 - 06:34 PM

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.

### #3SIC Games  Members

Posted 01 September 2014 - 06:56 PM

Top view:

Left View

Bottom View

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

### #4SIC Games  Members

Posted 01 September 2014 - 06:57 PM

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

### #5Hodgman  Moderators

Posted 01 September 2014 - 06:59 PM

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.

Edited by Hodgman, 01 September 2014 - 06:59 PM.

### #6SIC Games  Members

Posted 01 September 2014 - 07:24 PM

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

input.normal as color

input.tangent as color

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

### #7SIC Games  Members

Posted 01 September 2014 - 07:26 PM

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

### #8SIC Games  Members

Posted 01 September 2014 - 07:39 PM

This is the tangent rendered out without using color

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.

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

### #9SIC Games  Members

Posted 01 September 2014 - 09:28 PM

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

Mine inside editor:

Brayznsoft Normal Map tutorial - Tangent Data rendered out

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

### #10SIC Games  Members

Posted 02 September 2014 - 12:37 AM

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.