Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Transparency or Alpha Channel in Animated Texture

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 7th May 2003 05:56
Hi, as far as I know, DBpro only support animated texture via loading an AVI file (or is there any other way?)

How do I create an animated texture for my 3D models that had transparent area (through the use of color keys), or better still, that supports alpha channel (so I can specify the opacity for different part of the texture).

I know I can alternatively load a sets of images and switch the texture at run time. But it is a real pain when comes to tweaking the animation timing, especially when I am dealing with a lot of animated texture.

Ideas, anyone?
Thanks!
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 12th May 2003 14:19
Oh no... I am in grave danger... Nobody really knows how to do this? :-s

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 12th May 2003 15:21
.avi formats are compressed and therefor may loose the transparent colour in the encoding. Making your .avi with full-frames uncompressed codec may allow you to use the standard set object transparency command and use the set image colorkey to specify your transparent area.

However, whenever I use a transparent object in DBPro the texture always looks dirty with spurious black edging as if I loaded the texture without the extra ,1. As far as I can tell this is a bug but I may be wrong.

Pneumatic Dryll
Dr DooMer
23
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 12th May 2003 16:04
Well, it is and it isn't a bug. The area that you colour black, and so want to be transparent, does actually become transparent - no bug there. Also, as you know, textures pixels next to each other are blended together (can't remember technical name) to create a smoother effect when you're up close - no bug there.

It's when the two are combined: the area designated becomes transparent, but it is still included in the blend, so the black area seem to 'bleed' into the opaque area.

And, sorry Bulleyes, but I can't really think of a way to do this, other than use a series of images that are changed by set object texture. Of course, I haven't tried it, so even that might not achieve the transparency you're looking for.

"I am a living, thinking entity who was created in the sea of information."
kevil
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 12th May 2003 16:20
Well, you could use memblocks to set the transparency for different parts. Though I'm not sure what exactly you want to do. Do you want this alpha data to come with the AVI file, or do you want to set it yourself in your program?

Kevil

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 12th May 2003 19:53
Thanks for all the help!

I know I could set the transparency of an animated texture in AVI file using SET IMAGE COLORKEY. But this functions only allows 1-bit transparency, i.e. totally transparent (the colorkey pixels) or totally opaque (non colorkey pixels). This method will cause some jagged edge or "bleeding" as Dr DooMer mentioned it, due the anti-aliasing or the compression of AVI file.

Ideally, what I really need is able to set the alpha value of an animated texture, which currently I have no idea except TEXTURE OBJECT on each frame of the animation, which is kinda tedious for me.

Kevil,
How do you set the transparency for different parts of an image in a memblocks? If I can do this, I think I can think of some way to achieve my goal. Since the command PLAY ANIMATION TO IMAGE will send an animation (in an AVI file) to an image, I might be able to modify the transparency data at runtime.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
kevil
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 12th May 2003 20:18
These are my image manipulate functions:



So if you have an image, you should do:


Where image is the number of your image.
Then you can change the alpha for a pixel using:

Where alpha can reach from 0(totally transparent) to 255(solid).
After you're finished with changing the alpha values you do this:

Then you've done it.

But I don't know how you were planning to know which alpha value each pixel needs, unless you make some sort of opacity AVI, or you do it by color intensity.

Kevil

Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 13th May 2003 05:03
Is the image memblocks always in 32-bit RGBA format, no matter what type of the image, i.e. JPG, TGA, PNG, etc.?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2003 10:32
If your original image is 16 bit, when you transfer that to a memblock, that is also 16 bit.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 13th May 2003 16:27
Thanks IanM! So basically in the memblocks will be the pixel data, or there is still the image header info in it?

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 13th May 2003 16:29
I would prefer the memblock will just contains the pixel data. Otherwise I will need to understand the file format of different file.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th May 2003 20:17
The first 12 bytes cover the following:
Pos 0 = Image Width
Pos 4 = Image Height
Pos 8 = Image Depth

Each of these is a dword.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 14th May 2003 08:05
Thanks IanM! Oh... BTW, how do you know all these stuffs? I mean, how do you know how DBpro represents images, models, etc. in memblocks? Does DBS provide any docs for these?

It will be nice if I know them. So that I can create a specific function to deal with some of the limitations in DBpro. Or even pass the pointer to a DLL to process it.

Thanks again!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2003 20:25
All the formats are in the reference manual - except for the mesh format. I got that one from one of the guys on DBDN.
kevil
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 14th May 2003 20:57
You can read about the mesh format in the commands section under the command "make memblock from mesh". It is explained there.

Kevil

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2003 21:22
Well, almost. It doesn't explain what 'mesh data' is, or how to work out the format.
kevil
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: Netherlands
Posted: 14th May 2003 21:36
Not?

MAKE MEMBLOCK FROM MESH
This command will make a memblock from a mesh. The specified values must be integer values and the
source resource must exist or the command will fail. The mesh memblock is layed out in the following
format. The first DWORD is the FVF Format, which controls which components each vertex of your mesh
will contain. The default FVF Format is 338. The second DWORD is the FVF Size, which is the size in bytes
of a single vertex element. This size is respective of the FVF Format you specified, which has a default of
36. The third DWORD is the number of Vertices in your mesh. The remainder of the memblock contains
mesh data. The mesh data is a sequential list of vertices, containing the component data arranged as
specified by the FVF Format. The default FVF Format would specify the following arrangement of data
within the vertex element, which is duplicated for every vertex specified in the memblock. Each grouping of
three vertices makes a polygon. Given the default FVF Format of 338, the first three FLOAT values (12
bytes) of the vertex element would be the XYZ coordinates in model space. The second three FLOAT
values (12 bytes) of the vertex element would be the normals coordinates in model space. The next
DWORD is a diffuse colour component that specifies the colour of the vertex. The last two FLOATS are UV
texture coordinates for the vertex. This adds up to 36 bytes which is the size of a single vertex. Multiply
36 by the number of vertices in the mesh and you get the overall size of the mesh data.

SYNTAX
MAKE MEMBLOCK FROM MESH Memblock Number,Mesh Number


Enough information for me

Kevil

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th May 2003 21:44
Aha, I usually stick to the paper manual. Looks like I need to browse the IDE help a bit more.

I've been working it out the hard way - but that does mean that I can use other non-default FVF formats too
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 14th May 2003 21:50
Yes I think, there is a CONVERT FVF command, if that is any use.

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_101.zip

Login to post a reply

Server time is: 2026-07-11 12:02:38
Your offset time is: 2026-07-11 12:02:38