Jump to content
  • Advertisement
  • 08/11/17 09:04 PM
    Sign in to follow this  

    Using DOT to Debug Data Structures

    General and Gameplay Programming
       (1 review)

    TheComet

    In this article, I'd like to share a method I used to help visually debug tree-like data structures by leveraging the DOT format and Graphviz. This may be useful to you if you ever end up having to work with low-level data structures and no way to visually see what your code is doing.

    The Problem

    During the early stages of development of my inverse kinematics library (which, at the time of writing, is in its alpha stages and not quite ready for general use yet), I was working on an algorithm which takes a scene graph as its input and generates an optimised structure consisting of a tree of "chains", specifically designed for use with an IK solver.

    The transformation is not that easy to explain in words, but here is an illustration of before (a) and after (b) (please excuse my MSPaint skills; I'm a programmer, not an artist):

    1.png.14527fd00d931285c428f1928818ef93.png

    You can see here that each end effector in the scene graph specifies a "chain length" parameter, which tells the solver how many parent nodes are affected. Since the IK solver works most efficiently on single chains of nodes, it makes sense to break down the scene graph into multiple chains which the solver can then process sequentially. This is illustrated in (b). Notice how chain 1 (red) becomes isolated from the rest of the tree after processing, because its end effector only specified a length of 1. Also notice how in the new structure each chain consists of only a sequence of nodes with no branches.

    The algorithm had to be able to handle a few weird edge cases, such as:

    • What happens when you place an effector on a node that has multiple children?
    • What happens when there are multiple end effectors in a chain?
    • What happens when an end effector specifies a chain length that doesn't quite join up with the rest of the tree?

    This of course meant it was harder to test and make sure it was working correctly. I did of course write a suite of unit tests using Google's testing framework, but I wanted more: I wanted to have the ability to visually look at what my algorithm was generating, and I wanted to do this without having to use some fancy 3D engine.

    Inroducing: DOT and Graphviz

    DOT is a simple graph description language. Graphviz is a set of open source tools for generating graphics from DOT descriptions. For example, the following DOT code:

    graph testgraph {
        a -- b;
        b -- c;
        b -- d;
    }

    Compiled with dot as follows:

    dot -Tpdf testgraph.dot -o testgraph.pdf

    Produces the following graphic:

    2.png.3252fa7a3f9e72d5d94560c63d1ad932.png

    DOT is quite a powerful language. It's possible to specify colours, shapes, multiple connections between nodes, and much more! Read up on the format specification for more information.

    In only a few lines of code I was able to iterate the optimised chain tree and serialise it to DOT. This is what the example tree I drew in MSPaint looks like after it is broken down by my algorithm and exported to DOT:

    3.png.a086849bf37d2d09b8a62102bf905a2c.png

    Things to note:

    • The black edges show the connections between the original tree.
    • The red edges show how the chains are connected (just like in the first figure (b))
    • Effector nodes are coloured blue
    • Nodes that mark the start or end of a chain are square. You can see for example that node 6 is square because it has two child chains, but node 2 is not square because it's in the middle of the second chain.

    And just like that I had a powerful way to quickly spot errors in my algorithm. Using python and watchdog I wrote a simple script that would monitor the DOT file for changes and automatically compile it to PDF. Thus, every time I ran my program the graphic would update immediately on my second monitor so I could inspect it.

    Another Example

    In another application I wrote, I implemented an intrusive profiler which would dynamically build a tree from the callgraph and store timing information in each node. I thought it would be cool to also dump this tree to DOT format and see what it looked like. Note that in this case I didn't use the "dot" command line tool, instead I used "neato" (this is also part of the Graphviz package). Neato has a different layout algorithm based on physical constraints, which in this case produces much nicer graphs than "dot":

    4.thumb.png.01c5665c8b19103584fcb2b93d565786.png

    I find it quite beautiful to look at. What you see here is a visual representation of how much time was spent where in the program. Nodes that are red are "hot" (meaning lots of time was spent in them) and nodes that are blue are "cold" (nearly no time was spent in them).

    If you zoom in a little bit you can also see that I exported some of the profiler parameters of each function.

    5.png.48db060a3bcc93f56b91bef35d448cc3.png

    While this does provide a very nice birds eye view of where your program needs optimising, I would of course recommend using proper profiling tools to further analyse the slow functions.

    In conclusion

    Due to the simplicity of the DOT language, it's trivial to write an exporter for it, so if you ever find yourself fiddling with low level data structures, consider dumping them to DOT and visualising them. I found this to be extremely helpful during development of my IK library.



      Report Article
    Sign in to follow this  


    User Feedback


    Hey, I've looked into your ik library and it seems awesome. How stable it is, besides alpha, is it ready to use? And do you anticipate if the API is going to have significant changes in the future?

    Share this comment


    Link to comment
    Share on other sites

    Hi!

    It's fairly stable at this point (as in, it doesn't crash, there are no memory leaks, it correctly calculates results in every situation).

    The biggest API change in the near future will be that positions and rotations are specified in local space rather than in global space (which is currently the case). Other than that I don't see the API changing.

    Functionally, the way it was designed introduces some major flaws (none of which you will not run into if you don't try to solve nested trees with multiple end effectors). I'm still working on getting those fixed.

    Edited by TheComet

    Share this comment


    Link to comment
    Share on other sites


    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

  • Advertisement
  • Advertisement
  • What is your GameDev Story?

    In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

    (You must login to your GameDev.net account.)

  • Latest Featured Articles

  • Featured Blogs

  • Advertisement
  • Popular Now

  • Similar Content

    • By muttsang
      Hello everyone,
      I am a Games Tech and Design student in my second year and I have made a game on the side for mobile. I want to publish the game in the Play Store for Android and I do not want to make money out of it. I just want to have a free game on the play store because I want to experience publishing games on platforms accessible to majority of people and enjoy what I have done. The problem is i do not know anything about copyright laws and legal stuff and I have used some assets from the internet where they have said the asset can only be used for personal use.
      I want to know if I could get in trouble for using those stuff for a free game (no monetization). and if i have to refer the original creator, how would I do it? 
      Sorry if it is a common and silly question but I have no idea whatsoever on the legal stuff. I looked it up on the internet and have found out that if the game does not make money i can publish it and some said that i could get into legal trouble if i am not careful about it. 
       
      Thanks,
      muttsang
    • By GameDev.net
      Note: This article was originally posted to GameDev.net in 2003, and although the "shareware" terminology is now dated, the advice remains relevant and meaningful.
       
      Why is it that some shareware developers seem to be hugely successful in financial terms, growing their sales from scratch to generate tens of thousands of dollars in income, while the vast majority struggle to generate even a handful of sales? The answer can be found by exploring the difference in mindsets between both groups. For convenience, we'll label them as the professional and the amateur.
      First, let's examine the...
       
      Product Development Cycle
      Amateur
      Get inspired by an idea for a product. Create the product, regardless of whether there's a market for it. Release the product. Promote the product sporadically until bored with marketing. Note dismal results. Ask disempowering questions like, "Why do my sales suck?" Sulk for a while. Network mostly with others who are also getting dismal results, taking comfort in the fact that you aren't alone. Make a few sporadic changes to product or web site (maybe). Abandon the product (aside from continuing to process orders and handle support), and move on to the next product with step 1. Professional
      Do basic market research to determine the best opportunities for new products. Design a product that inspires you and that can exploit the market opportunities you identified. Create the product along with the system for selling the product and the marketing plan. Release the product. Promote the product systematically according to the marketing plan. Measure results and gather feedback. Study and learn from the top industry performers (companies and products). Ask empowering questions like, "How can I increase sales by 20% or more?" Update the product, the sales system, and the marketing plan based on lessons learned. Repeat from step 5.  
      After the first pass through this cycle, the initial results for the amateur and the professional may be virtually identical. But whereas the amateur typically stops after the first pass, the professional understands that this is just the beginning. Let's say they each release products that initially generate $100 per month in sales. The amateur will often conclude that the product is a failure, perhaps make a few minor revisions that don't help much, and then move onto the next product. But the professional says, "How can I get to $200 per month?" By iterating through this cycle of refinement and re-release many times (often more than ten times over a period of several years), the professional may ultimately end up with a hit that generates thousands of dollars in monthly income. To the amateur that initial $100 per month is seen as a flop. To the professional, however, it is seen as a seed. The professional understands that the initial launch is only the first step in a long stream of future updates and refinements, not just to the product but also to the sales system and the marketing plan. Here's why this works:
      In order to make a single shareware sale, there are an enormous number of factors that must all come together synergistically. The chance of getting all these factors correct on the initial release is slim to none. Let's say there are only ten critical factors in making a shareware sale (the quality of the product, the market demand for the product, the effectiveness of your registration incentives, the effectiveness of your ordering system, the file size of your shareware demo, and so on). And let's say that for each factor there is a range of effectiveness from 0% to 100%. Understand this: these factors don't add -- they multiply! If all of your critical factors are at 100%, but just one is at 0%, that means you could be getting zero sales, even though you did most things perfectly. For instance, you could have a truly brilliant product, but if people don't feel secure using your order form, that single flaw could cost you most of your potential sales.
      What if each of these 10 factors was at 60% effectiveness? Do you realize that this means you're only getting 0.610 = 0.6% of the sales you could be getting? Even if each factor is at 90% effectiveness, that's still only 35% of optimal. Obviously, this model is oversimplified. My goal is to dispel the prevailing myth that if each part of your ordering pathway is "good but not great," that your final sales will be good too -- the reality is that lots of good factors multiply together to create "utterly dismal." Here's the formula: (Good but not great)N = Utterly dismal (for a sufficiently large N). If everything about your product is just good (say 60% of optimal), this doesn't mean you'll be getting 60% of the potential sales. It means you're more likely getting less than 1% of the sales you could be getting. Refining the critical success factors and making each part of your product, your sales system, and your marketing just a little bit better with each consecutive release is how you grow your sales massively over time. It isn't out of the question that you can double or triple your sales in a day by doing this. See this article for some ideas on that.
      Now the truth of the matter is that most initial releases are nowhere near averaging 60% effectiveness for all critical success factors. Especially for first-time developers, there are probably many factors that are at 10% or less. The headline on your product web page, for instance, may be nonexistent or poorly written. Your product may have bugs or compatibility problems that prevent many people from running it. Your web site may look unprofessional and scare potential customers away. You may not have even scratched the surface of all the marketing you should be doing. Perhaps you only have one product and aren't experiencing the benefits of cross-selling other products. It's entirely possible that when all these factors come together, you may be generating something like 0.01% of the potential results that your product is capable of if you continued to nurture its development.
      Selling software through shareware channels is very different than selling software at retail. With try-before-you-buy, there are a huge number of steps each potential customer can go through before buying, any one of which can kill the sale. Just one suboptimal factor can cost you most of your potential sales, and when combined, multiple suboptimal factors may be tossing out potential customers left and right. Picture a ball rolling down a pipe with ten holes. If the ball passes all the way through the pipe without falling through any holes, you make a sale. But if the ball falls through even one of those ten holes, the sale is lost. The way you get your product from dismal sales to outstanding sales is by systematically identifying and plugging those holes.
      Having been in this industry for many years, I've seen this cycle repeat itself again and again. You would be absolutely amazed at how many of the greatest shareware hits experienced dismal sales after their initial release... sometimes even no sales at all in the entire first year. But the developers turned them into hits by continuously improving those critical success factors over a period of years.
      So which is the better approach? To release five products in five years, each at 0.01% effectiveness, or to raise a single product from 0.01% to 2%? If 0.01% makes you an average of $100 per month, the first scenario will get you to $500 per month, and this is exactly what amateur developers do. But the second scenario will get you to $20,000 per month with just one product, and it requires less work too.
      There are three good reasons why experienced professional shareware developers are often able to release more consistent hits than less experienced amateurs. First, the pros have already plugged many of the holes in their system that are shared by all products, such as optimizing their web sites to sell, refining the ordering process, implementing a money-back guarantee, crafting a solid marketing plan, gaining excellent search engine placement, etc. So when a new product is released, it inherits the benefits of prior system-wide optimization work. Secondly, the pros can apply the wisdom gained from refining each previous product to any new release, so when they release a new product, they've already eliminated all the obvious sale-killers that still plague amateur developers. And thirdly, the pros have already internalized the attitude that the first release is just the beginning; thus, they expect to continue to refine the product and immediately start listening to user feedback to help them locate new holes that need to be plugged.
      It is rare in the extreme that a developer's initial release will be anywhere near its full potential, even if the developer has vast experience. If you release a new shareware product, I guarantee it's going to be riddled with flaws, and it's probably earning less than 1% of its potential. If you raise each of ten critical success factors by just 5%, you'll increase your sales by 60%. And if you do this over and over again, you'll see your monthly sales gradually climb: $100... $160... $250... $400... $650... $1000... $1700... $2700... $4300... $6900... $11,000... $18,000... and so on. Note that you don't even reach $1000 per month until the 5th iteration!!!
      In order to improve these critical success factors, you have to confront the brutal, objective facts. Invite others to evaluate your product, your web site, and your ordering system. This requires putting your ego aside and being as open-minded as possible. Find out how others are marketing their products. Listen to what others have to say; don't delude yourself by trying to persuade them you're right and they're wrong. Don't worry about trying to make everything perfect all at once. But see if you can increase several critical success factors by a small amount with each successive release. For instance, you might try to make your product page just 20% more effective, your registration incentives 10% more enticing, your product interface 30% more intuitive, and so on.
      As a personal example, shortly after I released Dweep in mid-1999, I began getting requests for an expansion pack of more levels. So I released an expansion pack. Players also complained that Dweep moved too slow and needed a speed control. So I added a speed control. Then players wanted another expansion pack, so I released that. Then players wanted a level editor, so I added that. Then players wanted to be able to post their own levels, so I added a free levels archive. That turned out to be too much work to maintain, so I eventually took it down and replaced it with a forum where players can post their own levels, which has been working out wonderfully. During this time I also made major revisions to the web site, the marketing process, the ordering system, cross-promotions with others games, and the price (raising it from $9.95 to $24.95 while increasing the number of levels from 30 to 152). Most of Dweep's sales were a result of these later refinements, not the initial release.
      The amateur mindset leaves most of the potential rewards forever untapped, wallowing below 1% of the true potential. But professionals keep going... treating that shareware product as a tree that must be patiently watered before it bears a full harvest of fruit. I suppose you could say that the amateur sees the glass as 99.99% empty, while the professional sees it at 0.01% full.
      Now let's explore the differences between shareware amateurs and professionals in terms of...
       
      Personal Development
      Amateur
      Myopically focus personal development efforts on the areas you enjoy most (such as design or programming) as opposed to the areas where improvement would yield the greatest results (such as marketing or self-discipline). Gain knowledge sporadically through just one or two primary sources (i.e. reading books and articles, but not live seminars or audio programs). Apply your new knowledge to make your strengths even stronger (i.e. product development), while falling further behind in your weakest areas (i.e. marketing and sales). Guard the best of what you've learned as a treasured secret. Maintain a competitive scarcity mentality. Repeat from step 1.  
      Professional
      Take personal inventory of strengths as well as weaknesses that specifically detract from those strengths (ex. poor goal-setting habits result in unfocused marketing plan). Identify key knowledge/skills that must be mastered (marketing, selling, programming, etc) as well as key character traits that need improvement (organization, self-discipline, focus, motivation, etc). Identify multiple sources where above knowledge/skills/traits can be improved (mentors, business associates, books to read, organizations to join, conferences/seminars to attend). Take action by diving into these sources. Read the books, join and become active in the organizations, attend the conferences/seminars, and learn from the key individuals. Patiently apply the new knowledge to your business and life, realizing that even small gains will compound exponentially as you continue running this cycle year after year. Pass on your new wisdom to others by sharing advice, writing, volunteering, mentoring others, etc. Maintain a noncompetitive abundance mentality. Repeat from step 1.  
      The amateur sees personal development in narrow, monodimensional terms -- i.e. becoming a better developer. Efforts are focused on acquiring more knowledge within this limited field. A shareware amateur's bookshelf will be dominated by books within a narrow field, such as software development, virtually ignoring other crucial parts of the business like marketing and sales.
      By contrast, the professional takes a holistic approach. The professional understands that all areas of one's life are intertwined and that a weakness in one area (such as financial management) can detract from strengths in other areas (such as programming). The professional's bookshelf will likely be filled with a varied mix of books on topics such as business, marketing, sales, finance, technology, psychology, philosophy, health, and relationships. The professional keeps an open mind to acquiring knowledge through a variety of media, perhaps reading a book on software development, having a discussion with peers about marketing, listening to an audio program on time management, and attending a seminar on sales techniques. The professional seeks to advance on multiple fronts, understanding that a 10% improvement in five different areas will yield better results than a 50% improvement in just one.
      The amateur guards knowledge as a scarce resource... a competitive edge. Thus, the amateur rarely becomes known in professional circles, thus missing out on scores of lucrative opportunities that professionals frequently share with each other. This attitude constricts the flow of new knowledge back to the amateur, and the result is that the amateur is cut-off and isolated from the "inner circle" of the highly successful within his/her industry. Few bother to help the amateur directly because the amateur has never done anything for them and is relatively unknown. The amateur is stuck in a downward spiral of scarcity where growing the business feels like climbing a mountain.
      Conversely, the professional understands the importance of information flow and that passing on knowledge to others only deepens his/her own understanding. This sharing of knowledge plants seeds of abundance that benefit the professional for years to come. By giving openly and generously, the professional develops a positive reputation that attracts other professionals. An abundance of new opportunities flow to the professional through this network, seemingly without effort. This creates an upward spiral where the professional is able to leverage this network to grow his/her business with relative ease.
      Finally, let's dive into the...
       
      Psychological Factors
      Amateur
      Nonexistent or foggy goals ("Make more money") Sporadic motivation coming from irregular outside influences (inspiring book/movie, great conversation, flash of insight, etc) Focus on making money and getting customers to buy Seeks to blame poor results on outside factors (poor economy, competition, lack of luck, unfairness, shortfallings of shareware model, etc) Expends effort on the most enjoyable actions Scarcity mentality based on zero-sum thinking ("I'm not going to give anything away unless I get something in return") Short-range time perspective used in planning, often limited to the timeline of a single product cycle Sees problems as obstacles Persistent self-doubt ("Success is elusive") Unbalanced approach improving major strengths while letting other areas slide Believes that success comes from doing (work), then having (results), then being (successful) "Once I achieve this (foggy) goal, then I'll be successful" Weak commitment ("I'll try this and see what happens") Avoids facing brutal facts, stays within comfort zone ("I don't enjoy/understand marketing, so I'll just keep programming for now") Believes that risk-taking and luck are necessary for big breakthroughs ("Releasing a new product is like betting on a spin of the roulette wheel") Success stories from others increase feelings of anxiety, inadequacy, or resentment Associates most frequently with other amateurs who are equally confused, having less frequent contact with professionals (group griping and pity parties outweigh true learning experiences) Negative attitude rips many new ideas to shreds before they pass the incubation stage Negative associations to building business (customers are headaches, too many responsibilities, being overextended, burning out, a risky gamble, can't make money and do what I love)  
      Professional
      Crystal-clear goals, committed to writing ("Increase sales by 20% within 3 months") Deliberate cultivation of burning desire Focus on filling customer needs and providing value Accepts responsibility for poor results, seeks to understand causes and learn from them (registration incentives need improvement, product descriptions need rewriting, etc) Seeks to understand causes of poor results and learn from them Expends efforts on the most important actions (in terms of achieving goals) and finds ways to enjoy the process Abundance mentality based on law of sowing and reaping ("Givers get") Long-range time perspective used in planning, often thinking 5+ years ahead Sees problems as opportunities Persistent confidence and faith ("Success is inevitable") Balanced approach to improving multiple weak areas that detract from strengths Understands that success comes from first being (sucessful in one's thoughts), then doing (actions consistent with those thoughts), then having (results consistent with those actions) "Once I believe I'm successful, the external results will naturally follow" Strong commitment ("I will find a way or make one") Confronts brutal facts head-on ("Marketing is crucial to my business, so I must become a master marketer") Avoids unnecessary risks and bets on opportunities with the strongest chance of success while seeking to minimize the potential downside ("Releasing a new product isn't a gamble; I'll just keep refining it over time until it ultimately becomes a hit") Success stories from others are mined for new ideas and insights Networks with focused and successful professionals, learning by osmosis Associates most frequently with other focused and successful professionals, less frequent contact with amateurs (continuous flow of knowledge and ideas) Positive attitude lets new ideas incubate in imagination before putting them to the test in the real world Positive associations to building business (financial abundance, good life for family, early retirement, freedom, making people happy, fulfilling one's dreams, giving to charity, creating jobs) When results are weak, the amateur seeks security, comfort, and consolation. Amateurs want to know they aren't alone, so they find safety in numbers by holding group griping sessions in forums that attract other amateurs. Their inner insecurity makes it very hard for them to accept failure, so they're looking to put the blame elsewhere... on the failure of the shareware system, on the economy, etc. Amateurs look for validation of their position, seeking out "experts" who agree that success in their field is hopeless and that only the really lucky can succeed. When hearing of dismal sales from others, they feel more secure. Success stories are unnerving to the amateur, often making them feel anxious, envious, or resentful.
      The professional, on the other hand, is emotionally secure. The professional seeks understanding and knowledge. The professional accepts personal responsibility for his/her results and is always looking to improve. When the professional suffers a setback, s/he wants to understand the causes, assuming that the reason for failure was a lack of understanding or skill that led to mistakes. The professional will suffer failures at least as big as the amateur, if not bigger, but the professional will learn from each experience and move forward with an even stronger plan.
      You can't tell an early professional from an amateur purely by looking at a one-time snapshot of their results. The key differences are internal. Professionals and amateurs who start from scratch may begin on the same footing. After the first year their initial results may appear similar. But fast forward ten years.... Most likely the amateur will have given up and left the business or is still barely eeking out a living. Meanwhile the professional has become an established leader with a strong, sustainable income.
      So what is the essential difference between the shareware amateur and the shareware professional? It can be summarized in just one word: fear. The amateur feels vulnerable, believing that certain things might happen which s/he will be unable to handle. The amateur doesn't want to deal with products that aren't selling well, avoids facing his/her deepest inadequacies, and seeks to manage fear by clinging to the familiar and the comfortable. Instead of pursuing the greatest opportunities, the amateur pursues the safest and most comfortable paths. For instance, an amateur who feels more comfortable programming than marketing will heavily favor programming projects, whether or not that's what the business needs most. The amateur ties much of his/her sense of self-worth to external factors, and when those factors are threatened, the amateur feels a strong urge to return to the safety of the comfort zone.
      The professional, on the other hand, has internalized thoughts of security and abundance. The professional believes that no matter what happens, s/he'll be able to handle it. The professional doesn't cling to a comfort zone. When faced with change, s/he embraces it, seeks out the hidden opportunities, and charges boldly ahead. This isn't to say that professionals never feel fear; they do. The difference is that professionals turn and face their fears instead of shrinking from them.
      Amateurs will normally not be consciously aware of their fears. Such fears will be hidden behind rationalizations such as, "I simply don't like marketing," "I'm genetically disadvantaged when it comes to planning," or "I feel like a scam artist when I write sales copy." Thinking about such tasks and projects will typically make the amateur feel a sense of discomfort, anxiety, or even dread, but they often won't consciously know why. When confronted about these shortcomings, the amateur will often become emotional, sarcastic, and defensive. But whereas the amateur addresses this problem by getting defensive and shrinking back into the comfort zone, the professional lets go of his/her ego and strives to become consciously aware of his/her fears, driving them into the open where they readily dissolve. A professional says, "I probably feel uncomfortable marketing right now because of my lack of experience, but I know other people who happen to love marketing. I'll talk to them to see what they like about it, get some book recommendations, and within a few years, I'll be outstanding at marketing as well." Alternatively, a professional might hire or partner with someone else who has the skills s/he lacks, but the decision will be made out of awareness of this deficiency, not from fear and denial.
      These models of the amateur and the professional are abstractions of course. Between them lies a continuum where real people can be found. Hopefully you'll find the contrasts between these two poles helpful in continuing your own professional development.
       
      Steve Pavlina is the CEO and founder of Dexterity Software and writes and speaks on software and computer gaming industry topics regularly. This article is Copyright © 2002 by Steve Pavlina.
    • By Dyonisian
      Note: This article was originally published on LinkedIn.  If you enjoy my article, please click through and consider connecting with me.
       
      Can programmers art? How far can creativity and programming take you?
      I have summarized what I learned in several months into 7 key techniques to improve the visual quality of your game.
       
      "Programmer art" is something of a running joke. For those unfamiliar with the term, it refers to the "placeholder" or "throw-together" art that programmers tend to use while developing games.
      Some of us don't have the necessary artistic skills, however, sometimes we just can't be bothered to put in the effort. We're concerned about the technical side of things working - art can come later.
      Here's what this usually means -

       
      I worked on a game jam with some new people a few months ago. I just wanted to make sure that my gameplay and AI code was doing what it was supposed to do. This would have to interface with code from other teammates as well, so it was important to test and check for bugs. This was the result.
      That's not what I'm going to talk about today though.
       
      I'm going to take a different angle on "programmer art" - not the joke art that programmers often use, but the fact that there's a LOT that a programmer can do to improve the visual appeal of a game. I believe some of this falls under "technical art" as well.
       
      My current job kind of forced me to think in this capacity.
      I was tasked with visualizing some scientific data. Though this data was the result of years of hard work on the part of scientists, the result was unimpressive to the untrained eye - a heap of excel files with some words and numbers.
      There are very few people in the world who can get excited by seeing a few excel files.
      My job? To make this data exciting to everyone else.
      My task was to visualize connectome data for a famous worm known as C. Elegans, made available by the wonderful people working on the OpenWorm project.
      Part of the data parsing to read and display the data as a worm's body with neurons on it was done by my teammate. My main task was to improve the visuals and the overall graphical quality.

       
      The first thing that comes to mind is using HD textures, PBR materials and high-poly models. Add in a 3D terrain using a height map, some post-processing and HDR lighting, and BOOM! Gorgeous 3D scene. I'm sure you've all seen loads of those by now.
      Except, almost none of that would really help me.
      The idea was very abstract - neurons and connections visible in a zoomed-in, x-ray-like view of a worm. I don't think rolling hills would have helped me much.
      I had no 3D modelling skills or access to an artist - even if I did, I'm not sure what kind of 3D models would have helped.
       
      As a result, what I've made isn't a gorgeous 3D environment with foliage and god-rays and lens flares. So it's not applicable in every case or the perfect example of how a programmer can make a gorgeous game.
      But, it does provide a distinct viewpoint and result. The special sets of constraints in the problem I had to solve led to this.
      So here's what I actually did:
       
      The 7 things I did to improve the visuals of my Unity game
      1. Conceptualizing the look
      This could be considered a pre-production step for art or any visual project. Ideally, what should it look like? What's the goal? What are your references?
      In this case, the viewer had a hologram-like feel to it (also there were plans to port it to a HoloLens eventually). I liked the idea of a futuristic hologram. And the metaphor of "AI bringing us towards a better future".
      So what were my references? Sci-fi of course!
      My first pick was one of my favourite franchises - Star Wars. I love how the holo-comms look in the movies.

       
      Holograms became a key component of my design.
      This is a HUD design from Prometheus that I found on Google -

       
      In this case, the colours appealed to me more than the design itself. I ended up basing the UI design on this concept.
       
      Key takeaway - Your imagination is the very first tool that helps you create impressive art. Use references! It's not cheating - it's inspiration. Your references will guide you as you create the look that you want.
       
      2. Shaders can help you achieve that look 
      I had some shader programming experience from University - D3D11 and HLSL. But that work had been about building a basic graphics engine with features like lighting, shadows, and some light post-processing. I had done some light Shader programming in Unity before as well.
      What I really needed now was impressive visual effects, not basic lighting and shadows.
      I was really lucky that this was about the time Unity made Shader Graph available, which made everything much easier. I can write Shader code, but being able to see in real time what each node (Which can be considered a line of code) does makes it so much easier to produce the effects you want.
      I familiarized myself with all the samples Unity had included with this new tool. That wouldn't have been enough though. Thankfully due to my previous experience with Shaders, I was able to make some adjustments and improvements to make them suit my needs.
      Some tweaking with speed, scaling, colours, and textures led to a nice hologram effect for the UI panels.

       
      I wanted the viewer to feel good to interact with as well, and some work implementing a glow effect (alongside the dissolve effects) led to this -
       
      Key takeaway - Shaders are an extremely powerful tool in a Game Programmer's repertoire. Tools like Unity's Shader Graph, the old Shader Forge asset, and Unreal's material editor make Shaders more accessible and easier to tune to get the exact look you want.
      PS - Step 5 below is also really important for getting a nice glow effect.
       
      3. Visual Effects and Animations using Shaders
      I was able to extend the dissolve and hologram shaders to fake some animation-like visual effects.
      And a combination of some timed Sine curves let me create an animation using the dissolve effect -
       
      The work here was to move the animation smoothly across individual neuron objects. The animation makes it look like they're a single connected object, but they're actually individual Sphere meshes with the Shader applied to them. This is made possible by applying the dissolve texture in World Space instead of Object Space.
      A single shader graph for the neurons had functionality for colour blending, glow, and dissolve animation.
      All of this made the graphs really large and difficult to work with though. Unity was constantly updating the Shader Graph tools, and the new updates include sub-graphs which make it much easier to manage.
      Key takeaway - There is more to shaders than meets the eye. As you gain familiarity with them, there are very few limits to the effects you can create. You can create animations and visual effects using Shaders too.
       
      4. Particle systems - more than just trails and sparks
      I have no idea why I put off working with the particle systems for so long!
      The "neurons" in the viewer were just spheres, which was pretty boring.
      Once I started to understand the basics of the particle system, I could see how powerful it was. I worked on some samples from great YouTube tutorials - I'm sharing a great one by Gabriel Aguiar in the comments below.
      After that, I opened up Photoshop and experimented with different brushes to create Particle textures.
      Once again, I referred to my sources of what neurons should look like. I wanted a similar look of "hair-like" connections coming out of the neurons, and the core being bright and dense.
      This is what it looked like finished, and the particle system even let me create a nice pulsating effect.
       
      Part of my work was also parsing a ton of "playback data" of neurons firing. I wanted this to look like bright beams of light, travelling from neuron to neuron. This involved some pathfinding and multi-threading work as well.
       
      Lastly, I decided to add a sort of feedback effect of neurons firing. This way, you can see where a signal is originating and where it's ending.
       
      Key takeaway - Particle systems can be used in many ways, not just for sparks and trails. Here, I used them to represent a rather abstract object, a neuron. They can be applied wherever a visual effect or a form of visual "feedback" seems relevant.
       
      5. Post-processing to tie the graphics and art together
      Post-processing makes a HUGE difference in the look of a game scene. It's not just about colours and tone, there's much more to it than that. You can easily adjust colours, brightness, contrast, and add effects such as bloom, motion blur, vignette, and screen-space reflections.
      First of all, Linear colour space with HDR enabled makes a huge difference - make sure you try this out.
      Next, Unity's new post-processing stack makes a lot of options available without impacting performance much.
      The glow around the edges of the sphere only appears with an HDR colour selected for the shader, HDR enabled, and Linear colour space. Post-processing helps bump this up too - bloom is one of the most important settings for this.
      Colour grading can be used to provide a warm or cool look to your entire scene. It's like applying a filter on top of the scene, as you would to an image in Photoshop. You can completely override the colours, desaturate to black and white, bump up the contrast, or apply a single colour to the whole scene.

       
      There is a great tutorial from Unity for getting that HD look in your scenes - if you want a visible glow you normally associate with beautiful games, you need to check this out.
       
      Key takeaway - Post processing ties everything together, and helps certain effects like glows stand out.
       
      6. Timing and animation curves for better "feel" 
      This is a core concept of animation. I have some training in graphic design and animation, which is where I picked this up. I'm not sure about the proper term for it - timing, animation curves, tween, etc.
      Basically, if you're animating something, it's rarely best to do it with linear timing. Instead, you want curves like this -

       
      Or more crazy ones for more "bouncy" or cartoon-ish effects.
      I applied this to the glow effects on the neurons, as I showed earlier.
      And you can use this sparingly when working with particle systems as well - for speed, size, and similar effects. I used this for the effect of neurons firing, which is like a green "explosion" outwards. The particles move outwards fast and then slow down.
      Unity has Animation Curve components you can attach to objects. You can set the curve using a GUI and then query it in your C# scripts. Definitely worth learning about.
      Key takeaway - Curves or tweens are an animation concept that is easy to pick up and apply. It can be a key differentiator for whether your animations and overall game look polished or not.
       
      7. Colour Palettes and Colour Theory - Often overlooked
      Colour is something that I tend to experiment with and work with based on my instincts. I like being creative, however, I really underestimated the benefits of applying colour theory and using palettes.
      Here's the before -
       
      Here are some of the afters -
       
      I implemented multiple themes because they all looked so good.
      I used a tool from Adobe for palettes, called Adobe Colour - link in the comments.
      I basically messed around with different types of "Colour harmony" - Monochrome, triad, complementary, and more. I also borrowed some colours from my references and built around that.
      Key takeaway - Don't underestimate the importance of colour and colour theory. Keep your initial concept and references in mind when choosing colours. This adds to that final, polished look you want.
       
      Bonus - consider procedural art
      Procedural Generation is just an amazing technique. I didn't apply it on this project, but I learned the basics of it such as generating Value and Perlin noise, generating and using Height maps for terrains, and generating mazes.

       
      Procedural art is definitely something I want to explore more.
      A couple of interesting things (Links in the "extra resources" section below) -
      Google deepdream has been used to generate art. There's an open-source AI project that can colour lineart. Kate Compton has a lot of interesting projects and resources about PCG and generative art. I hope this leads to tools that can be directly applied to Game Development. To support the creation of art for games. I hope I get the opportunity to create something like that myself too.
      Conclusion
      These 7 techniques were at the core of what I did to improve the visual quality of my project.
      This was mostly the result of the unique set of constraints that I had. But I'm pretty sure some famous person said: "true creativity is born of constraints". Or something along those lines. It basically means that constraints and problems help channel your creativity.
      I'm sure there is more that I could have done, but I was happy with the stark difference between the "before" and "after" states of my project.
      I've also realized that this project has made me more of an artist. If you work on visual quality even as a programmer, you practice and sharpen your artistic abilities, and end up becoming something of an artist yourself. 
       
      Thanks for reading! Please like, share, and comment if you enjoyed this article.
      Did I miss something obvious? Let me know in the comments!
       
       
       
       
       
      Extra Resources
      OpenWorm project
      Great tutorial by Gabriel Aguiar
      Unity breaks down how to improve the look of a game using Post processing
      Another resource on post-processing by Dilmer Valecillos
      Brackey's tutorial on post-processing
      Adobe Colour wheel, great for colour theory and palettes
      An open-source AI project that can colour lineart
      A demo of generative art by Kate Compton
       
      Note: This article was originally published on LinkedIn. If you like it, please click through, get in contact, and consider connecting.
    • By JoAndRoPo
      Hi! 
      I hope this is the right area in the forum to post this question? 🤔 
      There are games with clear data and restore purchases in the settings page. 
      Question#1: What all does get cleared when clicking on clear data? Does this only clear player statistics & player experience? What about things that the player has purchased with in-game currencies (Can this be an option placed from the developers end? Question#2: What does get restored when clicking on restore purchases? Will it restore everything that the player has purchased with real currency?   I have a basic idea on what these 2 features do but would also like to know of all the possibilities available?
      Thanks!
       
       
    • By Seer
      I have written an algorithm which resolves collisions between axis aligned rectangles so that they are resting against one another after collision resolution.
       
      The code is in Java using LibGDX
      public class Rectangle { public Vector2 position; public float halfW, halfH; private Vector2 restingDistance, currentDistance, overlap; public Rectangle(Vector2 position, float halfW, float halfH) { this.position = position; this.halfW = halfW; this.halfH = halfH; this.restingDistance = new Vector2(); this.currentDistance = new Vector2(); this.overlap = new Vector2(); } public boolean intersects(Rectangle rectangle) { return (position.x - halfW < rectangle.position.x + rectangle.halfW && position.x + halfW > rectangle.position.x - rectangle.halfW && position.y - halfH < rectangle.position.y + rectangle.halfH && position.y + halfH > rectangle.position.y - rectangle.halfH); } public void resolveCollision(Rectangle rectangle) { // Calculate the resting distance of the two rectangles restingDistance.set(halfW + rectangle.halfW, halfH + rectangle.halfH); // Calculate the current distance between the two rectangles currentDistance.set(position.x - rectangle.position.x, position.y - rectangle.position.y); // Calculate the overlap between the two rectangles overlap.set(restingDistance.x - Math.abs(currentDistance.x), restingDistance.y - Math.abs(currentDistance.y)); // Remove the overlap of the axis with the greater overlap overlap.set(overlap.x < overlap.y ? overlap.x : 0, overlap.y < overlap.x ? overlap.y : 0); // Reverse the direction of the overlap depending on the positions of the rectangles overlap.set(position.x < rectangle.position.x ? -overlap.x : overlap.x, position.y < rectangle.position.y ? -overlap.y : overlap.y); // Add the overlap to the rectangles position position.add(overlap); } }  
      The code is used like this
      if(rectangle1.intersects(rectangle2)) { rectangle1.resolveCollision(rectangle2); }  
      From my testing the code works. Colliding rectangles are moved out of collision so that they are resting against one another. Are there any problems with the way the code resolves collisions? Can the collision resolution code be improved and if so how? Thank you.
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!