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 / Memblock Image Alpha problem , pls help.

Author
Message
haliop
User Banned
Posted: 22nd May 2010 16:29
im using Van B method for manipulating images or textures as you like , using memblock in DarkGDK , but since DarkGDK has much lower amount of members im asking some questions here , i hope no one mind. the code is similar to DBP and i translated what Van B wrote to Dgdk.

my question is , how do i write to the alpha channel?
i know its pos+3 , but no matter if its 0 or 255 the results are the same ,
the results are shown on a Plain Object textured by the Memblock Image manipulation.





ty for your time.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd May 2010 16:54
Looks about right to me. Only the "res" part looks a bit weird to me.
Quote: "x=res-x;"

and
Quote: "if (x>=res || y>=res) return;"

I'm assuming it's some kind of width and height at the same time.

Are you sure you're pasting the image to the screen with transparency enabled? If you're using it as a texture make sure transparency is enabled for that object too.

Cheers!
Sven B

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 22nd May 2010 17:14

^^much easier to read, and makes no difference to the writing of the actual image.



I've had this same problem you're having, and it turns out that the problemw as that I was using paste image. When you want transparency, do not use paste image, use sprite, or use texture object with the correct flag.

using set object transparency with a flag of 2 or 3 should work fine.


Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd May 2010 17:46
Quote: "When you want transparency, do not use paste image, use sprite, or use texture object with the correct flag."


paste image also has this flag. ^^
paste image 1, 0, 0, 1

Cheers!
Sven B

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 22nd May 2010 18:55
I thought that only worked for alpha masking (errm, maybe that's not the correct term, but the one where only one specific color isn't drawn at all)

brb testing stuff


haliop
User Banned
Posted: 22nd May 2010 19:11
ok thank you so much for your quick response, i will check it now.
haliop
User Banned
Posted: 22nd May 2010 19:17
dudes! you are totlay awesome!
ty so much.

however a question comes to mind.
whats the diffrence between the flags? ive searched in the Refrence Doc but nothing there.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd May 2010 22:31
Quote: "I thought that only worked for alpha masking (errm, maybe that's not the correct term, but the one where only one specific color isn't drawn at all)"


The colorkey is used for images without an alpha channel

From the help files:
SET IMAGE COLORKEY Red Value, Green Value, Blue Value
A colorkey allows you to specify a particular RGB colour that will be treated as transparent by the image when used. Transparent pixels of an image are not drawn. You must use this command before loading or grabbing an image in order that a suitable alpha map be generated from the transparent pixels of the desired image to be calculated. The alpha map is then used to decide which pixels are drawn and which pixels are never rendered. Be aware that setting the color key for the purpose of transparency will not work on images based on the PNG, TGA and DDS file format as these carry their own alpha channel and describe their own pattern of transparency.

Quote: "whats the diffrence between the flags? ive searched in the Refrence Doc but nothing there."


For paste image, there are only 2 flags: 0 (no transparency) or 1 (transparency).

For an object, there are multiple flags available:
SET OBJECT TRANSPARENCY Object Number, Flag
The transparent colour is determined by the SET IMAGE COLORKEY command or the alpha channel of the texture. The transparency modes are used to control when and how the object is drawn into the scene, and are described below. Special consideration should be used with the depth sort system, which takes the coordinate of the object and camera and depth sorts based on the distance between these points. You can inadvertantly create a situation where a large object behind a small object would have a shorter distance, and be rendered last instead of first.

0 - draw first no alpha
1 - draw first with alpha masking
2 and 3 - draw second which overlaps solid geometry
4 - draw second alpha test (only render beyond 0x000000CF alpha values)
5 - water line object (seperates depth sort automatically)
6 - combination of 3 and 4 (second phase render with alpha blend AND alpha test, used for fading LOD leaves)

Cheers!
Sven B

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 22nd May 2010 23:44
Quote: "
0 - draw first no alpha
1 - draw first with alpha masking
2 and 3 - draw second which overlaps solid geometry
4 - draw second alpha test (only render beyond 0x000000CF alpha values)
5 - water line object (seperates depth sort automatically)
6 - combination of 3 and 4 (second phase render with alpha blend AND alpha test, used for fading LOD leaves)"

actually... I'm curious too as to what those actually mean.


Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd May 2010 00:42
Quote: "actually... I'm curious too as to what those actually mean."


Frankly I'm not quite sure myself. I have seen many people just trying all transparency flags and picking the one that gives the best result. I do it too ^^

Greets,
Sven

haliop
User Banned
Posted: 23rd May 2010 07:48
cool thanx.

Login to post a reply

Server time is: 2026-07-25 16:19:25
Your offset time is: 2026-07-25 16:19:25