Archived

This topic is now archived and is closed to further replies.

Ysaneya

Mipmap lod bias crazyness

Recommended Posts

Huh oh, i'm basically trying to make mipmap lod bias working in DX9. I want to blur a whole dynamic texture by a constant factor. I've got a Radeon 8500 and it works fine under OpenGL, so it's not a hardware thing. I obviously create the dynamic texture with the D3DUSAGE_AUTOGENMIPMAP flag. I render my scene to this texture, then later try to display it again on a full-screen quad, but blurred. For that, i use: m_lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER,D3DTEXF_LINEAR); m_lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER,D3DTEXF_LINEAR); m_lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER,D3DTEXF_LINEAR); m_lpDevice->SetSamplerState(0, D3DSAMP_MIPMAPLODBIAS, n); where n is my lod bias factor. So what goes wrong ? Well, whatever the value n i give, i don't see any kind of blurring. I also tried to use the map mip level, but this one gives complete garbage for any value other than the default (0). Any help is welcome.. Y. [edited by - Ysaneya on January 28, 2003 1:18:41 PM]

Share this post


Link to post
Share on other sites
AFAIK the MIPMAPLODBIAS is a floating point value (it was in DX8, and I don''t think that''s changed), however you''re passing it as an integer. The SetBlahBlah() functions all take integer values, floating point values have to be converted into the integer version of their binary data in memory rather than the integer version of their value.

You can''t simply cast into an integer either since that will lose the fractional part of the value.

You pass the integer representation of a floating point value in memory like this:

float fValue = 10.34262f;
pDev->SetBlah( blah, BLAH_MIPMAPLODBIAS, *((DWORD *)&fValue) );

i.e. put the value in memory, then read the integer value from that memory address.

A pointer alias safe alternative is to use a union and pass the DWORD version to D3D.


500

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Thank you, that did the trick. I assumed casting the bias to a DWORD would do the trick, but i was wrong. It''s funny how the expected type is not even mentionned in the docs..

Y.

Share this post


Link to post
Share on other sites