FSA
Erfahrenes Mitglied
Hallo. Ich habe ein Problem mit meinem Bump Mapping Shader. Vorweg: C++, DirectX 9.
Im Anhang sind 2 Bilder. Auf Bild eins(weißes Licht Links) sieht man den Fehler. Das weiße Licht ist Links aber auf der Seite erscheint das Licht von Rechts und das Rote von Links. Also genau falsch rum. In Bild 2(die gegenüberliegende Seite des Würfels) stimmt alles. Also 3 Seiten des Würfels stimmen und 3 nicht. Mein Pixelshader:
Danke im Voraus.
(Crosspost! msvcplusplus = FSA)
Im Anhang sind 2 Bilder. Auf Bild eins(weißes Licht Links) sieht man den Fehler. Das weiße Licht ist Links aber auf der Seite erscheint das Licht von Rechts und das Rote von Links. Also genau falsch rum. In Bild 2(die gegenüberliegende Seite des Würfels) stimmt alles. Also 3 Seiten des Würfels stimmen und 3 nicht. Mein Pixelshader:
C++:
////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 BumpMapPixelShader(PixelInputType input) : COLOR
{
float4 textureColor;
float4 bumpMap;
float3 bumpNormal;
float3 lightDir;
float lightIntensity;
float4 color;
for(int i = 0; i <= 1; i++)
{
textureColor = tex2D( ColorMap, input.tex );
bumpMap = tex2D( BumpMap, input.tex );
// Expand the range of the normal value from (0, +1) to (-1, +1).
bumpMap = (bumpMap * 2.0f) - 1.0f;
bumpNormal = input.normal + bumpMap.x * input.tangent + bumpMap.y * input.binormal;
bumpNormal = normalize(bumpNormal);
float3 lD = lightDirection;
if(i == 1)
{
lD.xy = 0.0f;
lD.z = 1.0f;
}
lightDir = -lD;
if(!bOn)
{
lightIntensity = saturate(dot(input.normal, lightDir));
}
else
{
lightIntensity = saturate(dot(bumpNormal, lightDir));
}
float4 C = diffuseColor;
if(i == 0)
C.rgb = 0.7f;
else
{
C.r = 1.0f;
C.gb = 0.0f;
}
color += saturate( C * lightIntensity);
}
color = color * textureColor;
return color;
}
(Crosspost! msvcplusplus = FSA)
Anhänge
Zuletzt bearbeitet von einem Moderator: