Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Mar 2005
Offline Last Active Yesterday, 11:58 PM

#5291667 Which AP (Advanced Placement) course should I take for Game Dev ?

Posted by frob on 15 May 2016 - 12:55 AM

The ones you are interested in.


No specific courses or activities will guarantee you a job in the field.  There is no course that will make employers say "Well they didn't take that class, there is no way we're ever hiring that person!".

#5291654 Indie studio company shares

Posted by frob on 14 May 2016 - 10:06 PM

Generally ownership shares are a small business's most valuable asset.  If the company does well, you'll get a potentially huge value.


There's the old story of the painter who did murals for Facebook's first studio and he was offered either cash or shares; he took shares and at the IPO his shares were worth $200M. More typically if the company does well the shares will be worth $50K, $100K, maybe something on that scale, depending on what shares they offer.  It doesn't happen often, but it does happen.


But if the game studio does terrible -- and most that are not run as careful businesses will fail -- then they are worth nothing.


Most small businesses fail, and in that case the shares won't be worth the paper they're printed on.  


With actual shares rather than options to buy shares, there is a slight if the company is not operating in a business-like manner and mixing business funds with corporate funds, if the company takes on debt, even if you did not guarantee the loans there is a slim chance if they declare bankruptcy that someone might go after you instead.  So make sure you never mingle their money.

#5291648 What does a C++ Programmer need to get the job?

Posted by frob on 14 May 2016 - 08:16 PM

From the description, location is probably your biggest killer.  You need to be local to the game studios, it is rare for a studio to pay to relocate an entry level worker, and if you are willing to move on your own money it is still unlikely they'll interview if you are not local.


Go through the forum FAQ for some ideasto help break in, but being blunt, you need to be where the employers are, or look for a different route to follow your passions.

#5291451 Ways of Buffering Data to be Rendered?

Posted by frob on 13 May 2016 - 01:46 PM

More buffers need more time, which delays the player.  PS2 hit about the limit that players are willing to tolerate, having effectively four buffers before hitting the players is a LONG time, and programmers needed to do quite a lot to keep the games feeling smooth.


The nicest thing I've found so far showed a quickie implementation using macros which I nearly barfed at. .. So I am curious if anybody knows of any *modern* resources about this stuff


The process is not that hard to do and doesn't require any macros or anything.


In both D3D12 and Vulkan it is configured with your swap chain settings, which establishes a queue of buffers. The D3D12 stuff is documented on MSDN, the Vulkan stuff is buried in the specs, search for vkCreateSwapchainKHR to start the search but it basically works the same.



Generally with triple buffering you have the currently displayed buffer, the fully-drawn-but-pending buffer, and the one you are filling up. It provides a slight time buffer beyond what double-buffering gives you, but typically at a cost of an additional ~16 ms lag, putting the game 45-60 ms behind the player's input. Personally I don't think it is worth the benefit, you gain a small amount of processing smoothing at the expense of display lag, but your game might be different.


For competitive network games and twitch games, when you couple it with network lag often that adds another delay the additional buffer lag is often unacceptable to competitive players. They're the same players who will turn off vsync and prefer torn images with the split-second information benefits over the visual quality.

#5291437 when to use concurrency in video games

Posted by frob on 13 May 2016 - 11:53 AM

Concurrency is when two threads of execution can both make progress. Basically, concurrency is the equivalent of "is there more than 1 thread" while parallelism is "can more than 1 thread actually run at the same time." Parallelism is for performance while concurrency is for correctness.


While this can be true, for modern environments it is generally not compelled to be true.  


If I launch four threads to do a task and I have four CPUs on my machine, I generally presume the operating system will put one task on each thread.  But unless I take specific steps to ensure they are mapped that way, the OS has many scheduling options available.


The OS can run them sequentially on a single CPU and swap them out when they do blocking operations, or run them sequentially on multiple CPUs, or it can time-slice them on a single CPU, or time slice them on any number of CPUs. It can move them from one CPU to another CPU mid-execution. It can schedule them among other processes in any way the scheduler chooses.


You can take steps in most systems to require that the OS map a processing thread to a specific CPU, but even then the scheduler won't guarantee they are run simultaneously on different hardware at the same instant except on a small number of real-time operating systems for hardware that doesn't apply here on gamedev.net.


The parts about performance and correctness I feel is nonsense.   Code should always be correct or you are writing bugs.

#5291436 Polymorphism in C

Posted by frob on 13 May 2016 - 11:40 AM

My question is, would you use something like this? My biggest concern is in the implements macro.


Not particularly. Interfaces in C already exists and works well.


What you describe already has an implementation in idiomatic in C, and has existed since the '70s.  


The virtual functions in C++ was a way to automate the process with a standardized seven letter keyword and a standard structure called a vtable that can be made static rather than the more common dynamic structure, but otherwise the practice is common in C and has been for decades. 


Many of the "opaque pointers" in C such as the FILE structure contain a collection of function pointers that are specialized for whatever the underlying file connection happens to be. The functions the programmer calls in the library, fread(), fwrite(), fclose(), and so on, were often implemented as what C++ calls virtual dispatch. Instead of doing the work directly, they call the FILE structure's internal read function, or write function, or close function, and those functions are assigned when fopen() figures out the details of the stream it will be working with.



You might have a CreateFoo that returns a pointer to a FooStruct. You can state that FooStruct contains function pointers for your push, pop, peek, and size operations. Or you might have the FooStruct have a guaranteed member called SmallStack that has a function table with those function pointers in it so you can implement multiple interfaces that way.



Trying not to be too harsh, but it looks like all you did is wrap up some virtual function assignment with a macro specific to your individual functionality. Since everyone is going to write their own version for any new functionality they write, it doesn't seem to be much of a helper.  With idiomatic C you write that in your factory method already, and it is not a difficult or tedious task needing a macro.

#5291336 when to use concurrency in video games

Posted by frob on 12 May 2016 - 03:27 PM

Concurrency and parallelism are different names for basically the same thing.  You want to do multiple things at the same time. Various people have their own individual definitions but they are not standardized. Someone might think the work between tasks must be interrelated or independent. Others will want the tasks to be run by a particular pattern. Some might require that two different pieces of hardware are working at the same time versus an operating system running a task scheduler that could potentially put multiple processes on the same hardware in time slices.  The difference between concurrency and parallelism is a religious war more than anything.





To get to when and the why you need to understand a lot of details first. 


You need to know the machines you are on and their parallel abilities. If you know your machine has three parallel x86 processors, that's important.  If you know your machine has 6 SPE processors each with 6 parallel execution units, that is important too.  You need to know what the hardware looks like.  If you want to do something in parallel that is beyond what your target hardware supports you will get terrible support. If your write code expecting 8 hyperthreaded processors and you only have 2 non-hyperthreaded processes, that is not good. If you are working on parallel code for a graphics card, you need to understand what hardware is available there, instead.  Understand your minimum hardware.


You need to know what problems you are interested in doing in parallel.  Parallel searches, parallel sorts, parallel effects, parallel physics, parallel simulations, you need to understand the problem.  Understanding the problem also includes understanding the size of the problem. A sort of 100 data elements can be quite different from a sort of 100,000 data elements.  Know your problems.


Then you need to break down your processing in your game. You have core work that must get done. You must run your simulation. You must run physics.  You also have optional work that is not necessary but can be nice. Giant particle systems, visual effects, audio effects. They are nice to have, but not critical to your game.


You mentioned AI, but most AI systems should be core work.  You don't want someone on a high-end machine having a more powerful AI than someone on a low power machine. 



Parallel processing for core architecture works great only as far as your minimum spec goes.  If your minimum spec is for two processing threads it must work for two processing threads and any extra threads are a bonus.  If your minimum spec is 6 SPE threads then it must work for that, instead.  The minimum spec is important, and the difference between the minimum spec and the target ideal spec is important.


Once you've identified those, you need to look at algorithms that fit your architecture. Some problems have specific parallel algorithms.  Parallel searching, parallel sorting, parallel independent tasks, these have straightforward parallel algorithms that are well-studied. Other concurrency like asynchronous calls for I/O are also well-studied. But not everything can be concurrent, some algorithms are inherently serial processing like numerical methods used in physics. Once you understand them you can  each physics interaction is inherently serial, but you can do many of them side by side. You need to partition your problem into pieces that can be studied and eventually mapped to a target number of processors.  Then typically you break down communications patterns between them, bundle them into groups of work, and map them to the actual CPUs for work.  But that is more how rather than when.


We are closer to figuring out when.  With this information you can figure out how to partition, agglomerate, and map the work, and you can estimate the kind of speedup you get. That is, you have problems that can be done in parallel either with a superlinear speedup (like parallel search) or with a roughly linear speedup (like compartmentalized work tasks) are great for parallel processing. If your problem can be readily broken down into either one, and the problems are large enough that the effort makes sense, it is a good candidate. 


That leads to asking: how much should it be broken down?  You should break down what you must do into at least as many minimum processing nodes as your system has, but you also can break it into more of them if that makes sense for your architecture.  If you are developing on a game console where your hardware is fixed you know exactly the number of processors you will be mapping to.  You can fine-tune to run on six parallel processors or whatever is in the console box.


That is what makes it tricky for PC development.  If your minimum spec is 2 processing threads but you happen to be running on an Intel 8870 with 18 CPUs (36 HT processors), you'll have far more processing power available but no additional core work to do. You can write algorithms that take advantage of the core work you must do, but once that is done, you'll have time for optional work. If you write code that naturally breaks work down into too many tiny pieces it will add extra overhead.  If you break the work down into hundreds of tiny pieces and only have two workers you add overhead for each tiny piece.  But on the other hand, if you break it down to many pieces and have many workers available they can do the task more quickly.


So after you've figured out all those things, what you must do and what is optional, and you know the hardware you are doing it on, and you know the scope of the problems and what tasks it could be broken down to, you have enough information to make a business decision to answer the question of when to do it. You need to look at the cost of implementing it and the benefit you get from doing it. And you need to look at the costs of not implementing it and the benefits of not implementing it.  If the effort is large and the benefit is small, it probably is not worth it.  If the cost is small but the benefit is big, it makes sense to do it.  But when the cost is big and the benefit is moderate, you need to decide on your own if it is worth while.  When the business decision says yes, or the business decision says no, that is the choice you should make for when to do it or not.

#5291217 How can I optimize Linux server for lowest latency game server?

Posted by frob on 11 May 2016 - 04:00 PM

1. include shot event data in periodical update packet for 5 times in a row(if he will not receive any of these packets, then screw him, he probably has ping way > 100 or unstable connection).

2. instead of using sendTCP for each shot event, use sendUDP but 2 or 3 times, to reduce the chance of packet loss.


Always resending a fixed time doesn't handle it.


Why 5 for the periodical update?   


Why "2 or 3" for sending an event?


If you chose five, what happens if a network disruption drops the next five packets and the sixth goes through?  Alternatively, if it goes through perfectly the first time, why resend four unnecessary times?  Same with events, why resend two or three times if once is enough, and why two or three if it might be the fourth time that goes through?


Why not 4? or 7? or 92?  Or why not just 1, since the vast majority of time UDP gets through perfectly?   Pulling numbers out of the ether does not help.


There is a known solution: Resend until acknowledged.


In the general case of networking the UDP packet will arrive quickly. Unless you have a particularly chatty interface, the data will arrive and the server will send a response back to you acknowledging it before your game needs to send another packet.  Most games accumulate data for a short time window then send it off.


Effectively this pattern implements a sliding window similar to what you get in TCP, except you are not using TCP's stop-until-resent functionality, you always resend until the other side says they've got it.  


If there is high latency or connectivity issue it may get sent multiple times before you hear back, but if the data is fairly small and you are on high speed networks the impact is minimal.  While it is important to consider size a few bytes doesn't hurt if the game has requirements for megabit connections.


In the general case for well-designed protocols there will be a full round trip with acknowledgement of the data all the time.

#5291190 Smooth Animation for Characters

Posted by frob on 11 May 2016 - 01:44 PM

 I am really having hard time to know if the animation can be smoothly generated as sprite.


Yes, it can.  Skilled animators are good at that type of work. Amateurs often struggle with it.


Any idea if this is part of the tweening or something?


There are many ways to implement it.  The post above shows one way of composing characters. It is script-heavy but can work well, where the animator has a collection of pieces that are rotated and translated by animation scripts.  It can be implemented as a sequence of fully-composed images, where each animation sequence is completely drawn by hand (or exported by a 3D modeling program and touched-up by hand) and images are played in order like a movie or flip-book.  It can be implemented sequences of rendered segments which are basically a mix of the two, many scripted segments that are animated and each segment has hand drawn sequences of clips.


There are also programs that automatically generate image tweens between multiple still images, but that probably is not what you are looking for in this example.

#5290984 About game design

Posted by frob on 10 May 2016 - 10:16 AM

If you draw or do art, and want to draw and do art on your computer, then a nice Wacom tablet will range anywhere from 'nice to have' to 'essential for your art'.  I work on illustrations and sketches in the computer I love having pressure sensitivity.  It is not as nice as my preferred medium (charcoal pencils or watercolor pencils) but those don't get entered automatically into the machine. 


If hand drawing is not your thing the tablet will be little more than a desk decoration.

#5290983 Browser strategy game server architecture (with pics)

Posted by frob on 10 May 2016 - 10:06 AM

The steps 1 & 2 seems chatty. The worlds online/offline changes rarely. Knowledge of connections should be independent of the login process, not a query every time someone loads a login page.


I don't understand why you want step 6. If the auth server says an account is authenticated with a token then the user is authenticated. No round-trip is required here; step 5 is effectively an unnecessary notice, step 6 is a reply to the notice. 


With that, it boils down to:

3) Client sends a request to the front-end machine for login.

4) Front-end sends request to back-end auth server

5) On success, back-end notifies a listener machine

6) ACK the notice

7) Back-end notifies front-end of authorization results.

8) Front-end notifies user of redirect location or error message

9) User uses token on redirect location.


From that, I would dump #5 and #6. Other servers don't need to be "told" like this.  As part of the handshaking for what would be step 10, client getting hooked in to world server, the world server should ask the auth server if the token is valid and store the result for the session.  (Other standard things should take place, auth tokens should expire after a short time and be replaced automatically, network boundaries should be enforced, likely your world servers are more complex than depicted, etc.)

#5290890 Will Unity or Unreal Engine 4 suit better for me?

Posted by frob on 09 May 2016 - 04:21 PM

The Liscense has a reference in it that you can contact them for custom liscensing, But I don't know at what point that would be viable.


If you are planning on spending more than around $10K on individual licenses, probably worth it to call them. The worst they will tell you is no deal, and it doesn't take much to ask.


But I agree, having to pay Unity/Epic is a good problem to have :)
Yes, their paid license model is more confident that way. It follows a "We only make money if you do, and we are betting you succeed" model.  But if you cross the threshold, it will feel like a painful check to cut.
Unity's model feels more like they don't expect you to win big. It follows an "If you find us useful pay us a fixed amount" model. If you cross the threshold you will breathe a sigh of relief that you're making a lot of money.
I remember there used to be a calculator somewhere but I'm not finding it, where you enter the expected number of developers involved since each needs a license and it tells you the cutoff for how much you need to make before one or the other is less expensive.  In either case you need to be regularly bringing in far more than most hobbyist developers ever will.

#5290888 Getting objects within a range (In order, fast)

Posted by frob on 09 May 2016 - 04:02 PM

When you go for optimizations the details are everything.


1. I have to do !toLoad.ContainsKey(distanceSq), which is using about 30% of my cpu, because you cannot enter a value multiple times into a dictionary. Is there a faster way to prevent repeats?
It depends on which of the Dictionary types you are using and the quality of the hash. If you expect to actually find a value TryGetValue is sometimes faster than ContainsKey, especially if you plan on using the object. 
Your example is a little strange to me since it appears you are using distance squared as a key in the dictionary. That is not a typical dictionary key.
2. Just adding to the dictionary gets laggy - it accounts for 40% of my cpu. I understand this is because of the amount of objects I'm loading.
No idea about the number of objects you are adding.  If you know how many items you will be adding you should set its capacity up front.  It sounds like you should know how many items you will be adding, or approximately so. Expanding the capacity means a ton of work for a hashed container, and it can potentially need to expand its capacity every time you add a new item.

#5290877 Localized subdivision

Posted by frob on 09 May 2016 - 03:01 PM

Subdividing a planet's surface has approximately nothing to do with an octree.  An octree is for volumes. Unless you are modeling the mantle and core of the planet, it is probably a bad fit.  


The surface of the planet can be generated as a surface mesh or height map or similar.



In games many people start out with huge ideas of "I want many full real-size worlds!"  Then realize that idea is extremely difficult.  Even games like WoW don't reach the content size of Earth.  A few seconds on Google says:


* Currently the WoW with all expansion packs is somewhere between 45-60 square miles.  


* Skyrim's actual navigable overworld is actually on the order of 15-20 square miles.


* Dragon Age Inquisition has two large kingdoms on the map and feels bigger than Skyrim, but is about the same 15-20 square miles of navigable space.


* GTA 5 is about 100 square miles but has a ton of dead space and repeated patterns throughout, it is not dense.



The games do a lot of lying to convince you the world is really a big world.  The biggest games have models that fit inside a real-world city.  Not that it is small, that is an enormous amount of content, but it should give you a sense of scale.  


Those are games where the budget is easier to measure in billions of dollars rather than millions. $0.25B, $0.31B, $0.26B, etc., and they produced under 100 square miles.  Earth has about 60 million square miles of land.


The biggest problems with world-sized games is trying to generate compelling content.

#5290825 Gamepads in Assembly

Posted by frob on 09 May 2016 - 10:46 AM

How do I use the USB hubs? Couldn't find a tutorial and my knowledge doesn't reach that far.


In assembly and you're writing an OS?


For how to write to the hardware, you use the various port instructions (in/out, ins/outs, insd/outsd) and writing to specific memory addresses.  If you are writing an OS in assembly those should be within your knowledge.  


You'll need to implement quite a lot of functionality to work with the devices, as they are implemented as plug and play interfaces.  You'll have a phase of scanning and detection, a phase of self-configuration, implementing all of that is going to be a bit of work.  You can look at how the Linux kernel and a few other open source systems do it, but they mostly used C for most of the heavy work and their own libraries for the CPU-specific blocks of assembly code for the lowest-level hardware access mentioned above.  Intel has documentation for that.


Once you're able to talk to the hardware, and you're able to run the plug-and-play configuration code, you'll need to communicate with the USB protocols.  It is packet based and works in a daisy-chain fashion where you (the OS implementer) will need to track the paths through to the devices and different devices have their own sub-protocols. At the least you'll need to implement the protocol for host, interconnect, and hub functionality, plus you'll need device function enumeration. The OSDev Wiki linked to above has many specific that can help there and F/OSS implementations can serve as reference.


Once you've finally got through to the USB device itself, and you've identified it as a HID gamepad device you are willing to support, you'll need to implement the protocol for that as well.  Again, the OS Wiki and existing F/OSS implementations can serve as reference.



What you describe is an enormous project. The only ones that have succeeded have required large public communities or well-funded corporations. Good luck on whatever you are attempting to achieve.