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 bug?

Author
Message
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Oct 2014 03:41
I do not know for what reason but in some objects when i apply a transparent texture (black color with rgb(0,0,0) hidden), there are blue borders around where the transparency start, how can i fix this?

I tried both with png and bmp textures
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 27th Oct 2014 05:21 Edited at: 27th Oct 2014 05:21
seems i have been able to fix it by turning backdrop off.
But i still have a transparency bug, similar to it for the flowers made with plantlife of darkbasic, i have the problem also with the trees made with treemagic of darkbasic, the artifact is visible only when the camera point to the water, here a screenshot

Attachments

Login to view attachments
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 27th Oct 2014 11:57
The problem is that they are being rendered in the wrong order such that the backdrop is "drawn" first, then your transparent objects so that their edges are blended with the backdrop, and only then are the objects behind the transparent ones drawn. This means they will not blend properly with the transparent ones and you'll get those ugly outlines.

Unfortunatelt there isn't much that can be done about this in DBPro without restructuring its drawing orders and recompiling it. Even so there are situations where this cannot really be avoided, short of storing data for several "depth pixels" and then blending those as a post process, such as when two transparent objects are overlapping such that one of them stretches both in front and in back of the other.
One simple solution that is often used with foliage like you have in your image is to use alpha testing instead of alpha blending. This basically means that you either draw a pixel or not; this will result in hard, pixelated edges but you won't get any borders. It is also possible to draw the foliage in a separate render pass like that and then blend it in with the rest of the scene with some blurring post-processing; this will ease up on the hard edges.

In order to do alpha testing you'll have to write your own shader where you simply set the output alpha value from the pixel shader to 1 if the sampled alpha value is above some arbitrary threshold such as 0.5, and to 0 otherwise. In this way the draw order doesn't matter since pixel data with a lower depth value will always simply overwrite any previous pixel at the given position.

Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 28th Oct 2014 01:58
There must be something wrong with the shaders you're using. I've never seen DBPro render transparent objects in the wrong order before, and it looks to me like the grass is only affected by the problem when the water is visible behind it.

Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Oct 2014 02:32
yes i said before it only happens when i look at the water and have these flowers between water and camera, i am using the water shader of evolved (not the advanced lighting one, the normal one)
MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th Oct 2014 03:33 Edited at: 28th Oct 2014 03:41
What on earth are people talking about?

SET OBJECT TRANSPARENCY OBJnum, Flag

EDIT

Saw the image...



Hmm Staying quiet now

Is that a cut-out or your actual screen resolution?

I recall one of the flags on the above command being a draw order flag... try from 0-20 not sure how far above 5-6 it goes... if at all

EDIT



Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 28th Oct 2014 03:42
Quote: "I recall one of the flags on the above command being a draw order flag... try from 0-20 not sure how far above 5-6 it goes... if at all"


You could certainly try with the various flags with set object transparency, maybe one will work, but AFAICT it's purely a shader incompatibility. Still, if you haven't already, you should definitely try all the flags.

MrValentine
AGK Backer
14
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th Oct 2014 03:49
Clonkex see edit code block above

Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Oct 2014 04:03
I think the image is 1024*1024 but i was running 1024*768, fps is limited to 50 by sync rate 50.

Tomorrow i will try the set object transparency thing, i think flags are from 1 to 6?
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Oct 2014 04:36 Edited at: 28th Oct 2014 04:51
Made a test, the blue borders are fixed only with transparency set to 4 or 6, BUT, doing that the flowers will gradually disappear getting far from them, which is even worse than having the blue borders bug.

Edit:

Tried now to disable mipmap, fix the issue, but it looks awful, better keep the blu borders bug for the moment, it s the "best looking option" so far
wattywatts
15
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 28th Oct 2014 04:50
Quote: "AFAICT it's purely a shader incompatibility."

I'm going with this. It happens sometimes, then you need to find alternate ways of doing one thing or the other. You could make your own water with a scrolling texture and some effects, or you could try changing the transparent parts to black and using ghost object..
Ah, the joys of programming, right?
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Oct 2014 04:54 Edited at: 28th Oct 2014 05:17
wattywatts, way better keep the blue border bug which is barely visible (is visible only from very few angles, like the screenshot) than remove the good water shader which is awesome (almost actually) and make a crappy scrolling water texture, i have that option when setting water detail on low, for slow computers, no way you can compare it to the water shader effect
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Oct 2014 19:37 Edited at: 28th Oct 2014 19:40
Quote: "There must be something wrong with the shaders you're using. I've never seen DBPro render transparent objects in the wrong order before, and it looks to me like the grass is only affected by the problem when the water is visible behind it."

It will if it is impossible to compute the "correct" order such as when transparent objects overlap along the camera's Z-axis.
The water effect most likely uses a transparent object, thus it is sorted in with the flowers. But the water plane is large, it's center point is compared to the center point of the flowers when determining sorting order and as such the water object is drawn after the flowers (its center point is behind the camera), which results in those being blended with whatever was drawn before them (which is this case seems to be the backdrop clear colour, indicating that the skybox isn't drawn first either, which in turn must either mean that the skybox is set to be transparent (which makes no sense) or DBPro doesn't discern between transparent and opaque objects when sorting).
Or that is my interpretation of the problem at least, of course I could be wrong.

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Oct 2014 20:13 Edited at: 28th Oct 2014 20:15
Try set object transparency obj, 4. If 4 doesn't work try 2, I forget.

I like offending people. People who get offended should be offended. -- Linus Torvalds
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 28th Oct 2014 20:55
TheComent did you read what i wrote?

I have already tried that command, fix the transparency but the flowers disappear progressively with the distance, to fix that i have also tried to disable mipmap, that fix the problem but looks VERY bad, so seems that fixing a thing i broke another even worse.
For the moment keeping that blue borders bug is the best looking solution so far, as disappear flowers with distance it s just crazy, and disabling mipmap to fix that makes the flowers REALLY bad looking, so for the moment i will stick with the original setup
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Oct 2014 01:05 Edited at: 29th Oct 2014 01:06
You might be interested in this. I had the exact same issues as you did: link.

Try using set object transparency obj, 4 and disable object zwrite obj. It has been mentioned that the drawing order is the order in which the images are loaded. It's also been suggested to try using transparency mode 6 instead of 4 for foliage.

As to things disappearing in the distance, anisotropic filtering is the solution to that.
http://forum.thegamecreators.com/?m=forum_view&t=159383&b=5

I like offending people. People who get offended should be offended. -- Linus Torvalds
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 29th Oct 2014 03:06
Sorry but this didn t fix anything, i still have the disappearing problem with the distance even with anisotropic filter on, also they say anisotropic filter is not that heavy but it kills my fps enough (on worst angle where i have lower fps, it drops from 46 down to 27 using anisotropic filter 16x just on 2 objects)
Clonkex
Forum Vice President
14
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 29th Oct 2014 05:35
Quote: "But the water plane is large, it's center point is compared to the center point of the flowers when determining sorting order and as such the water object is drawn after the flowers (its center point is behind the camera)"


Hmm... based on this concept, what you could TRY doing is moving the water plane a long way into the distance (say, +1000 on the X axis) as long as it's big enough. If the plane isn't big enough, make it bigger. The idea being to move the centre of the water out from underneath the island so it always renders behind the plants.

I've probably not thought this through, though.

Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 29th Oct 2014 06:47 Edited at: 29th Oct 2014 06:50
I don't think that is the problem:

- The flowers cover an area going from x= -6000 up to x= 6000 and z= -6000 up to z= 6000 (not the Whole area but some here and some there), all at y= 100

- The water plane is very huge and positioned at -200000,-10,-190000
tuan anh
10
Years of Service
User Offline
Joined: 29th Oct 2014
Location:
Posted: 29th Oct 2014 08:16
There must be something wrong with the shaders you are using
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 29th Oct 2014 08:38
I wonder why the plants don't disappear when you haven't set a transparency mode.

I like offending people. People who get offended should be offended. -- Linus Torvalds
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Oct 2014 13:09
The disappearing issue is probably a mipmap problem since the transparent parts of the textures get averaged with the non-transparent parts which can make the whole image look transparent at higher mipmap levels.

You might be able to stop that by turning off mipmapping - but that will probably lead to other issues. Another solution which I believe Evolved uses in his images is to modify the rgb colour component of the transparent pixels. I'm not sure of the precise details but I know it works with his shaders.



Powered by Free Banners

Login to post a reply

Server time is: 2025-05-13 13:36:24
Your offset time is: 2025-05-13 13:36:24