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 / Help me with objects with transparent texture please!

Author
Message
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 23rd Oct 2003 11:05
Hello, I need finish my work on my racing game this week and I need help. I placed trees into my level. Trees are made of two planes textured and set cull and trasparent properly. I use BMP texture for tree and image colorkey is 0,0,0 for transparent zones.

Here is my problem :
If whole tree is under horizont all is fine, but if part of tree is above horizont (above matrix) then edges are blue. I think that it is something with aliasing but i don't know. It look like edges are smoothed with background blue color, but I use sky box so I don't know. PLEASE help se someone with this problem.

Pics with problem :
All is under horizont and its OK :


Here is the bug :
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 23rd Oct 2003 12:37
See here: http://www.thegamecreators.com/?m=forum_view&t=16273&b=7

and here: http://www.thegamecreators.com/?m=forum_view&t=16365&b=15

Maybe something there that can help (but I doubt it!)

If your mansion house needs haunting, just call Rentaghost!
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 23rd Oct 2003 13:31
Backdrop off didnt helped.
Set filter set on 0 also didnt helped.

Any other ideas please?
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Oct 2003 15:43
could it be the mipmaps that DB creates? Try setting Mipmapping off to see if it makes a difference. I know this may not be appropriate for your project, but at least you'll know if that is the problem.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 23rd Oct 2003 15:51
OK, i tried make new project and there if I turn off backdrop then all works fine. In main project I also turn off backdrop but it won't work. I think that somewhere is beckdrop turned on again, but I scanned all source files and don't found any backdrop on commands. So is there some other command for turn backdrop on?
zircher
23
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 23rd Oct 2003 16:06
As a causual observation, does this problem only happen if there is no 3D geometry behide the plane? If that is the case, the 'fix' might be to use a sky sphere or box so there is always some background geometry.

I have not personally seen this problem, but then my current project does use a large inverted sphere for a background.
--
TAZ
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 23rd Oct 2003 16:17
I use skybox.
Sam
22
Years of Service
User Offline
Joined: 17th Oct 2003
Location:
Posted: 24th Oct 2003 11:35 Edited at: 24th Oct 2003 11:43
I work for a software company and I sometimes get the same problem when rendering images in OpenGL

The problem is not Darkbasic, the problems is the settings specified during export...

The image bellow is a PSD formatted image, as you may already know, the checker background represents opacity or transparency value...

When I created the circle on the top left, I had "anti-aliased" turned on... This feature will smooth the jagged edges of an object by softening the color transition between edge pixels and background pixels by using alternative levels of opacity as you can seen from the enlarged section of the circle.

When exporting an image to DarkBasic, make sure that you use a adequate format so that the opacity color information is not lost.

An alternative would be to make sure that anti-aliasing is turned off.

If I export this image as a GIF image, the pixels with 25, 50, and 75% Opacity would turn blue, red or any custom background color specified when exporting. This happens because a GIF image only supports solid pixels or 100% opaque pixels. If my circle was a different color and not black, I could choose a black as my custom background color. But if I did here, my circle would also become transparent. I could re-draw my circle with a lighter shade of black.

A BMP image works the same way, you must choose a color as the transparent color or "mask". If the background color specified was a blue, the anti-aliasing would turn that blue into darker shades of blue... The blue background would show transparent in Darkbasic, but the darker shades of blue would not show transparent. So you get a blue border around the image.

Darkbasic supports PNG images, PNG can hold different levels of opacity. As long as Darkbasic can read the PNG correctly, you should not have any problems because not only the blue is specified as a transparent color, but also it's shades of blue from the resulting anti-aliasing.

To save time and headache, I would simply turn anti-aliasing off when creating transparent backgrounds and if possible, choose the darkest color for the transparency. Also, exporting as a transparent PNG image is probably your best option.

Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 12:05
I don't think that it is the problem, because if I turn off backdrop then texture is drawed fine. Also If is some object after my object then all is displayed fine. I know about antialiasing when drawing transparent textures. Problem is in DBP.

--------
Beavis
http://www.progress-studio.com
Sam
22
Years of Service
User Offline
Joined: 17th Oct 2003
Location:
Posted: 24th Oct 2003 12:38
Beavis, would that create a small black line around the image? My image had a small black line around it... I was only able to get that line to go away by turning anti-alising off, or exporting it to PNG.
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 12:59
No, I don't have black line around image. Look at second picture and you'l see my problem. Blue border but only above horizont. If I turn off backdrop then all is fine, but in my main project I can't turn off backdrop and I don't know why.

--------
Beavis
http://www.progress-studio.com
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2003 13:05
Beavis is right - the problem is that db is smoothing the edges of the trees to the colour of the backdrop when it should be smoothing to whatever is in background. Change backdrop to red and you get a red outline. Make it black and you get a black outline.

You can turn off filtering for the trees and problem goes away completely because no smoothing occurs but this makes trees look very pixelly when close up.

If your mansion house needs haunting, just call Rentaghost!
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 14:10
And how can I turn off smoothing? I used
SET FILTER object_id, 0
but it doesn't helped me

--------
Beavis
http://www.progress-studio.com
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Oct 2003 14:14
SET OBJECT FILTER Obj,1

If that does nothing, try 0 instead, should work without any problems, although you should disable mipmapping too.

I made a little function to setup an object to use transparent textures nicely, I'll post it tonight.


Van-B

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Oct 2003 14:15
Game looks amazing BTW.


Van-B

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2003 14:52
Found the answer! (I think). Convert your trees from bmp to png format and problem goes away and edges of leaves on trees fade nicely into the background. png supports multiple transparency layers and it appears db uses them really well.

If your mansion house needs haunting, just call Rentaghost!
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 15:06
I tried SET OBJECT FILTER obj,0 and also 1 but didn't work. How to turn off mipmapping?

--------
Beavis
http://www.progress-studio.com
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 15:08
OH, so Sam was right? I try it now. Thanks

--------
Beavis
http://www.progress-studio.com
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2003 15:27
Forget that - I've REALLY found the answer!!!!!!!!

It's all to do with the image number that you texture your sky and trees with.

The image number you texture your sky with must be LESS THAN the image number you texture your trees with.

Just tried it in my game and everything now perfect. No blue border and lovely smoothing.



If your mansion house needs haunting, just call Rentaghost!
Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 15:44
PNG doesn't helped me
I don't know if I have good texture. Can someone send me PGN texture please?

--------
Beavis
http://www.progress-studio.com
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Oct 2003 16:00
Try disabling mipmapping to, I think it's SET OBJECT TEXTURE obj,0,0 - check the help and experiment though, you'll get it sorted I'm sure.


Van-B

Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 16:15
Thank you Van B ! It really helped me. It was last problem I had with my project.

--------
Beavis
http://www.progress-studio.com
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Oct 2003 16:22
Actually you should thank Batvink 'cos he mentioned it first, but it's cool to see your back on track (no pun intended).


Van-B

Beavis
23
Years of Service
User Offline
Joined: 15th May 2003
Location: Czech Republic
Posted: 24th Oct 2003 16:27
Yes I thank Batvink too. I didnt know how to turn off mimpapping in DBP.

--------
Beavis
http://www.progress-studio.com
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 24th Oct 2003 16:52
Just in case you were interested, I have posted new bug report that explains my theory about image number causing bug (with proof).

It also allows mipmapping back on. May not be such a problem for you as trees will never be close enough to worry about what they look like.

At least you have got me to sort out my blue edge probs for my game!

http://www.thegamecreators.com/?m=forum_view&t=18984&b=15

If your mansion house needs haunting, just call Rentaghost!

Login to post a reply

Server time is: 2026-07-26 17:35:48
Your offset time is: 2026-07-26 17:35:48