• Create Account

Banner advertising on our site currently available from just \$5!

### #Actuallipsryme

Posted 23 April 2013 - 07:43 AM

Um I don't think so...how would I do that ?

Using SampleLevel and going through every mip map and normalizing it ?

normalTS seems fine:

http://d.pr/i/pGwC

Here's the complete PS code for the normal mapping:

VS code is just transforming to world space and normalizing it.

	// Normal Mapping
float3 normalWS = input.Normal * rsqrt(dot(input.Normal, input.Normal)); // normalize
float3 tangentWS = input.Tangent * rsqrt(dot(input.Tangent, input.Tangent)); // normalize
float3 biTangentWS = cross(input.Normal, input.Tangent);

float3 normalTS = float3(0, 0, 1);
float3x3 tangentToWorld = float3x3(tangentWS, biTangentWS, normalWS);

// Sample the normal map, and convert the normal to world space
normalTS.xyz = NormalMap.Sample(AnisotropicSampler, input.UV).xyz * 2.0f - 1.0f;
normalTS.z = sqrt(1.0f - ((normalTS.x * normalTS.x) + (normalTS.y * normalTS.y)));
normalWS = mul(normalTS, tangentToWorld);
normalWS = normalWS * rsqrt(dot(normalWS, normalWS)); // normalize


### #4lipsryme

Posted 23 April 2013 - 07:42 AM

Um I don't think so...how would I do that ?

Using SampleLevel and going through every mip map and normalizing it ?

normalTS seems fine:

http://d.pr/i/pGwC

Here's the complete PS code for the normal mapping:

VS code is just transforming to world space and normalizing it.

	// Normal Mapping
float3 normalWS = input.Normal * rsqrt(dot(input.Normal, input.Normal));
float3 tangentWS = input.Tangent * rsqrt(dot(input.Tangent, input.Tangent));
float3 biTangentWS = cross(input.Normal, input.Tangent);

float3 normalTS = float3(0, 0, 1);
float3x3 tangentToWorld = float3x3(tangentWS, biTangentWS, normalWS);

// Sample the normal map, and convert the normal to world space
normalTS.xyz = NormalMap.Sample(AnisotropicSampler, input.UV).xyz * 2.0f - 1.0f;
normalTS.z = sqrt(1.0f - ((normalTS.x * normalTS.x) + (normalTS.y * normalTS.y)));
normalWS = mul(normalTS, tangentToWorld);
normalWS = normalWS * rsqrt(dot(normalWS, normalWS));


### #3lipsryme

Posted 23 April 2013 - 07:41 AM

Um I don't think so...how would I do that ?

Using SampleLevel and going through every mip map and normalizing it ?

normalTS seems fine:

http://d.pr/i/pGwC

Here's the complete PS code for the normal mapping:

	// Normal Mapping
float3 normalWS = input.Normal * rsqrt(dot(input.Normal, input.Normal));
float3 tangentWS = input.Tangent * rsqrt(dot(input.Tangent, input.Tangent));
float3 biTangentWS = cross(input.Normal, input.Tangent);

float3 normalTS = float3(0, 0, 1);
float3x3 tangentToWorld = float3x3(tangentWS, biTangentWS, normalWS);

// Sample the normal map, and convert the normal to world space
normalTS.xyz = NormalMap.Sample(AnisotropicSampler, input.UV).xyz * 2.0f - 1.0f;
normalTS.z = sqrt(1.0f - ((normalTS.x * normalTS.x) + (normalTS.y * normalTS.y)));
normalWS = mul(normalTS, tangentToWorld);
normalWS = normalWS * rsqrt(dot(normalWS, normalWS));


### #2lipsryme

Posted 23 April 2013 - 07:39 AM

Um I don't think so...how would I do that ?

Using SampleLevel and going through every mip map and normalizing it ?

normalTS seems fine:

http://d.pr/i/pGwC

### #1lipsryme

Posted 23 April 2013 - 07:36 AM

Um I don't think so...how would I do that ?

Using SampleLevel and going through every mip map and normalizing it ?

PARTNERS