• Create Account

### #Actual~Helgon

Posted 23 November 2012 - 07:06 PM

Hi,

i have a problem with one of the exersises in "introduction to gameprogramming with directx 11" (for the ones who have the book, its chapter 10, exercise 7).

the task ist to draw an animation with additive blending. after trying some logic thinks i started "brute forcing" all possible variations but what ever i tried i never got the desired result.

i attached an img so u can see what is requested and what is my "best" result yet.

i hope that someone can give me a hint.. really tryed to solve it by my own for hours

(thats the blend desc which gives me the best result like on the screenshot (right))

D3D11_BLEND_DESC noBlack = {0};
noBlack.AlphaToCoverageEnable = false;
noBlack.IndependentBlendEnable = false;
noBlack.RenderTarget[0].BlendEnable = true;
noBlack.RenderTarget[0].SrcBlend	   = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].DestBlend	  = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].SrcBlendAlpha  = D3D11_BLEND_ONE;
noBlack.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
HR(device->CreateBlendState(&amp;noBlack, &amp;NoBlack));


boxTech->GetDesc( &amp;techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
md3dImmediateContext->IASetVertexBuffers(0, 1, &amp;mBoxVB, &amp;stride, &amp;offset);
md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);
// Draw the Cylinder
XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
XMMATRIX worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoltMat);
Effects::BasicFX->SetDiffuseMap(bolts[currentBolt]);
md3dImmediateContext->OMSetBlendState(RenderStates::NoBlack, blendFactor, 0xffffffff);
landAndWavesTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(mCylIndexCount, mCylIndexOffset, mCylVertexOffset);
// Set per object constants.
worldInvTranspose = MathHelper::InverseTranspose(world);
worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoxMat);
Effects::BasicFX->SetDiffuseMap(mBoxMapSRV);
md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff);
boxTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(36, 0, 0);

}


i really hope that someone can help me because i get crazy

regards helgon

### #2~Helgon

Posted 23 November 2012 - 07:06 PM

Hi,

i have a problem with one of the exersises in "introduction to gameprogramming with directx 11" (for the ones who have the book, its chapter 10, exercise 7).

the task ist to draw an animation with additive blending. after trying some logic thinks i started "brute forcing" all possible variations but what ever i tried i never got the desired result.

i attached an img so u can see what is requested and what is my "best" result yet.

i hope that someone can give me a hint.. really tryed to solve it by my own for hours

(thats the blend desc which gives me the best result like on the screenshot (right))

D3D11_BLEND_DESC noBlack = {0};
noBlack.AlphaToCoverageEnable = false;
noBlack.IndependentBlendEnable = false;
noBlack.RenderTarget[0].BlendEnable = true;
noBlack.RenderTarget[0].SrcBlend	   = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].DestBlend	  = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].SrcBlendAlpha  = D3D11_BLEND_ONE;
noBlack.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
HR(device->CreateBlendState(&amp;noBlack, &amp;NoBlack));


boxTech->GetDesc( &amp;techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
md3dImmediateContext->IASetVertexBuffers(0, 1, &amp;mBoxVB, &amp;stride, &amp;offset);
md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);
// Draw the Cylinder
XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
XMMATRIX worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoltMat);
Effects::BasicFX->SetDiffuseMap(bolts[currentBolt]);
md3dImmediateContext->OMSetBlendState(RenderStates::NoBlack, blendFactor, 0xffffffff);
landAndWavesTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(mCylIndexCount, mCylIndexOffset, mCylVertexOffset);
// Set per object constants.
worldInvTranspose = MathHelper::InverseTranspose(world);
worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoxMat);
Effects::BasicFX->SetDiffuseMap(mBoxMapSRV);
md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff);
boxTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(36, 0, 0);

}


i really hope that someone can help me because i get crazy

regards helgon

### #1~Helgon

Posted 23 November 2012 - 07:04 PM

Hi,

i have a problem with one of the exersises in "introduction to gameprogramming with directx 11" (for the ones who have the book, its chapter 10, exercise 7).

the task ist to draw an animation with additive blending. after trying some logic thinks i started "brute forcing" all possible variations but what ever i tried i never got the desired result.

i attach a img so u can see what is requested and what is my "best" result yet.

i hope that someone can give me a hint.. really tryed to solve it my own for hours

(what gives my best results like on the screenshot (right))

D3D11_BLEND_DESC noBlack = {0};
noBlack.AlphaToCoverageEnable = false;
noBlack.IndependentBlendEnable = false;
noBlack.RenderTarget[0].BlendEnable = true;
noBlack.RenderTarget[0].SrcBlend	   = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].DestBlend	  = D3D11_BLEND_SRC_ALPHA;
noBlack.RenderTarget[0].SrcBlendAlpha  = D3D11_BLEND_ONE;
noBlack.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE;
HR(device->CreateBlendState(&noBlack, &NoBlack));


boxTech->GetDesc( &techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
md3dImmediateContext->IASetVertexBuffers(0, 1, &mBoxVB, &stride, &offset);
md3dImmediateContext->IASetIndexBuffer(mBoxIB, DXGI_FORMAT_R32_UINT, 0);
// Draw the Cylinder
XMMATRIX worldInvTranspose = MathHelper::InverseTranspose(world);
XMMATRIX worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoltMat);
Effects::BasicFX->SetDiffuseMap(bolts[currentBolt]);
md3dImmediateContext->OMSetBlendState(RenderStates::NoBlack, blendFactor, 0xffffffff);
landAndWavesTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(mCylIndexCount, mCylIndexOffset, mCylVertexOffset);
// Set per object constants.
worldInvTranspose = MathHelper::InverseTranspose(world);
worldViewProj = world*view*proj;

Effects::BasicFX->SetWorld(world);
Effects::BasicFX->SetWorldInvTranspose(worldInvTranspose);
Effects::BasicFX->SetWorldViewProj(worldViewProj);
Effects::BasicFX->SetTexTransform(XMMatrixIdentity());
Effects::BasicFX->SetMaterial(mBoxMat);
Effects::BasicFX->SetDiffuseMap(mBoxMapSRV);
md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff);
boxTech->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->DrawIndexed(36, 0, 0);

}


i really hope that someone can help me because i get crazy

regards helgon

PARTNERS