Directx 9法线贴图像素着色器
我有一个关于directx9着色器中法线映射的问题。 当前,我的“法线贴图+漫反射颜色”的地形着色器输出仅会生成此图像。 我觉得很好 如果我使用像这样的空法线贴图图像 我的法线漫反射和颜色贴图的着色器输出如下所示。 但是,如果我使用包含颜色贴图的方法,我会得到一个非常有趣的结果 有人知道是什么导致了这个问题吗 下面是一些片段Directx 9法线贴图像素着色器,directx,pixel-shader,Directx,Pixel Shader,我有一个关于directx9着色器中法线映射的问题。 当前,我的“法线贴图+漫反射颜色”的地形着色器输出仅会生成此图像。 我觉得很好 如果我使用像这样的空法线贴图图像 我的法线漫反射和颜色贴图的着色器输出如下所示。 但是,如果我使用包含颜色贴图的方法,我会得到一个非常有趣的结果 有人知道是什么导致了这个问题吗 下面是一些片段 float4 PS_TERRAIN(VSTERRAIN_OUTPUT In) : COLOR0 { float4 fDiffuseColor; fl
float4 PS_TERRAIN(VSTERRAIN_OUTPUT In) : COLOR0
{
float4 fDiffuseColor;
float lightIntensity;
float3 bumpMap = 2.0f * tex2D( Samp_Bump, In.Tex.xy ).xyz-1.0f;
float3 bumpNormal = (bumpMap.x * In.Tangent) + (bumpMap.y * In.Bitangent) + (bumpMap.z * In.Normal);
bumpNormal = normalize(bumpNormal);
// Direction Light Test ( Test hardcoded )
float3 lightDirection = float3(0.0f, -0.5f, -0.2f);
float3 lightDir = -lightDirection;
// Bump
lightIntensity = saturate(dot( bumpNormal, lightDir));
// We are using a lightmap to do our alpha calculation for given pixel
float4 LightMaptest = tex2D( Samp_Lightmap, In.Tex.zw ) * 2.0f;
fDiffuseColor.a = LightMaptest.a;
if( !bAlpha )
fDiffuseColor.a = 1.0;
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
float4 textureColor = tex2D( Samp_Diffuse, In.Tex.xy );
// Combine the color map value into the texture color.
textureColor = saturate(textureColor * LightMaptest);
textureColor.a = LightMaptest.a;
fDiffuseColor.rgb = saturate(lightIntensity * I_d).rgb;
fDiffuseColor = fDiffuseColor * textureColor; // If i enable this line it goes crazy
return fDiffuseColor;
}