Sign in to follow this  
Estauns

My Texture Has No Color? [Unsolved =(]

Recommended Posts

Estauns    103
Free Image Hosting at www.ImageShack.us Its a smiley face with a purple background (for colour keying) but the face part doesn't show up. My states are this:
			device.RenderState.Lighting = false;
			device.RenderState.AlphaBlendEnable = true;
			device.RenderState.SourceBlend = Direct3D.Blend.SourceAlpha;
			device.RenderState.DestinationBlend = Direct3D.Blend.InvSourceAlpha;
			device.RenderState.AlphaSourceBlend = Direct3D.Blend.SourceAlpha;
			device.RenderState.AlphaDestinationBlend = Direct3D.Blend.InvSourceAlpha;
texture = Direct3D.TextureLoader.FromFile(device, name, D3DX.Default, D3DX.Default, D3DX.Default, 0, Direct3D.Format.Unknown, Direct3D.Pool.Managed, Direct3D.Filter.None, Direct3D.Filter.None, Color.FromArgb(255, 255, 0, 255).ToArgb()); That's how I load the texture and its not giving me errors... but no face? [Edited by - Estauns on June 28, 2005 1:29:53 AM]

Share this post


Link to post
Share on other sites
Specchum    242
Direct3D doesn't support colour keying. That's available only if you are using Direct Draw. However it does support alpha blending so what you need is a texture with transparency. In photoshop you would create a transparent background (the checkered thing) and create your face on it. Direct3D then should be able to render it properly (if you've set the flags right).

Share this post


Link to post
Share on other sites
Estauns    103
When you load a texture with a colourKey specified, it builds the alpha channel for you, as far as I know. That's why my smiley face has no background, but I can't figure out why his face isn't there.

Heres the documentation for the colour key thing:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m_dec_2004/directx/ref/ns/microsoft.directx.direct3d/c/textureloader/m/fromfile0.asp

Thanks for the response though, still can't figure out why he's all black. =(

Share this post


Link to post
Share on other sites
Endurion    5412
Hmm, remove these:


device.RenderState.AlphaSourceBlend = Direct3D.Blend.SourceAlpha;
device.RenderState.AlphaDestinationBlend = Direct3D.Blend.InvSourceAlpha;


and add these:


device.TextureState.ColorOperation = Direct3D.TextureOperation.Modulate;
device.TextureState.ColorArgument1 = Direct3D.TextureOperation.TextureColor;
device.TextureState.ColorArgument2 = Direct3D.TextureOperation.Diffuse;

device.TextureState.AlphaOperation = Direct3D.TextureOperation.Modulate;
device.TextureState.AlphaArgument1 = Direct3D.TextureOperation.TextureColor;
device.TextureState.AlphaArgument2 = Direct3D.TextureOperation.Diffuse;

Share this post


Link to post
Share on other sites
Specchum    242
Quote:
Original post by Estauns
When you load a texture with a colourKey specified, it builds the alpha channel for you, as far as I know. That's why my smiley face has no background, but I can't figure out why his face isn't there.

Heres the documentation for the colour key thing:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m_dec_2004/directx/ref/ns/microsoft.directx.direct3d/c/textureloader/m/fromfile0.asp

Thanks for the response though, still can't figure out why he's all black. =(


*cough* ahem. I stand corrected! heh heh... *hares away to the coffee machine*

Share this post


Link to post
Share on other sites
Do you specify a vertex color? Is it black? Endurion posted code to modulate texture by diffuse, which should be the default setting. You've disabled lighting, so that's not it, but if you're vertices contain a diffuse it could be the problem.

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