how to LockRect Texture like dxt5 format?

Started by
7 comments, last by ryan20fun 12 years, 8 months ago
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..
Advertisement
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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


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.



thank you
that is to say we can't directly modify this format pixel?
then for this dxt5 format, how to meke it gray??
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).

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).


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
Making a DXT texture grey on the fly isn't that hard. The compressed data format holds raw 5:6:5 colours which you can modify. You just need to work out where they are stored.

Making a DXT texture grey on the fly isn't that hard. The compressed data format holds raw 5:6:5 colours which you can modify. You just need to work out where they are stored.



thanks
i'll see what i can do..
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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

why not "tint" the sprite when you draw it?
the ID3DXSPRITE interface has a tint option when you draw.

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

This topic is closed to new replies.

Advertisement