Jump to content
  • Advertisement
Sign in to follow this  

Blending not updating

This topic is 2836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, I know i'm just missing something stupid here, i've had this problem before. But I'm working with Direct3D 10 and C++, and i'm trying to play with the blending. I'm having a funny problem though. The blending sort of works, but its not updating as the object is spinning. its like it did all the blending at initialization time, so as the object spins, some sides of the object are blending correctly, but other sides are not see through. I know this is a little vague, but i'm just looking for more of a theory of whats happening. When the object starts out, the face facing me is not see through, as the object spins, the next face is see through and i can see the other side, which is right, then when the back of the object comes around, the front side of the object is invisible. It seems like it would be something with it being blended at initialization time, but i'm not too sure.

here is a sample of what i'm working with

(in the initialize scene function)

D3D10_BLEND_DESC blendDesc = {0};
blendDesc.AlphaToCoverageEnable = false;
blendDesc.BlendEnable[0] = true;
blendDesc.SrcBlend = D3D10_BLEND_SRC_COLOR;
blendDesc.DestBlend = D3D10_BLEND_INV_SRC_COLOR;
blendDesc.BlendOp = D3D10_BLEND_OP_ADD;
blendDesc.SrcBlendAlpha = D3D10_BLEND_ONE;
blendDesc.DestBlendAlpha = D3D10_BLEND_ZERO;
blendDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
blendDesc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;

d3dDevice->CreateBlendState(&blendDesc, &TransparentBS);


ZeroMemory(&cmdesc, sizeof(D3D10_RASTERIZER_DESC));
cmdesc.FillMode = D3D10_FILL_SOLID;
cmdesc.CullMode = D3D10_CULL_NONE;
cmdesc.FrontCounterClockwise = true;
hr = d3dDevice->CreateRasterizerState(&cmdesc, &cullMode);


(in the draw scene function)

d3dDevice->OMSetBlendState(0, NULL, 0xffffffff);
d3dDevice->OMSetBlendState(TransparentBS, NULL, 0xffffffff);

Share this post

Link to post
Share on other sites
I'm testing it with a cube, and it seems like i was kinda wrong. This is really stupid, I've had this problem before I think, its been a long time since i played with this... Anyway, i'm going to try to explain exactly what i see.

Starting with the FRONT face, which is the face of the cube that starts out facing the camera. The FRONT face is totally opaque, not transparent at all, however, it changes tones as i play with the blending operators, like it gets darker or lighter.

As the cube spins to the right, the LEFT face comes around. It is transparent, and i can see all the other sides of the cube, EXCEPT for the RIGHT side of the cube as it passes around behind, the RIGHT face is invisible when its behind the LEFT face of the cube.

The BACK side comes around now, and it is also transparent, BUT... The only face i can see behind the BACK face is the FRONT face.

Now the RIGHT side of the cube comes around, and it is also transparent, and i can see ALL sides of the cube through it, which is what i want. For some reason, this is the only face that works the way ALL the faces should work.

Now spinning the cube on the x-axis, when the TOP face of the cube comes around, i can only see the FRONT face and the BACK face through it.

And finally, when the BOTTOM face comes around, I can't see the LEFT or RIGHT faces.

Now that i'm explaining this so thoroughly, i'm beginning to see a patter... I'm going to try a couple more things and i'll report back if i fix it.

(sides that can be seen through)

TOP: 2

Share this post

Link to post
Share on other sites
Sounds like depth-testing is enabled. Disable depth-testing, or sort your faces and draw them back to front, relative to the current camera/rotation. Depending on your blending mode, you might need to sort anyway to get correct output, but for simple blending disabling depth testing can be enough.

Share this post

Link to post
Share on other sites
Of course, I didn't even think of disabling the depth testing until you mentioned it. Thanks for the fast reply!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!