Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Leaf Bug  (Read 12203 times)

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Leaf Bug
« on: June 18, 2003, 03:00:00 pm »

So, I just updated to Windows XP.  At first, the leaves displayed fine.  This was before I updated my video drivers.  Things were going slow, but there were leaves.  Then I updated the drivers.  The game ran faster than ever, but no leaves.

That's kind of weird.  Anyway, it seems like a driver issue, but now I'll just try to come up with a work-around.  It is easier for me to test now, because I feel your pain.

[ June 18, 2003: Message edited by: Toady One ]

Logged
The Toad, a Natural Resource:  Preserve yours today!

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Leaf Bug
« Reply #1 on: June 18, 2003, 03:15:00 pm »

It has to do with alpha blending (transparency).  So the leaves are mostly empty space, and you want the sky to shine through etc.  When I got rid of that part of the code, the leaves display.  But there's no sky shining through.  Like this:

The reddish part should actually be transparent.  All I have to do is figure that out.  It should be done today.  I still don't have any ideas on the text display bug...  I'll have to look at it more.

Logged
The Toad, a Natural Resource:  Preserve yours today!

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Leaf Bug
« Reply #2 on: June 18, 2003, 06:29:00 pm »

I fixed the leaf bug.  It seems that alpha testing is broken on new systems.  My test was "alpha not equal to zero" to print a pixel.  So I set the alpha byte equal to one for the parts I wanted to print, and it worked on the old OS.  Now, I have to set the alpha byte to 127+ to satisfy the test.  Keep in mind the test is "alpha not equal to zero".  One is not equal to zero.  Apparently, in the modern world of Windows XP, one IS equal to zero, but 127 and 255 aren't.  Anyway, it works now.

MATH CORNER:  If one is equal to zero, then by adding 126 ones to both sides, you get that 127 is also equal to zero.  Therefore, Windows XP is behaving inconsistently (or alpha testing is not a homomorphism on the additive group of integers, I guess).

[ June 18, 2003: Message edited by: Toady One ]

Logged
The Toad, a Natural Resource:  Preserve yours today!

Harlander

  • Bay Watcher
    • View Profile
Re: Leaf Bug
« Reply #3 on: June 27, 2003, 08:52:00 am »

Did you say you'd fixed it?

I get red-outlined leaves now, as in that screenshot.. I used to have normal leaves, but I'm pretty sure I updated to the newest directX since I last tried it.. I'll try and dig out an older version and see if leaves appear there..

Nope, they don't. So it's probably a drivers thing. Curse you, drivers... cuuuuuuurrrse youuuu!

Aside from that, the new version looks pretty interesting ... blowing things up and melting trees into piles of boiling sap is fun... and the blood transparency actually looks quite nice

[ June 27, 2003: Message edited by: Harlander ]

Logged

Demon

  • Bay Watcher
  • From a time before a time before time
    • View Profile
Re: Leaf Bug
« Reply #4 on: June 27, 2003, 11:37:00 am »

"MATH CORNER: If one is equal to zero, then by adding 126 ones to both sides, you get that 127 is also equal to zero. Therefore, Windows XP is behaving inconsistently (or alpha testing is not a homomorphism on the additive group of integers, I guess)."

Perhaps I'm just old fashioned...  but I thought 126+0=126.  Perhaps you meant mutiplying both sides by 127 you could show 127=0.  Or you could use the transitive property to show 0=127 by adding 1's.  0=1, 1=2, 2=3, 0=127.  

Demon: proving Pennsylvania is better at math since 2002.

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Leaf Bug
« Reply #5 on: June 27, 2003, 12:51:00 pm »

I meant what I wrote.  If 1=0, then you can treat the ones you add to the left side as 1's, and the ones you add to the right side as 0's.  Like, 1=0 ~> 1+1=0+1 ~> 1+1=0+0 ~> 2=0.  And so on, until you get to 127=0.  WEST SIDE FOREVER!  Don't make me change the time back.

Harlander, could the red outline be the branches?  They are reddish on the pre-release.  I made them more brown for the final version.  To make the leaf texture for trees, it draws some branches and then sprinkles leaves on it.  If the branches are red and thick, a lot of your leaves will be red-outlined.  You can send me a screen shot if you want.  It might not actually be a problem.  If any of the leaves aren't red-outlined, it's probably all right.  I just put R=100 instead of R=70 by accident.  What I should be doing is using the color from the material file...  but of course I haven't done that yet.

Logged
The Toad, a Natural Resource:  Preserve yours today!

Harlander

  • Bay Watcher
    • View Profile
Re: Leaf Bug
« Reply #6 on: July 07, 2003, 06:16:00 pm »

It's not easy to get a good shot.. but in this one you can see the solid brown branches, and the brown outline of the green leaves. It's really only a minor cosmetic thing

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Leaf Bug
« Reply #7 on: July 07, 2003, 08:03:00 pm »

All right, yeah.  I think I figured that out.  First, red was just an accident.  I typed the color wrong.  So pretend it's brown.  The outline around the leaves is still ugly.

The problem was that when it blended the texture, even though the pixels surrounding the leaves are invisible (alpha=0), they are still brown (r=70, g=30, b=10), so it blended the noninvisible leaf pixels with brown around the edges.  I made the invisible parts black, so now when it blends the leaves, they have black outlines.

The reason the invisible parts where brown to begin with is that when I did the random walk on the texture to make the little branches, I just changed the alpha bit...  uh...  I don't want to blow my Dr. Pepper high explaining when I could be doing area effect body detonation spells, so anyway it looks like this now:

The black outlines could be changed to fading to transparency, or it could be given sharp outlines but at the cost of heavy pixelation from no blending.  Actually, I could make the transparent pixels green if they are near leaves, and black/brown if they are near branch pixels...  that might look best.

Logged
The Toad, a Natural Resource:  Preserve yours today!