Sign in to follow this  
xychzh

how to LockRect Texture like dxt5 format?

Recommended Posts

xychzh    100
I want to make the disable effect for button, and the texture is dxt5 format, so i need to modify the texture pixel
this is not same as the uncompress format, yes??
then how to LockRect this format??

thank you..

Share this post


Link to post
Share on other sites
mhagain    13430
You can LockRect it but it will give you access to the compressed texels. An alternative is to use something like D3DXLoadSurfaceFromSurface, which will handle decompression for you, then load it back on to the original texture, but it's not going to give you high performance and will be sending the texture through another compression step, which will cause a loss in quality. Best option is to use D3DFMT_X8R8G8B8 or D3DFMT_A8R8G8B8 for textures that you need to modify in this way.

Share this post


Link to post
Share on other sites
xychzh    100
[quote name='mhagain' timestamp='1313684672' post='4850823']
You can LockRect it but it will give you access to the compressed texels. An alternative is to use something like D3DXLoadSurfaceFromSurface, which will handle decompression for you, then load it back on to the original texture, but it's not going to give you high performance and will be sending the texture through another compression step, which will cause a loss in quality. Best option is to use D3DFMT_X8R8G8B8 or D3DFMT_A8R8G8B8 for textures that you need to modify in this way.
[/quote]


thank you
that is to say we can't directly modify this format pixel?
then for this dxt5 format, how to meke it gray??

Share this post


Link to post
Share on other sites
xychzh    100
[quote name='Hodgman' timestamp='1313717884' post='4851023']
Locking the pixels and modifying them is the wrong solution to make a button grey. You should instead either use a pixel shader to make it grey, or have two different copies of the texture (on that is grey, and one that is not).
[/quote]

my project is not use shader, i make 2d game with d3d9?i render texture with XYZRHW and DrawPrimitiveUp.?
so i often use this way to modify pixels.
if not, i have to prepare a gray texture additional.
thank you

Share this post


Link to post
Share on other sites
Adam_42    3629
Making a DXT texture grey on the fly isn't that hard. The [url="http://en.wikipedia.org/wiki/S3_Texture_Compression"]compressed data format[/url] holds raw 5:6:5 colours which you can modify. You just need to work out where they are stored.

Share this post


Link to post
Share on other sites
xychzh    100
[quote name='Adam_42' timestamp='1313750486' post='4851140']
Making a DXT texture grey on the fly isn't that hard. The [url="http://en.wikipedia.org/wiki/S3_Texture_Compression"]compressed data format[/url] holds raw 5:6:5 colours which you can modify. You just need to work out where they are stored.
[/quote]


thanks
i'll see what i can do..

Share this post


Link to post
Share on other sites
mhagain    13430
Or if all you want to do is greyscale it you could use a D3DTOP_DOTPRODUCT3 TextureStageState blend with either a texture, a temp color or a constant color having R/G/B in the proportions 0.3/0.59/0.11.

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