# final computed color for a normal and shadow map pixel shader

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

## Recommended Posts

Hi I have 2 separate effect files here - one is use for bump mapping and the other one is use for shadow mapping. I think I have combined them successfully except for the final output color from the pixel shader. On my NormalMap.fx, the final computed color looks like this: float3 color = (ambient + diffuse)*texColor.rgb + spec; On my ShadowMap.fx, the final computed color looks like this: float3 litColor = spot*ambient*texColor.rgb + spot*shadowCoeff*(diffuse*texColor.rgb + spec); I need to modify the final output color in ShadowMap.fx because my scene looks erratic or at least I need to move my spot light way so near the texture just to see the bumps. Let me know if you need additional information. Thanks.

##### Share on other sites

float3 color = (ambient + diffuse)*texColor.rgb + spec;

Where is the normal vector? Usually you'd have a dot(normal,light) term or something similar.

Quote:
 I need to move my spot light way so near the texture just to see the bumps.
Sounds to me like you've got some sort of scaling issue. Are you sure your normals are normalized? Also, it's fair game to include a scalar bias in the N•L computation to make the bumps more dramatic or more soft - maybe you need to consider this instead?

hth
Jack

##### Share on other sites
Hi Jack

Thanks for trying to help. It happened a little above. I'm posting more code now:

Shows how I pull the normals from the normal map, specular from the specular map and calculate the diffuse, spec and ambient final colors:

// Sample normal map.float3 normalT = tex2D(NormalMapS, tex0);	// Expand from [0, 1] compressed interval to true [-1, 1] interval.normalT = 2.0f*normalT - 1.0f;    // Make it a unit vector.normalT = normalize(normalT);// Compute the reflection vector.float3 r = reflect(-lightVecT, normalT);// Determine how much (if any) specular light makes it into the eye.float t  = pow(max(dot(r, toEyeT), 0.0f), gMtrl.specPower);	// Determine the diffuse light intensity that strikes the vertex.float s = max(dot(lightVecT, normalT), 0.0f);// Calculate spec, ambient and diffusefloat3 specT = tex2D(SpecularMapS, tex0);float spec = t*(specT*gLight.spec).rgb;	float3 diffuse = s*(gMtrl.diffuse*gLight.diffuse).rgb;float3 ambient = gMtrl.ambient*gLight.ambient;// and finally sample the diffuse texture color:float4 texColor = tex2D(TexS, tex0);

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013607
×