converting gray texture to black texture.

converting gray texture to black texture.

Post by am9ob » Mon, 26 Jun 2006 02:12:02



I have a texture .
the texture has 3 colors [gray black white]

I want to convert the texture into 2 colors texture [black white]
that is to say , gray colors should be turned to black color.

if I use pixel shader, that is easy.

I make billboard plane and settexture [3 colors texture]

and draw billboard using pixel shader
[ ps code , if color gray, then set out color to black].

and then capture the rendering result [ back buffer or rendertosurface
texture]


but I use only fixed pipeline.
that is , if I use color op, alpha op in SetTextureStageState.
how can I get 2 color texture from 3 color texture.

that is to say,
I want to know how to set color op to achieve it.
 
 
 

converting gray texture to black texture.

Post by Wessam Bah » Mon, 26 Jun 2006 23:08:39

Output your color as alpha in the first stage (include
D3DTA_ALPHAREPLICATE), and set the second stage to output pure black (e.g.
with TFACTOR or DIFFUSE), use this setup to draw a full-screen pure black
quad that maps your texture against a white render target, and make sure you
enable alpha testing (not blending) and set AlphaRef to the threshold on
which you want your grays to be considered blacks instead of whites...

--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts

 
 
 

converting gray texture to black texture.

Post by am9ob » Wed, 28 Jun 2006 17:09:02


thanks for your good idea .
I think it's possible if I do it as you say.

but I searched D3DTA_ALPHAREPLICATE in msdn,
it says that it copy alpha channel to color channel.

so I have to output color as alpha in the first stgage, as you said.
but I don't know how to output color as alpha.

any ideas ?

thanks.
 
 
 

converting gray texture to black texture.

Post by Wessam Bah » Wed, 28 Jun 2006 23:50:58

DOH! Sorry... My mistake...
Unfortunately there's no way to replicate a color channel into alpha with
FFP. Your best bet is to use a different texture format that puts the
relevant color information into the alpha channel of that format.
Why don't you use D3DFMT_A8?

--
Wessam Bahnassi
Microsoft DirectX MVP,
Programmer
Electronic Arts
 
 
 

converting gray texture to black texture.

Post by am9ob » Fri, 30 Jun 2006 13:30:02

Ok, I will try it.