• Advertisement
Sign in to follow this  

DDS files and transparency, with DirectX

This topic is 972 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

  Hi there GameDev.net forum posters,

 

   This is my first post here, and I hope my problem isn't too mundane to merit a response from some of you pros.

 

    I am editing a texture in photoshop, the dimensions of the file are 2048 x 2048 pixels. I am dividing the texture into 256 pixel squares so I can animate a grass animation within my engine. 

 

I am on photoshop cs6, with the nvidia texture plugin. 

 

Here is what I am usually looking at for a texture.     post-231819-0-43388100-1440275029_thumb.

 

 

When I try to save as a .DDS file, i select DXT5 format, disable mipmapping, and when I preview the texture, I get this.

 

post-231819-0-42327100-1440275039_thumb.

 

 

I looked around, and I guess I'm suppose to have an alpha mask channel in my photoshop file. so I do that, select the texture and remove that from the alpha. Still when I try to save the dds texture, I end up like this

 

post-231819-0-53413600-1440275267_thumb.

 

I've tried different formats DXT3, ARGB 256 colors + alpha, but I just cant get the desired result.

 

If I save it as a .PNG file, I end up with a texture that I would like.    post-231819-0-74450200-1440275407_thumb.

 

   But when I save as a .PNG file, and load the texture into my engine using the call.

 

result = CreateWICTextureFromFileEx(device,filesnames.c_str(), 0u, D3D11_USAGE_STAGING,

0, D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ, 0, false, &srcTex, nullptr);

 

I end up with the same ugly textures being rendered in the engine.

 

Any help or guidance would be appreciated.

 

Cheers,

RedBeard

Share this post


Link to post
Share on other sites
Advertisement

What are you using to preview the images?

When you save the texture, it has to put *something* into the RGB channels for the transparent pixels. You don't have any colour data there in photoshop, so the exporter is inventing data for you. This shouldn't be a problem as long as you render the texture using alpha blending. It just looks like your preview tool isn't using alpha blending...

Share this post


Link to post
Share on other sites

Thanks for your help Hodgman,

 

      I didn't know that the saved texture didn't have to look like it matched the initial image as long as you were using alpha blending.  Turns out it was a problem in my pixel shader where I was using the line

 

color.a = input.instanceTransparency;       

 

where I should have been using

 

color.a -= input.instanceTransparency;

 

Thx again for the quick reply and insight into how these files are processed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement