mal wieder macht mir die Shader-Programmierung unvorhersehbare Probleme. Problem diesmal ist, dass das Mesh der mit Hilfe des Effektes gerendert wird eben nicht angezeigt wird.
Aber Code sagt mehr als tausend Worte:
Hier die .Fx Datei:
Code: Alles auswählen
//--------------------------
//--- Globals --------------
//--------------------------
float4x4 matWorldViewProj;
float3x3 matRotation;
texture tex0;
sampler DiffuseTex = sampler_state
{
texture = (tex0);
MIPFILTER = LINEAR;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
//--------------------------
//--- Vertex Shader -------
//--------------------------
struct VS_OUTPUT
{
float4 vPos : POSITION;
float2 vTex0 : TEXCOORD0;
float3 vNormal : TEXCOORD1;
};
VS_OUTPUT VS(float4 vPosition : POSITION,
float3 vNormal : NORMAL,
float2 vTexCoord : TEXCOORD0)
{
VS_OUTPUT OUT =(VS_OUTPUT)0;
OUT.vPos = mul(matWorldViewProj, vPosition);
OUT.vNormal = mul(matRotation, vNormal);
OUT.vTex0 = vTexCoord;
return OUT;
}
float4 PS(float2 vTex0 : TEXCOORD0) : COLOR
{
return tex2D(DiffuseTex, vTex0);
}
//---------------------------
//--- Techniken -------------
//---------------------------
technique tec0
{
pass p0
{
//Vertexshader
VertexShader = compile vs_1_1 VS();
//Pixelshader
PixelShader = compile ps_2_0 PS();
}
}
Code: Alles auswählen
//Matricen
//welt sicht und projektions matrix
MATRIX matWorldViewProj, matWorldIT;
matWorldViewProj = maWorld*view*proj;
//Berechnungen an Effekt geben
bumpMapping.GetEffect()->SetMatrix("matWorldViewProj", &matWorldViewProj);
bumpMapping.GetEffect()->SetMatrix("matRotation", &maRotate);
if(textures[i])
bumpMapping.GetEffect()->SetTexture("tex0", textures[i]);
//zeichenvorgang
bumpMapping.BeginEffect();
for(DWORD j = 0; j < bumpMapping.GetNumPasses(); j++)
{
bumpMapping.BeginPass(j);
HRESULT hr = mesh->DrawSubset(i);
bumpMapping.EndPass();
}
bumpMapping.EndEffect();
Außerdem habe ich geprüft, ob die richtigen Werte an den Effekt übergeben werden. Dies ist auch der Fall.
Sieht jemand einen Fehler in der Shaderdatei oder im Code?
MfG Droven