question about fixing D3DRENDERSTATE_TEXTUREMAPBLEND
alexd4 at inbox.lv
Mon Jan 7 00:55:08 CST 2008
I found some problems with D3DRENDERSTATE_TEXTUREMAPBLEND state =
D3DTBLEND_MODULATE in ddraw and handling the alpha channel. This old state is
currently mapped to texture stage states, with alpha part done as
This isn't correct, I believe, because in some cases it should be taken from
diffuse color (Aliens vs Predator 1 depends on it). But the latter behavior
isn't correct in all cases either.
I found this description of this state on some random website via google:
"D3DTBLEND_MODULATE Modulate texture-blending is supported. In this mode, the
RGB values of the texture are multiplied with the RGB values that would have
been used with no texturing. Any alpha values in the texture replace the alpha
values that would have been used with no texturing."
I guess, this means that it either takes alpha from texture or from diffuse
color, depending on whether the current texture has alpha channel (which takes
priority). I've submitted a test for this to wine-patches that includes checks
with both kinds of textures. It passes on XP and thus supports that this is the
way it is supposed to happen. Unfortunately, this doesn't easily translate to
available texture stage states. So it looks like something more hacky is needed
to make it work correctly in all cases in wine. There are two approaches I can
1) introduce an internal D3DTOP_ value in wined3d that will map to texture alpha
or diffuse alpha, depending on the pixel format of the currently selected texture.
2) move D3DRENDERSTATE_TEXTUREMAPBLEND handling to wined3d;
So it would be nice if Stefan Dösinger or maybe somebody else of d3d devs gave
me some directions - which approach (if any) is ok and acceptable for wine
project. I'll attach a diff with my current hacks that show how 1st approach is
about to look.
BTW, this worked in wine around 0.9.15
There it wasn't mapping to texture stage states, but instead was using such call:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
From what I read about GL_MODULATE, I'm not sure it always does exactly the
thing TEXTUREMAPBLEND=MODULATE is supposed to do, but with Aliens vs Predator it
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the wine-devel