Sign in to follow this  
HerrCron

Problem with Reflections and Alpha Blending

Recommended Posts

HerrCron    122
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

Share this post


Link to post
Share on other sites
jollyjeffers    1570
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

Share this post


Link to post
Share on other sites
ET3D    810
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.

Share this post


Link to post
Share on other sites
HerrCron    122
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.....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this