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 mode issues with foliage

Author
Message
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Jun 2012 14:19
I believe I've seen posts about similar topics in the past, but I haven't been able to locate any of them, so I'll post this here. If you know of any previous post that has treated this, please link it out for me

So I'm having alpha transparency issues with foliage models. Basically setting a transparency mode of 1 through 3 or 5 all seems to give the following identical result:

The problem of course being the white borders around the edges (and for this particular type of textue, the holes as well).

Setting the transparency mode to either 4 or 6 generates the following result:

As one can see, the white borders are gone, but now the edges near the transparent areas seem to be blurred, something that is especially evident with the stems that doesn't look well at all.

I would like to think it's an issue with the texture, but it works as intended with various other 3d software so I'm not too sure about that. Do anybody have any ideas about what one can do to alleviate these type of problems?

Thanks in advance,
Rudolpho


"Why do programmers get Halloween and Christmas mixed up?"
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Jun 2012 15:23
Try PNG with Alpha transparency. It works better.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 25th Jun 2012 16:00
That screenshot was taken using a tga texture with an explicit alpha channel (attached).

A PNG gives roughly the same results.


"Why do programmers get Halloween and Christmas mixed up?"
Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 25th Jun 2012 16:34
I get the same problem too.
I find that using transparency mode 6 along with an earth/grass texture on the
ground plane beneath the plant will get the plants looking ok.

Sometimes I like to use words out of contents
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 25th Jun 2012 16:56 Edited at: 25th Jun 2012 16:59
Mine all work. I don't know what the difference is. Try putting..

Load Image "Whatever.tga",1,1 (extra ,1)

But if you have transparency I don't see how you would get a white outline anyway.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jun 2012 20:25
I think turning off mipmapping might help. Have a look at set object texture. You may have to experiment a bit since the Help file is garbled.
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 25th Jun 2012 23:03
I think it's a draw order problem, and not a transparency issue. Try changing the backdrop colour to something more distinct. If the border colour around the leaves is the same colour as the backdrop, it's a draw order issue.

If that's the case, DBP is detecting the origin of the plant objects is further away from the camera than the origin of the white grid object the plants are on. It is therefore drawing it first. This means the alpha channel around the leaves is blending with the backdrop colour. The grid is then rendered next, and since it is behind the leaves, it isn't drawn at all where the blended edge pixels are, and you therefore get your outline.

What you need to do is get DBP to draw the grid first and the plants next. Since we don't have a lot of control over draw order in DBP (I never got the Z Bias command to work), you can use a trick I have used before. Offset the base limb of the ground object so it is really high (e.g. OFFSET LIMB groundObject, 0, 0, 100, 0). Then position the ground object at the correct height again (now at 0,-100,0). By doing this, DBP will detect the ground object's origin is at -100 on the y, assume it is further away and draw it first. The leaves will then be drawn afterwards and will blend with the ground image.

Obviously, this only works in the camera is above the ground, but it should work for most circumstances.

Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 26th Jun 2012 00:45
sweet fallout! I'm gonna use that. thanks for sharing.

Sometimes I like to use words out of contents
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 26th Jun 2012 23:09
Waterline Objects - Hair and Foliage

I have problems like this using transparency+hair and water. When the characters head is below water and the camera is still above, hair sometimes disappears or is partially clipped.

I Think I'll have to switch to higher poly count, non transparency hair.





It gets kinda rough trying to sort out the Z Order when water and hair are in part overlapping each other at the same time.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Jun 2012 23:11 Edited at: 26th Jun 2012 23:12
Swap the hair for dark hair, because wet hair is dark anyway, so it will look like you meant to do it.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 26th Jun 2012 23:34 Edited at: 26th Jun 2012 23:39
Quote: "Swap the hair for dark hair, because wet hair is dark anyway, so it will look like you meant to do it."


lol That won't help at all. It's a transparency Z-Order issue. I need per pixel ordering not per object ordering. Also, not that it matters the hair is Jet-Black anyway.
Did you see the screenshots I posted above?

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Jun 2012 02:10
No, I mean dark hair with no transparency. A hair model. The transparency that you use is to fade it out. Dark, wet hair is bunched up, so it doesn't need to fade out.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Jun 2012 12:57
@Fallout: yes, that seems like it might be the issue.
Unfortunately your solution had no effect on my end though :/

I eventually managed to get it working decently (still not perfect, but assuming the player won't crawl around and look underneath the shrubbage it should be good enough ) using GG's idea along with transparency mode 6; the deactivation of mip-maps seem to be the main way to keep the few-pixel stems visible at distances. Kind of makes sense when you think about it


"Why do programmers get Halloween and Christmas mixed up?"
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 28th Jun 2012 13:19
Out of interest, what do you load first? The ground or the plants? The object ID also makes a difference to draw order. If you load your plants with a lower object ID, they'll probably be drawn first. In my game, I was having z issues with particles, but by loading them with higher object IDs than the objects that were overlapping them, I sorted my issues out.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Jun 2012 15:16
Tried setting the plants to object id's > 10000 while the grid was id 1; still no change when using transparency mode 1 I'm afraid.


"Why do programmers get Halloween and Christmas mixed up?"
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Jun 2012 15:29
According to the Help file mode 1 draws first which definitely isn't what you want. I find it hard to think of a case where you would want to draw transparent objects first. Perhaps the Help file isn't being clear?
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 28th Jun 2012 16:11 Edited at: 28th Jun 2012 16:14
I usually use mode 2. But the picture looks more like it has no alpha working. It looks like the plants have a white background. In Photoshop I make 2 layers, and I click the eye on the background layer. That makes it vanish.

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 28th Jun 2012 16:13
Quote: "According to the Help file mode 1 draws first which definitely isn't what you want. I find it hard to think of a case where you would want to draw transparent objects first. Perhaps the Help file isn't being clear?"


Hmmm. I suppose overlapping sky related objects could be drawn first (clouds). Can't think of anything else.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 28th Jun 2012 16:18
As said, mode 6 (or 4, which seem to preserve the edges to a slightly better degree) works well enough for me.

As for all other modes they give identical results in this particular case (that being said they probably don't always) and so I assumed Fallout was talking about one of these modes (since they're the only ones that get part of the background colour baked in around the edges).

If you think it might matter, I should perhaps mention that all the plants are instanced from a single hidden object.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2026-07-08 05:38:58
Your offset time is: 2026-07-08 05:38:58