2
Le problème est que si je fais tourner le triangle et que la rotation est supérieure à 1,6f, il commence à scintiller.DirectX 11 Scintillement de l'objet par rotation
Voici un morceau de code:
-ici est un petit réglage qui est initalized dans le moteur de rendu
mCamPosition = D3DXVECTOR3{ 0.0f, 0.0f, -0.5f };
mCamTarget = D3DXVECTOR3{ 0.0f, 0.0f, 0.0f };
mCamUp = D3DXVECTOR3{ 0.0f, 1.0f,0.0f };
D3DXMatrixLookAtLH(&mCamView, &mCamPosition, &mCamTarget, &mCamUp);
D3DXMatrixPerspectiveFovLH(&mCamProjection, 0.4f * static_cast<float32>(M_PI),
static_cast<float32>(pWindow->GetSize().Width)/static_cast<float32>(pWindow->GetSize().Height),
1.0f,
1000.0f);
-partie de la boucle principale
...
rotation += 0.0005f;
MeshTransform.SetRotation(rotation);
Renderer->Clear();
Renderer->Draw(Mesh, Shader, &MeshTransform);
Renderer->Display();
...
-part de la fonction de tirage
D3DXMATRIX MeshTranslation;
D3DXMATRIX MeshRotaiton;
D3DXMATRIX MeshWorld;
D3DXMatrixIdentity(&MeshWorld);
D3DXMatrixIdentity(&MeshRotaiton);
D3DXMatrixIdentity(&MeshTranslation);
//Translation
D3DXMatrixTranslation(&MeshTranslation, pTransform->mPosition.X, pTransform->mPosition.Y, 0.0f);
//Rotation
D3DXVECTOR3 RotAxis{ 0.0f, 0.0f, 1.0f };
D3DXMatrixRotationAxis(&MeshRotaiton, &RotAxis, pTransform->mRotation);
MeshWorld = MeshRotaiton * MeshTranslation;
mWVP = MeshWorld * mCamView * mCamProjection;
D3DXMatrixTranspose(&mCBPerObject.WVP, &mWVP);
pContext->DeviceContext->UpdateSubresource(pPerObjectBuffer, NULL, nullptr, &mCBPerObject, NULL, NULL);
pContext->DeviceContext->VSSetConstantBuffers(0, 1, &pPerObjectBuffer);
pContext->DeviceContext->VSSetShader(pShader->cpVertexShader.Get(), 0, 0);
pContext->DeviceContext->PSSetShader(pShader->cpPixelShader.Get(), 0, 0);
...Drawing
fichier -Shader
cbuffer cbPerObject
{
float4x4 WVP;
};
struct VS_OUTPUT
{
float4 Position : SV_POSITION;
float4 Color : COLOR;
};
VS_OUTPUT VS(float4 InPosition : POSITION, float4 InColor : COLOR)
{
VS_OUTPUT Output;
Output.Position = mul(InPosition, WVP);
Output.Color = InColor;
return Output;
}
float4 PS(VS_OUTPUT Input) : SV_TARGET
{
return Input.Color;
}
Je l'ai essayé avec une valeur plus élevée et ça n'a pas fonctionné que j'ai essayé une valeur inférieure ça a marché merci! –
Ok, j'ai édité ma réponse .. merci pour la correction – Nain