Problem with Reflections and Alpha Blending

Started by
3 comments, last by HerrCron 17 years, 5 months ago
Hey everyone, sorry to be asking questions straight out of the traps, but i am a bit stumped at the moment. Aaaanyway I'm writing a small program all it does is display the Dwarf.x mesh that comes with DirectX. The dwarf is displayed infront of a mirror and cast a shadow on the floor. Next i decided to add rotation to the Dwarf, and this is where the problem starts, somehow i've managed to set the alpha blending in such a way that when the dwarf rotates, he becomes transparent on his 'front' [that is to say, his chest area] This might help clear things up When the program starts, everthing is grand Then, we rotate the dwarf by 180Degrees So, anyway, i reckon this is down to how i have my alphablending set [because if i turn it off, i don't have this problem, but then the reflection doesn't look right] So, i've set up alpha blending like this

Device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
Device->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_ZERO);
Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
And like i said earlier if i disable it, i don't get that problem, so if anyone can help, it'd be great. Thanks in advance HerrCron ps: i know that the reflection is a little too far away, and the shadow or floor aren't reflected, but i know how to fix that, this is doing my head in. Cheers
Advertisement
Toggle the culling order depending on which mesh you're drawing.

Toggle D3DRS_CULLMODE between D3DCULL_CCW and D3DCULL_CW depending on whether you're drawing the real mesh or its reflection...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Currently, the Cullmode is set to
 D3DCULL_CW


when the reflection is being drawn, and no varation on this gets any better result.
Can you explain how you draw the mirror? It's not clear to me how you're using alpha blending.

I think that's also why Jack gave the response he gave. That's because one standard way to draw a mirror is to reflect the transformations and draw the objects again, and that doesn't involve alpha blending.
Yeah, this is actually all a mistake on my end. For some reason i got the notion into my head that i HAD to make the reflection slightly transparent, for *some* reason that escapes me now in the cold light of day.

Thanks jollyjeffers and ET3D for all the help, i promise to think things through before i post a problem again.

Now, where is the D'oh emoticon.....

This topic is closed to new replies.

Advertisement