Jump to content

  • Log In with Google      Sign In   
  • Create Account

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.

  • You cannot reply to this topic
9 replies to this topic

#1 SIC Games   Members   -  Reputation: 617

Like
1Likes
Like

Posted 01 September 2014 - 05:36 PM

When I output the normal map this shows up:

 

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


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31800

Like
3Likes
Like

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.



#3 SIC Games   Members   -  Reputation: 617

Like
1Likes
Like

Posted 01 September 2014 - 06:56 PM

What I got was this :
 

Snapshot1.jpg

 

Top view:

 

Snapshot2.jpg

 

Left View

Snapshot3.jpg

 

Bottom View

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


#4 SIC Games   Members   -  Reputation: 617

Like
0Likes
Like

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


#5 Hodgman   Moderators   -  Reputation: 31800

Like
2Likes
Like

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.


#6 SIC Games   Members   -  Reputation: 617

Like
1Likes
Like

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

Snapshot1.jpg

 

input.normal as color

Snapshot1 - Copy (2).jpg

 

input.tangent as color

 

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


#7 SIC Games   Members   -  Reputation: 617

Like
0Likes
Like

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


#8 SIC Games   Members   -  Reputation: 617

Like
1Likes
Like

Posted 01 September 2014 - 07:39 PM

This is the tangent rendered out without using color

 

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.

 

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


#9 SIC Games   Members   -  Reputation: 617

Like
3Likes
Like

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:

 

Snapshot1.jpg

 

Brayznsoft Normal Map tutorial - Tangent Data rendered out

 

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


#10 SIC Games   Members   -  Reputation: 617

Like
4Likes
Like

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





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.



PARTNERS