Reapplying the Decal: Part 2

Well, yesterdays article seems to have gone down quite well. So, as promised, here’s part 2, wherein colour keying is restored, code is demonstrated, and more screenshots are taken! Before continuing, I’ll ask those of you who didn’t read yesterday’s instalment to head on over. Go on – we’ll wait.

Sigh. OK, for those of you who didn’t bother, here’s a summary anyway.

Last time, on Decal Trek: The Next Implementation, we had just finished recreating suitable objects that will allow us draw onto the screen again. We’d tested our new objects, found some problems, and experimented with solutions to them. Eventually, we decided to cajole the old objects into accepting us. When we left off, we’d basically got everything work, except the colour keying.

The best way to solve a problem is to not have that problem at all. So, the first question is “why do we need colour keying at all”? Well, let’s explain how Decal puts things together – most UI rendering systems work in this way, so this is a N for the price of 1 education (with large N)!

The UI system is made up of lots of different components. Buttons, text boxes, check controls and others. These are all individual objects. Lets have a look at them, in an idealised form, one at a time.

Single controls example

Very nice. 3 controls all rendered onto a piece of paper, one at a time. This is pretty much how Decal works – we have lots of controls, and they’re drawn onto the “paper” of your AC window. But, Decal doesn’t look like a lot of controls all floating around on their own. The controls are organised into groups. Lets do that – put our controls onto our tab page, just like in game.

Controls without a colour key

Hmm. Not bad. As we can see, the button control works fantastically – it blends in perfectly. This is an artefact of the way the drawing works – it only deals with copying rectangles around. There is no other reasonable way. Computers like squares, everything can always be contained within a square, and it’s bloody hard to find the shape of some text saying “Hello”! So, we draw squares round everything, cut them out, and stick them onto the tab box.

So, as the button control is a square, we could cut it out perfectly. However, the checkbox isn’t quite a square – it’s a circle and some text. When we cut it out and drew it into the tab box, the background came with it, and gave us that nasty white box. So, let’s make white the colour key. When we copy over the rectangle, we’ll copy over every bit of the colour except when it’s white.

Controls with a colour key

Great! We didn’t bring the white with us, and because none of the control actually used white, it looks fine. Colour keys to the rescue! I hope this demonstrates their idea, need and functioning, so here’s a bonus question for astute readers: What has become common since DirectX 6 that means DirectX 9 doesn’t need good colour key support?

Having established the need for colour keys, let’s work out how to implement them in Decal again. We know we have our Decal image that we need to draw. As explained above, this image is put together out of lots of little images (the control objects) – this is called “composition”. We need to get colour keys working again for this composition phase.

Our main task yesterday reopened a route that allows us to use some of the old techniques that were locked off to us. We can now ask each object for a “DC” – a special object that the old fashioned drawing code uses. Because we can now get this DC, we can use some functions Microsoft provided in Windows that will largely do the colour keying for us. So, let’s change our drawing objects to use this DC during composition.

[Sound of keyboard]

Great! It seems to work! Except…oh dear. Once again, the ugly head of performance has been raised. It’s not as bad as yesterday, but it still gives a bit of problem, especially for old computers. As many AC players are still on older machines, we’re going to have to look at this. Wouldn’t life be so much easier if everyone upgraded his or her machines bi-monthly like us developers?

Taking stock (programming involves a lot of stopping and thinking to make sure one’s taking the right road), we remember that the objects we used yesterday were drawing at a nice speed. Our new DC rendering is somewhat slow. We read over our results, and look at our image.

Decal renderer without a colour key

Hmmm. There isn’t really a lot of the colour key present. This suggests that, perhaps, the colour key isn’t used everywhere. In fact, all the controls that are square don’t seem to use it at all! What if, instead of using our new, perfect, drawing object everywhere, we could sometimes the old, imperfect but fast one?

[Sound of keyboard]

Done! The drawing object can now choose which method it uses. That’s a good start – but the drawing object is concerned only with drawing. We’ll have to tell it what to use, and when. So, we’ll update all the image drawing, and some of the composition code, to only use the slow colour key method when it’s strictly necessary. We’ll analyse each image when it’s loaded to see if it needs a colour key, and configure the compositor never to use the colour key on the final phase (when it’s not needed). Bonus question 2: Can you tell me why the final phase, which draws the plugin window and the control bar, doesn’t need to use the colour key drawing object?

Superb – the colour key rendering is only performed when required now! We’re done. Let’s look at the results.

Decal renderer, finished

That looks pretty damn good, and whilst not quite as fast as the old Decal, is fast enough for now. Code wise, today’s changes are longer than yesterday – this is often the way with programming. We got 99% of the way there with 2 lines, then it took dozens to get the last 1%. In fact, writing it took 2 passes – one to test the idea, which produced functional, but messy code. Messy code will make it hard for the next person to get anywhere, so it was rewritten to be neater and more flexible for future users. For those interested in what the actual programming looks like, you can see changes I made in this file.

This concludes this short article pair on fixing the renderer. If people find these interesting, I can certainly write up some more on other parts of the system. Throw me some ideas, and I’ll try and respond.

Adam Wright (as Asriel)

36 Responses to “Reapplying the Decal: Part 2”

  1. W-O-L-F says:

    Very nicely done Asriel!

  2. Tofino says:

    >MessageBox( 0, “WHO IS CALLING ME?”, “DownMixRGB: I’m DEPRECATED FOO!”, MB_OK );

    Had a message like this that I wrote in a sales app a couple of years ago pop up over the weekend. Hilarity ensued. :)

    Good series.

  3. Bowdiddly says:

    Very nice, I for one would love updates like this all the time, but it is your work…hehe.

    Thank you!

  4. Enolive says:

    Again, thanks.

    How about the business with obtaining the memlocs and assigning them to names/funcions? E.g., how/why it took so long obtaining all of the memlocs and then discovering what exactly those memlocs were doing so that you could assign it to a value/name/function.

    Very good and understandable writing style, btw.

  5. Marlio says:

    Thanks Adam, for giving us an overview of the FINE WORK you guys are doing on Decal, and for FinaLLY giving us an update on what is going on…We have felt like we were in the dark for a long time and appreciate the article about Decal, and all the time and effort you are putting into this fabulous program…YOu guys are obviously very talented and I dont have a clue about programming, but it seems to be somewhat complicated. Keep up the fine work, and I hope we have Decal back soon….I miss it!!!! Bahhhhh

  6. John says:

    Very good explanation, lots of facts, how things work, etc.

    I wish this was required reading BEFORE posting on the IGN AC Utilities board.

  7. Kuma says:

    Great read. I’d love to read as much as your willing to write on how decal works.

  8. Brave Eowyn says:

    Thank you Adam. I know everyone in my guild has missed decal. I really feel you are making all of us a part of your process by allowing us to understand the trials and tribulations you are encountering in recreating Decal.

    Thank you for your hard efforts from everyone that is true and Brave!

  9. Cd Locke says:

    very nicely done!! I would like to add that being disabled or having carply tunnel
    makes it rather hard to play ac without plug ins. I have it in both my wrist and need
    surgery really bad. I have to say that todays post is wonderful. It gives me a better
    understanding of programing which is where I stopped in my computer skills when I became
    disabled with my back and started playing during my recovery. I for one was not much on
    macro’s acmer’s and for sure even today I dispise ucmers. I’ve only been using Decal for
    about two years and still my main toon has not hit 90.

    I played ac the other day for a few hours and now its been twos since I’ve played my arms
    just can’t do all the moving around the key board as they once did.

    Last but least keep up the good work as I see you all are slowly getting there.

    My I sugest a link to the area on the Decal page so others can find it. Had I not been scrolling the boards looking to see what was going on I would have never found it.

    Again Thank you for you hard work.

    Locke

  10. Sweet Mary says:

    Destructive Energy Corrupting Asheron’s Land (D.E.C.A.L)

    Once upon a time, the people of Dereth, beckoned by my father Asheron, learned to use mana, an energy that is part of everything, to defend themselves against the creatures threatening their lives. Through much research it was found that certain combinations of plants and elements could be used to focus the mana flow and create protective spells, and skill enhancing spells. Masters of magic were even able to produce offensive spells. Asheron’s people gained experience through much hard work and with the aid of practiced skill with mana. Harnessing the mana made them able to survive against great threats such as the evasion of the Shadows and BZ.

    Later on, some ambitious and somewhat mis-guided Derithians discovered that the mana flow is made up of both positive and negative (or dark) energy. They found ways to harness (or hack) the dark energy and produce various hypnotic spells. Using these hypnotic spells, they found they could induce themselves into performing repetitive or tedious tasks while in a mind numbed trance, thereby completing the task while the mind rested in an unconscious state.

    Some Derethians hailed these hypnotic spells as wondrous and set out to use them to do useful things such as prepare themselves for battle. However many other Derethians warned that the use of hypnotic spells was very dangerous. They warned that use of them would weaken our warriors by removing real experience and producing new warriors whom were the skill-less “walking dead” addicted to the trance state, and dependant on it to survive. This is why spells that utilized dark mana became known as Destructive Energy Corrupting Asheron’s Land (D.E.C.A.L).

    The makers of the hypnotic spells insisted that their teaching would be used with restraint. That only minor tasks would be done using the spells and tasks requiring real skill such as engaging in battle they would not support. Even whilst proclaiming this, some of them were secretly using the spells to hypnotize themselves in battle.

    Enemies of the Derethian people watched as the irresponsible dark mana hackers unleashed the hypnotic powers. That’s when BZ realized that in his control he had the perfect weapon to weaken us. BZ turned people like my brother Elgar to the dark side and had him formulate an addictive battle hypnotic spell that would spread like a virus to those weaker in mind. Gradually his plan has worked since recently Derethins in masses could be seen throughout Dereth in a hypnotic zombie-like state. Asheron’s people are indeed now very weak. The spell has also had the affect of driving away those who have been strong enough to resist the virus.

    Now very recently, there was a sudden and significant change in the mana flow. In conjunction with a new race of blue people finding their way to our land, the mana’s negative energy signature has completely changed. This has made all research and understanding of dark mana invalid. Hypnotic spells can no longer be cast, and zombies across the land are waking up. Some of these zombies are discovering conscious life, while others are still dumbfounded and trembling with addiction withdrawal.

    Now is the opportunity for the creators of Destructive Energy Corrupting Asheron’s Land to make up for their past mistakes.

  11. Lucavian says:

    sweet mary,

    if you cant post anything constructive about the wonderful work he has done to explain what the dev’s are going through for the players than maybe you shouldn’t post anything as we all see it as alot of drivel that has no point in being here but you are entitled to your opinion(more often then not you should lock it in that dark corner of your brain though). nice work man seems like you all have alot of stuff about it nailed down….and makes me think people do care that the people that use decal would like to know more about the process. keep it up guys!!

  12. [...] am Wright @ 2:51 pm Well, despite embedding a couple of “bonus questions” into yesterdays post, I didn’t receive any answers. I’ll have to make the [...]

  13. Rockinron110 says:

    Sweet Mary you are a complete nutjob

    Play the game the way you want to and leave the rest of us alone.

    Thanks for all the work you guys are doing on Decal

    Freaky

  14. Darkened says:

    Sweet Mary should change her name to Schizophrenic Mary!

    In the five plus years I have been playing, this game has evolved. Decal and other plugins are only an adaptation for those who enjoy different playing styles.

    Great Work!! Decal Devs!!

    Thanks for keeping us informed and educated..

  15. Enolive says:

    Ever notice how Sweet Mary never addresses her descriminatory tendancies?

    The deliberate absense of the handicapped who rely on Decal is a slap in the face, imo.

    How about the very valid reason for people using Decal, such as handicaps and injuries, Mary?
    Turbine accepts their payment to play the game and do NOT condemn them for utilizing (smartly so) 3rd party applications/utilities to enable their enjoyment of the game as long as they are able to reply to +Envoy /tells.

    Your short sighted, black and white point of view has peaked in its heavy handedness. Allow others to enjoy the game, in a a live and let live manner, and you’ll notice your stress levels (as well as those of people around you) will decrease.

    g’day to you

    question to decal and plugin devs: Can you put up your various website information so more folks may click on the PayPal/Contribute buttons? I’d like to see your work go rewarded and support your efforts in more than a mere kind word or two. Thanks.

  16. Cd Locke says:

    Nice Story Mary let the Truth be known! What about the use of decal
    that I know for a fact that you use? Or that
    You had to let Sweet Mary die and start a whole
    new account just to play?

    Just remember if you don’t have anything nice to say
    don’t say anything.

    and or add what Turibine did when they added the market place
    and all the citys and the Dereth we knew died. Decal had nothing
    to do with that nor Elgar. If Turbine was doing thier part then
    the ucmers would have been banned from the game. In fact I remember
    code being added that would stop Tank if you did put any in put from
    the Keyboard within 5 mins, then you had to start it over again.

    For the Devs.. Yes a link to Pay Pal would be nice. As I would send
    something in when I can afford. An sorry for the start of this post
    but I feel She’s wrong nor should she be here if she has no good in
    put into the GREAT work you all are doing.

    Locke

  17. Immortalbob says:

    Very well written.

  18. bowtrox says:

    And I thought you just clicked a button and ‘SHAAZAAM’…

    …boy was I mistaken! Keep up the good work guys, and ditto’s to the paypal buttons…
    I can’t wait to see the “new and improved” decal.

    bowtrox-

  19. Yteru says:

    Once again I complement you on your narrative; it’s most informative. I had no idea how complicated Decal and all of the plug-ins were. Thanks again for all your hard work!!

    While I do my best to bite my tongue when I see posts such as Sweet Mary’s and while I do respect everyone’s right to express their opinions there does come a point when I am compelled to respond. Sweet Mary, kindly dig a hole, jump in and pull the dirt in after you. If Decal is that big a problem for you, don’t use it! Or better yet,go play WOW.

  20. Cleverace says:

    Friggin crybabies like sweet mary need to close there accounts and go play somthing else. Decal rocks! So does
    tank! I would like to see all you have to do to get it running, pay no mind to the numskulls that cut you down,
    i m sure alott more miss it then dont.

    Ya know when i started playing i considerd decal part of the game, now that its not available, i wont play, i know
    i will have to “donate” when they get it fixed.

  21. asfera says:

    To the Decal Devs
    Thank you for a program that not only helps me enjoy ac more so but Thank you for having a program that Helps my 1 armed friend play

    Very we written artical here Thanks

    Please give a link for a paypal donation and ill toss a little here and there as i have extra

    TO sweet mary
    You are the Least useful POS on this thread please go eat some worms
    Decal may have bad apps but to the people that use them they increase THERE game play experiance
    I myself hate tank but the more i read what you write the more i am convinced you are a closet macroer that wants decal to die so you can write your own cheat UCM (as if your mind can read c++ or even think in DOS) id place you as a person that hates themself so you must bring everyone else down with you
    read this quote aload Sweet mary and live it “” I Am wE ToD Id sOfA KiNg WEE tod ID”" SAY IT OVER AND OVER AGAIN liveit be it cuz YOU ARE IT

  22. Sweet Mary says:

    Locke hun, I have not suggest that I have not used Decal. I used to consider it fine and just speak out against combat marcos. That’s well know about me. But recently I have come to realize that the rest of the gaming industry sees any TPA as cheating and for good reason. The reason is that you need black and white, not grey. There’s no place to draw the line otherwise. The good plugins lead to the bad ones.

    As for suggesting I stopped playing my main and started another, you are full of crap. The last time I played, it was with Sweet Mary. When I had access to another account, I still played mainly Sweet Mary.

    How about the very valid reason for people using Decal, such as handicaps and injuries, Mary?
    Show me where this excuse has caused exceptions in any game. Other online games? Sports? Name one.

  23. Six says:

    Sweet Mary… how well *I* do know you! I have seen you using buff bots when you were young, I have seen you use trade bots even till today. Now contradiction seems to be your better suit, good leads to bad, what suit are you wearing? Whatever fecal matter you have left in that fragile skull of yours should be flushed out. You obviously have no concept of what Decal has done for MANY players for GOOD and BAD. Or how many third party plugins have adapted to the gaming COC such as tank with inactivity. So ya, if you contemplate what I said real REAL hard you will sumize I called you sh-it for brains.

  24. Tehanu says:

    again.

    Please don’t feed the trolls.

  25. Shadrackur says:

    Bravo…:)

    Great article guys…once again your input is much appreciated.

    And on a personal note it’s a shame people like “Sweet Mary” exist to vent their venom on you guys…just someone else trying to stamp their own brand of morality on an entire population.

  26. Luvitz of SC says:

    Mary do us all a favor walk in front of a semi thanks for all the hard work on decal guys and gals

  27. Karki says:

    Great articles. I will read more if you write more. :)

  28. Cd Locke says:

    Mary I wont stoop to your level again!
    we both know the truth. I’d just have
    to say that what I use to admire of
    you, I’ve lost for ever just as I did
    with the guild that we both were in.

    Your ruining a good thread. Sad
    that what these people seem to say
    is true along with every other bad
    thing I heard.

    By far the good out wieghs the bad
    in Decal, along with all the plug ins
    it comes down to how one chooses to
    use them.

    Locke

  29. Sweet Mary says:

    Locke, my intention was to ruin the thread. It’s a hacker thread and not everyone accepts what AC has become due to their actions.

    I don’t know who you are which is no surprise since if I did, you would likely not make up lies about me.

  30. Advantus says:

    *Raises middle fingers high*

    *Point at anti-Decal knobs*

    Ponders thoughts of new decal…..*atoyot*

    *Scans for paypal link to help devs*

  31. Aking says:

    I FOR ONE AM GLAD FOR THE EXTREME EFFORT DEVS HAVE BEEN WORKING ON. SWEET MARY stfu> .KEEP OUT OF IT. YOUR IDIOTIC ATTEMPTS TO UNDERMINE AC IS FRUITLESS.DONT LIKE DECAL DONT USE IT!!!

  32. Dark says:

    Nice work!

  33. Vokard says:

    First and foremost, Kudos to the DECAL Dev team. Your efforts are greatly appreciated by so many.

    Second and last….

    A fanatic’s fire is fuled by those that reply to their rhetoric.

    *Scan’s for PayPal link*

  34. Capio says:

    Keep up the good work. Cant wait for decal to be up and running with ALL of the previous plugins.

  35. Stormy says:

    Good jobs Devs!!

  36. My! my! SM certainly has a very vivid imagination, I mean coming up with that psychogenic lore about the roots of AC, ALMOST as impressive as the work that is Decal. well not really…
    Allow me to share my experience thus far. I was around when AC first came out, BEFORE decal! Since then I’ve been a member of the Obsidian Knights of TD and proudly call my self a “Knight”. Back then, many hours went into looting and selling, figuring out spells, and finding ways to stack my pyreals with out OB my character. Then Decal came out, shortly afterwards, I discontinued regular playing (in no way related to the release of Decal). I then came back late of last year when decal, it would seem, was at its peak! So many apps could be d/l’d and run to enhance the game play! And salvaging/tinking, whoa that one took a moment to figure out! You mean my bandit hilt elect yaoji is worthless now? Damn! Most recently I’ve come back to play AC after a couple months off. I’ve come to this conclusion; without the implement of Decal in game play, I no longer have the availablity of a buff bot to cast me up to tip top shape (lvl 126 sword, 2 schools magic). And now every corpse is not scanned with a swiftness that would not hinder my max exp earned / buff cycle. So now I am having to go out and interact with other players, work up to getting them to cast a few critter spells on me, and likely wind up hunting with them for the time being. Also I am now faced with the choice of, take the time to loot corpses in great detail to try and find one of those ‘rares’ I keep hearing about, OR kill one, move on to the next one until my stamina needs casting. If your still reading this post, I must say that it has been interesting coming back and adapting to AC again with out the help of Decal. Though I wouldn’t mind having it again =) However I am against macro hunting and that sort, I mean when I came across it in game, I didn’t mind it at all, its about my gaming experience, and playing the game is fun for me. BUT when my EX-patron asks to go hunting in some dungeon and then turn on ElTank and leave his monitor, that pissed me off a little bit, I mean Hello?! You take me to a dungeon above my abilities and then leave me for bantha fodder? What nerve!
    Speaking of nerve, all you Dev’s, don’t let your nerve be smashed or weakend by other attempts to knock you, instead let them be empowered by thier harsh comments. Its almost like a direct attack on your abilities, and I think you should come back double fold and show them what it means to be a ‘computer programmer of breathtaking technical and creative proficiency’.
    Keep up the preserverance and I look forward to the new Decal!
    Thank you for your posts and melting away a few hours down time at the job.
    Cheers!