Jump to content

[Solved] Creating and Drawing DDS With Alpha


Shard
 Share

Recommended Posts

Hey guys.

 

I am trying to create a HUD with several transparency sprites and draw them to the screen and I've had a couple of problems with them. Loading and drawing a DDS with no transparency works just fine, but loading ones with it result in one of these three problems depending on the setting used:

 

1) A bad pointer error

2) The transparency loads as black.

3) The transparency loads as white.

4) The entire sprite loads as white.

 

This leads me to as a couple questions.

1) How are we supposed to create DDS with texture?

2) How am I supposed to call the render functions?

 

 

I was originally calling the update of the HUD like this:

//Main loop 
while(!KeyHit(KEY_ESCAPE) && !AppSuspended())
{
	controls->Update();
	player->Update();
	aiManager->Update();
	world->Update();



	frameWerk->Update();
	frameWerk->Render();

	hud->Update();

	Flip();
}

 

But after reading this, I changed my code to set it to the transparency layer, but that didn't change the reults.

//Main loop 
while(!KeyHit(KEY_ESCAPE) && !AppSuspended())
{
	controls->Update();
	player->Update();
	aiManager->Update();
	world->Update();



	frameWerk->Update();
	frameWerk->Render();


	frameWerk->GetTransparency().SetWorld();
	hud->Update();
	frameWerk->GetMain().SetWorld();


	Flip();
}

 

 

//Hud Code

void HUD::Update()
{
DrawImage(LoadTexture("star.dds"));
}

 

Attached is the image of what settings we are currently using for the creation of the DDS.

 

What am I doing wrong here?

post-26-12720782078136_thumb.jpg

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Hello,

 

well, sorry if i tell something that you allready know, but you have to create an alpha chanel of your image and then FlattenImage. I tell you it because i see in your image the transparent background and when you flatten the image it turns a white background so i assume you not done that. then save it as dds with alphamap and in the "properties" of the dds saving use, in the Image Options, Color Map instead of normal map. (you can create the normal map too but is necessary a color map). sorry again if you know that.

Link to comment
Share on other sites

Hi Shard, given that the alpha in your image is ok the only thing I do differently to you is as follows:

 

pFramewerk->Update();
pFramewerk->Render();

pPlayer->showStats();

SetBlend(BLEND_ALPHA);
DrawImage(hudImage,650,10,140,60); 
SetBlend(0);

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Hello,

 

well, sorry if i tell something that you allready know, but you have to create an alpha chanel of your image and then FlattenImage. I tell you it because i see in your image the transparent background and when you flatten the image it turns a white background so i assume you not done that. then save it as dds with alphamap and in the "properties" of the dds saving use, in the Image Options, Color Map instead of normal map. (you can create the normal map too but is necessary a color map). sorry again if you know that.

 

 

Hi Shard, given that the alpha in your image is ok the only thing I do differently to you is as follows:

 

pFramewerk->Update();
pFramewerk->Render();

pPlayer->showStats();

SetBlend(BLEND_ALPHA);
DrawImage(hudImage,650,10,140,60); 
SetBlend(0);

 

 

After having tried both suggestions, I got the same result. Below is a screencap of the runtime window. The white box should be a blue star.

 

[Edit] I used one of the dds files that came with the engine for the camera node (which wasn't showing up before) and now it is. I believe this is due to the code working, but our star dds still doesn't show with the same code.

 

Also, a quick question about partial alpha. Would that code be able to render partially transparent images, say at 17%?

post-26-12721441964908_thumb.jpg

post-26-12721448967835_thumb.jpg

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Check the generate MIP maps radio button.

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

hi,

 

i'm trying to post you an alpha image that i made to try with Pixel Perfect suggestion but it give me "Error you aren't permited to upload this kind of file" and i don't know why. Anyway when you save your image, look, in image options, if the Pre Modulate Color checkbox is checked and check it if not. Of course the Generate Mip Maps radio button must be checked too as Marleys Ghost says (and flattenimage and all you did before). Then try Pixel Perfect suggestion. I'd like to post you an image but i can't.

 

P.D.: for the 17% try make a shader with alpha test "configuration" and the white part of the alpha channel of the image must be 17% opacity i think, but not sure.

Link to comment
Share on other sites

Thanks Marley and Darth Raff, both your suggestions have made it work perfectly.

post-26-12723222933471_thumb.jpg

simpleSigPNG.png

 

Programmer/Engineer/Student

www.reikumar.com

 

2.6 GHz Intel Core Duo - nVidia GeForce 8600 GT - Windows 7 64-bit - 4 Gigs RAM

C++ - Visual Studio Express - Dark GDK - Leadwerks SDK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...