Jump to content
  • Advertisement
Sign in to follow this  

Detail Normal Map 'streaking'

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I'm learning HLSL and I've ran across a problem when implementing detail normal maps (detail diffuse works though <shrug>) Here's the pixel shader
float4 p(v2p In, uniform float4 lightColor) : COLOR
	/*** Custom UV Texture Coords ***/
	float2 DetailN_UV    = In.uv * DetailN_Tile;                                            // Texture UV's for Detail Normal
	float2 DetailD_UV    = In.uv * DetailD_Tile;                                            // Texture UV's for Detail Diffuse
	float2 DiffuseTile   = In.uv * D_Tile;                                                  // Texture UV's for 
	float4 AO            = tex2D(aomapSampler, In.uv);
	float4 DetailDiffuse = tex2D(detaildiffusemapSampler, DetailD_UV);
	float4 Diffuse       = ((tex2D(diffusemapSampler, DiffuseTile) * DetailDiffuse) * AO) / .15;
	//float4 NewDiffuse  = Overlay(Diffuse, DetailDiffuse) / .29;
	float4 Specular      = tex2D(specularmapSampler, DiffuseTile);	
	float3 DNormalPRE  = tex2D(detailnormalmapSampler, DetailN_UV) * 2 - 1;
        float DetailNormal = normalize(DNormalPRE.b * .5);
	float3 Normal        = tex2D(normalmapSampler, DiffuseTile) * 2 - 1;
	float3 NormalComp    = normalize (Normal);// + DetailNormal); THIS IS WHERE THE PROBLEM HAPPENS!!!
	float3 Nn = normalize(In.worldNormal);                                                    // Normalzing the input world space vectors
	float3 Tn = normalize(In.worldTangent);
	float3 Bn = normalize(In.worldBinormal);
	float3 N = (NormalComp.z * Nn) + (NormalComp.x * Bn) + (NormalComp.y * -Tn);
	N = normalize(N);                                                                         // Putting the tangent space normal map into world space
	float3 L = normalize(In.lightVec.xyz);
	float3 V = normalize(In.eyeVec.xyz);
	float3 H = normalize(L + V);                                                               //The half-angle vector, used for blinn specular
	float4 fNDotL   = saturate(dot(N,L));
	float4 cDiffuse = fNDotL * Diffuse;

	float fNDotH     = saturate(dot(N,H));
	float fSpecLevel = pow(fNDotH, g_fGlossiness);
	float4 cSpecular = fSpecLevel * Specular;
	float4 lighting = ((cDiffuse + cSpecular) * lightColor );
	return float4(lighting.xyz, 1);
http://img204.imageshack.us/my.php?image=specularwtf1mn3.jpg <--- the output Thanks so much! It's been driving me crazy!

Share this post

Link to post
Share on other sites
Looks like your texture coordinates are off for your detail normal-map. Have you debugged your shader in PIX to see what DetailN_UV looks like before sampling the normal map?

Share this post

Link to post
Share on other sites
Nope, I haven't yet. Downloading the DX-SDK now (Why didn't I have it on before?).

Never used it, so I'll go through the documentation and return back, hopefully it's an common / easy issue to get through, since it would really help my scene!

Thanks! :)

Share this post

Link to post
Share on other sites
So you know how to do it...

Start up PIX, then set it to target your executable. Click the radio button that says "take a snapshot when F12 is pressed". Then start up your app, line up your shot, press F12, then close your app. When it closes, PIX will bring up a bunch of windows. What you need to is find the surface you rendered to using that particular shader: if you're using post-processing you'll have to go through the list of textures and surfaces and find the one you're looking for (right click on it and then view it to see its contents), otherwise if you rendered to the back buffer it will already be displayed in the window in the bottom right corner. Then right-click on the pixel you want to debug, view it, then click "debug pixel". It'll bring up a window with your disassembly (and your HLSL source code if you compiled your shader with debug information) which you can then step through to see values used.

Also if you want to debug vertex shaders, you need to find the draw call in the list of API calls in the bottom left window and then click on the vertex you want to debug in the lower-right window.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!