블로그

  • Navier-Stokes 방정식

    유체방정식인 Navier-Stokes 방정식을 푸는 것이 게임에 구현된 것은 거의 못 본것 같습니다. 아직까지는 단순한 노이즈 기반의 식을 쓰는 것 정도로 충분한것 같고요. 저는 지금까지는 이런 물리식을 게임에 쓰는일은 전혀 안해봤네요. 논문상으로는 파티클을 생성시켜서 물결을 일으키는 수준까지는 있습니다만 대부분 이펙트로 처리하는 것 같습니다.

    참고로 Navier-Stokes방정식을 영화 CG쪽에서는 Newtonian 방법이나 Lagrangian 방법으로 나뉘는데 Newtonian은 물의 공간을 표현하는데 좋고 (일반적인 프로그램에서 지원하는 것 같더군요) Lagrangian은 물뿌리는 것에 좋습니다. 점성도 표현 가능하죠. (Realflow라는 프로그램이 많이 쓰입니다.) 다만 실시간이 절대 아니고요 시간이 아주 오래오래 걸려요.

    게임쪽에 물리가 들어오기엔 좀 어려워보이는게 아무래도 해외 진출을 해야하는 형편이다보니 저사양을 고려하지 않을수 없어서 물리를 넣기에는 좀 어려울것 같아요.

    결국 서버에서 물리를 자세히 하는 것은 오버라고 보고요 잘못된 위치를 보정해주는 정도만 해도 될것 같네요. 이런 일은 클라이언트 프로그래머가 가능한 업무 범위가 아닌가 생각됩니다.

  • 25 essential books that every college student should read.

    There is no college student who would like reading books, they say. Can you believe it? We hardly think so!

    Yes, reading is fashionable. Again. And every college student is always in fashion as a rule. But a sufficient ammount of other reasons why books are worth reading for students can be found which are more essential than simple fashion following:

    • books widen your vocabulary;
    • books help students find new models for academic writing;
    • books improve your cognitive skills;
    • books expand your view of the world around;
    • books let students remember grammar and punctuation rules autmatically;
    • books help students learn a subject better;
    • books help you avoid a social exclusion (according to this study of the Basic Skills Agency).

    Every college student has their own list of must-read, or at least must-check, books; but what if we tell you there are some writing masterpieces that are worth your attention and are essential for college students to read? Check the list below!

    1. Freedom by Jonathan Franzen

    freedom

    “You may be poor, but the one thing nobody can take away from you is the freedom to fuck up your life whatever way you want to.”

    This is a story about a relationship, a love triangle which subjects first met in college. What will become more important to them: love or friendship? Is there any decision for this difficult situation, when you love but do not want to lose your best friend? Every college student should know the answer to these questions.

    2. This Side of Paradise by F. Scott Fitzgerald

    this side of paradise

    “It is not life that’s complicated, it’s the struggle to guide and control life.”

    A privileged Princeton student becomes totally disillusioned after graduation. He finds out that life is completely different behind the walls of his college, and now he has to look for his self again. It sounds so familiar to many college students today, doesn’t it?

    3. Norwegian Wood by Haruki Murakami

    norwegian wood

    “Don’t feel sorry for yourself. Only assholes do that.”

    This is a story about true love and friendship, when one college student has to change his life principles and attitude to everything that happens around. It teaches us to appreciate friendship and people who love us, and be ready to accept the ugly truth of life.

    4. 1984 by George Orwell

    1984

    “Perhaps one did not want to be loved so much as to be understood.”

    A world divided between three totalitarian states. A total control, elimination of all human values, and attempts to survive in this world full of hatred. Will you be able to challenge the system? Are you strong enough to remain for ever one and not to lose your individuality?

    5. Crime and Punishment by Fyodor Dostoyevsky

    crime and punishment

    “Pain and suffering are always inevitable for a large intelligence and a deep heart.”

    A well known novel about the student Raskolnikov and his attempts to find his place in this life and understand who he really is. After killing an old pawnbroker, this young man tries to justify his actions. Raskolnikov’s story can make every modern college student rethink their views to moral laws and their place in society.

    6. A Brave New World by Aldous Huxley

    a brave new world

    “Words can be like X-rays if you use them properly — they’ll go through anything. You read and you’re pierced.”

    A novel that was called “a negative utopia” by its author. This is a story about our future world, where happiness plays an important role but individuality is not appreciated. Is it possible to stay happy, being like others? What is more important to young people: to accept things as they are, or try to resist the system?

    7. One Hundred Years of Solitude by Gabriel Garcia Marquez

    one hundred years of solitude

    “Then he made one last effort to search in his heart for the place where his affection had rotted away, and he could not find it.”

    This is a myth-novel, an epic novel, a novel-paroemia about the evolution of humanity where each of us is doomed to loneliness, and where loneliness is the only thing that dominates the world where everything is tangled with the ties of fatal love. A perfect reading for college students to understand and estimate the importance of a family and close people who support them.

    8. The Great Gatsby by F. Scott Fitzgerald

    the great gatsby

    “The loneliest moment in someone’s life is when they are watching their whole world fall apart, and all they can do is stare blankly.”

    This book should be read to feel the disillusionment many Americans felt during the Jazz Age. This is a good lesson to young people that teaches them to assess their capabilities and understand that our past can’t be returned; so, it is always better to let it go.

    9. Lolita by Vladamir Nobokov

    lolita

    “I knew I had fallen in love with Lolita forever; but I also knew she would not be forever Lolita.”

    Full of humor and intrigue, this novel about forbidden love between a man and a young nymphet remains controversial today but can teach us understanding, sacrifice, forgiveness and many other traits that are so important but forgotten by so many people today.

    How Balanced is Your Life?

    Assess how balanced your life is with our Time/Life Self-Assessment and get a customized report for free.

    You will find out your time management strengths, uncover hidden opportunities, and shape your life on your terms.

    Take the Free Assessment

    10. A Farewell to Arms by Ernest Hemingway

    a farewell to arms

    “But life isn’t hard to manage when you’ve nothing to lose.”

    The first – and the best! – book of the English literature “Lost Generation” about World War I. This is a story about the war where young and naive boys became Poor Bloody Infantry, and either died or became embittered to the limit; about the war where love is just a brief moment of rest with no past and no future; about the war you want to forget but which can’t be forgotten.

    11. The Grapes of Wrath by John Steinbeck

    the grapes of wrath

    “If you’re in trouble, or hurt or need – go to the poor people. They’re the only ones that’ll help – the only ones.”

    This is a story about one family that moves to California in attempts to find a better life during the great depression; the story about the importance of love, support, and close people near you; the story about resilience and courage of a man to roll with the punches.

    12. The Master and Margarita by Mikhail Bulgakov

    the master and margarita

    “Yes, man is mortal, but that would be only half the trouble. The worst of it is that he’s sometimes unexpectedly mortal -there’s the trick!”

    The devil comes to Moscow. Merry mischief and melancholy sadness, romantic love and magical obsession, mystery and reckless game with the evil spirit – they all can be found in this novel. Perfect reading to find out how the evil can be more honest than a society and political regimes.

    13. Uncle Tom’s Cabin by Harriet Beecher Stowe

    uncle tom's cabin

    “Treat ’em like dogs, and you’ll have dogs’ works and dogs’ actions. Treat ’em like men, and you’ll have men’s works.”

    This book is a part of many colleges history though it was both praised and criticized. A difficult and quite controversial period of American history many famous writers and essayists described is represented here, and it helps young people understand the principles and values of their nation to see how they have been changed since then.

    14. The Stranger by Albert Camus

    the stranger

    “If something is going to happen to me, I want to be there.” 

    After reading this novel, young people will understand how important their personal choice is and how indifferent the universe sometimes is. The story of a person who killed a man and did not feel guilty lets us see how absurd the world around us may be.

    15. The Art of Happiness by The Dalai Lama

    the art of happiness

    “Happiness is determined more by one’s state of mind than by external events.” 

    The series of interviews with the Dalai Lama can help college students (and all other people actually) learn and understand how to attain fulfillment in their life and start feeling happy.

    16. Faust by Johann von Goethe

    faust

    “As soon as you trust yourself, you will know how to live.” 

    A bet between God and Mephistopheles for the soul of Faust turns into his supernatural journey and struggle for his will and freedom. This play teaches us to understand the difference between good and evil, learn some myths of ancient history, and master the art of dispute.

    17. Paradise Lost by John Milton

    paradise lost

    “Solitude sometimes is best society.” 

    We all know the Biblical story about Adam and Eve’s temptation into sin by Lucifer, the arrogant angel that fell from grace. But we know practically nothing about Lucifer himself. Paradise Lost helps us see the different side of good and bad, allowing to make our own impression about who is right.

    18. Lord of the Flies by William Golding

    loed of the flies

    “The greatest ideas are the simplest.” 

    An uninhabited island; a boundless ocean; and boys with no adults supervision. This is a story about a divided society by the example of a small kids’ community. A revolution. Bloodshed. Death. It demonstrates us how important (and necessary) it is to be a good leader, to have a clear mind, to be a critical thinker, to be able to find a compromise, and to stay a human first of all.

    19. To Kill a Mockingbird by Harper Lee

    to kill a mockingbird

    “You never really understand a person until you consider things from his point of view… Until you climb inside of his skin and walk around in it.” 

    This is a book about a young girl’s growing up, which passes through adventures, fun, and relationships with peers. She has many things to learn about, including life’s unfairness to kids, weak people, or people with a different skin color. As a result, we can see that kindness, sympathy and mutual support do not depend on your color of skin, your social status, or public opinion. It all depends on a man’s soul.

    20. The Running Man by Stephen King

    the running man

    “Say your name over two hundred times and discover you are no one.” 

    In a typical small town, an ordinary man lives. Slowly but surely he sinks into the abyss of black hatred to himself and everyone who surrounds him. And when an occasion happens, it is impossible to stop him. America becomes a hell; people die of hunger, and the only way to get some money is to take part in the most monstrous game generated by a warped mind of a sadist. What are people ready to do and how far are they ready to go to get what they want?

    21. A Clockwork Orange by Anthony Burgess

    a clockwork orange

    “When a man cannot chose, he ceases to be a man.” 

    This is a wicked satire to a modern totalitarian society that tends to turn a young generation into so-called “clockwork oranges”, obedient to the will of their leaders. A clever, cruel, charismatic antagonist Alex, a leader of a street gang that considers violence the high art of life, runs into the iron jaws of a new state program for the criminals rehabilitation, and he becomes a victim of violence himself.

    22. Civilization and Its Discontents by Sigmund Freud

    civilization and its discontents

    “Most people do not really want freedom, because freedom involves responsibility, and most people are frightened of responsibility.” 

    This book is a must-read for every college student just because it describes Freud’s views and ideas that are still a major part of our culture and world’s understanding. This is a good chance to understand why we live in society the way we do.

    23. A River Out of Eden by Richard Dawkins

    a river out of eden

    “The universe that we observe has precisely the properties we should expect if there is, at bottom, no design, no purpose, no evil, no good, nothing but pitiless indifference.”

    This book is a perfect reading for college students who want to learn the process of evolution in simple and interesting way. The author gives a truly beautiful explanation of our world’s birth and development, and no one will have heart to call this story boring.

    24. Hamlet by William Shakespeare

    hamlet

    “We know what we are, but not what we may be.” 

    One of the most well known plays of William Shakespeare, Hamlet helps us find the answer to the eternal question we heard many times: “To be or not to be?”. This is a story that can teach us to accept the responsibility for all our decisions and deeds.

    25. The Divine Comedy by Dante

    the divine comedy

    “In the middle of the journey of our life I found myself within a dark woods where the straight way was lost.”

    Who did not hear about Dante and his nine circles of Inferno? This is our chance to learn them all and understand the view of afterlife Christians had in Middle Ages. We all will have to pay for our sins, and this book teaches us not to forget about that.

    How many books from this list have you read already? Do you have anything to add or change here?

  • Graveyard Keeper: How the graphics effects are made

    Hello! I’m a lead programmer of the game “Graveyard Keeper”. I’d like to share with you some techniques and tricks that we used to make our game look as you see it from the GIF below.

    We are very passionate about graphics in our games. That’s why we put so much time and effort into different effects and other stuff that makes our pixel art as attractive as possible. Maybe you will find here something helpful for your work.

    First I want to say some words about big parts that compose the visual part of our game:

    • Dynamic ambient light is just change of illumination depending on the time of the day.
    • LUT color-correction is responsible for the change of color shades depending (again) on the time of the day (or world zone).
    • Dynamic light sources — torches, ovens, lamps.
    • Normal maps — make objects look like they have a real volume, especially when light sources move.
    • The math of light 3D distribution — a light source centered on the screen should illuminate a higher object properly and should not illuminate an object below (turned to the camera with its dark side).
    • Shadows are made with sprites, they turn and react to light source positions.
    • Object altitude simulation — for the fog to be displayed correctly.
    • Other stuff: rain, wind, animations (including shader animation of leaves and grass) and so on.

    Let’s talk about those in more details now.

    Dynamic ambient light

    Nothing special here. Darker at night, lighter in the daytime. The light’s color set with a gradient. By nightfall a light source not only becomes darker but gets blue tint.

    It looks like this:

    LUT color correction


    LUT (Look-up table) is a table of color change. Roughly speaking it’s a three-dimensional  RGB array where each element (a) corresponds to a color with its coordinates as RGB values; (b) contains the color value that the color associated with the element should be changed to. So if there is a red point at coordinates  (1, 1, 1), it means that all the white color from the picture will be replaced with red. But if there is white color at the same coordinates (R=1, G=1, B=1), the change doesn’t happen. So LUT by default has coordinates associated with a particular color. I mean that point with coordinates (0.4, 0.5, 0.8) is associated with color (R=0.4, G=0.5, B=0.8).

    It should also be pointed here that for convenience that 3D texture is represented as two-dimensional. That’s how for example default LUT (that doesn’t change color) looks:

    Easy to make. Easy to use. Works really fast.

    It is very easy to set up — you give an artist a picture from your game and say: “Make it look like it’s evening”. Then you apply all color layers plus the default LUT. Congratulations! You get an Evening LUT.

    Our artist was actually very passionate about it. He created 10 different LUTs for different time of day (night, twilight, evening and so on…) That’s how the final set of LUTs looks:

    As a result one location may look different at different time of day:

    The picture also shows how the intensity of the light sprites changes depending on the time of day.

    Dynamic light sources and normal maps

    We use regular light sources, the default Unity ones. Also, every sprite has its own normal map. This helps to feel the volume.

    These normals are pretty easy to draw. An artist roughly paints light on 4 sides with a brush:

    And then we merge them with a script in a normal map:

    If you are looking for a shader (or software) that can do that, pay attention to Sprite Lamp.

    3D light simulation

    This is where things start to be a bit more complicated. You can’t just light the sprites. It’s very important whether a sprite is “behind” a light source or “in front of” it.

    Take a look at this picture.

    These two trees are at the same distance from the light source but the back one is illuminated while the front one is not (because the camera faces its dark side).

    I solved this problem very easily. There is a shader that calculates the distance between a light source and a sprite on the vertical axis. If it’s positive (the light source is in front of the sprite), we illuminate the sprite like we always do, but if it’s negative (the sprite is blocking the light source), then the intensity of lighting is fading depending on the distance at a very quick rate. There is a rate, not just “not to illuminate”. So if the light source behind the sprite is moving, the sprite is blackening gradually, not at once. Yet it’s still very fast.

    Shadows

    Shadows are made with sprites rotating around a point. I tried to add a skew there, but it turned out to be unnecessary.

    Every object may have a maximum of 4 shadows. The shade from the sun and the additional three from dynamic light sources. So the image below shows this concept:

    The problem “how to find the closest 3 light sources and to calculate the distance and an angle was solved with a script running in the Update() loop.

    Yes, it’s not the quickest way considering how much math is involved. If I programmed it today, I would use that modern Unity Jobs System. But when I did it there was no such thing so I had to optimize regular scripts we had.

    The most important thing here is that I did the sprite rotation not modifying the transform but inside a vertex shader. So the rotation isn’t involved here. You just put a parameter to a sprite (I used the color channel for that, all the shadows are black anyway), while the shader is responsible for sprite rotations. It turns out to be quicker — you don’t have to use Unity geometry.

    There is a minus to this approach. The shadows are to be adjusted (and sometimes drawn) separately for each object. Yet actually, we used about ten different more or less universal sprites (thin, thick, oval etc.)

    The next disadvantage is that it’s difficult to make a shadow for an object that is stretched along one axis. For instance, look at the fence shadow:

    Not ideal. That’s how it looks if you make a fence sprite translucent:

    It should be noted here, by the way, that the sprite is highly distorted vertically (the shadow sprite original looks like a circle). That’s why its rotation looks like not just a simple rotation but also like a distortion.

    The fog and the altitude simulation


    There is also fog in the game. It looks like this (the regular version above and and an extreme 100% fog to demonstrate the effect).

    As you see, the tops of houses and trees are seen from the fog. In fact, this effect is really easy to make. The fog consists of a great deal of horizontal clouds spread across all the picture. As a result the upper part of all the sprites is covered with a fewer amount of fog sprites:

    The wind

    The wind in a pixel art game is a completely different story. There are not many options here. To animate manually (it’s not possible considering how much art we have) or to make a deforming shader, but then you’ll have to deal with some ugly distortions. You can also don’t do any animation, but then the picture will look static and lifeless.

    We chose the deforming shader. It looks like that:

    It’s pretty obvious what’s happening here if we apply the shader to the chequered texture:

    It should also be pointed here that we do not animate the whole crown of a tree but some particular leaves:

    There are also an animation of a wheat field shake and things are pretty simple here too. The vertex shader changes the shape of the x-coordinates taking y-coordinate into account. The highest point will be shaken the most intensely. The intention here is that the top should move while the root shouldn’t. Plus the phase of shaking varies according to the x/y coordinates to make different sprites move separately.

    This shader is also used to create a swinging effect when a player goes through wheat or grass.

    I think that’s all for now. I haven’t spoken about scene construction and about its geometry, because there is a lot to speak about in a new entry. Beyond that I’ve spoken about all the main solutions that we applied developing our game.