Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Aug 2010
Offline Last Active Jun 15 2016 10:47 AM

#5294850 Do I need to know Algorithms and Data Structures?

Posted by on 03 June 2016 - 01:57 PM

If you have lots of if statements that skips execution 99% of the time and you know some that will always be false then pre-buffering the positive and plausible ones can improve cache locality and avoid stalling hyper-threading with calculations that would otherwise be done and thrown away. Learning about broad phases is essential for both physics and game logic so that the games can scale up without lagging.

#5294691 implementation of neural network

Posted by on 02 June 2016 - 01:20 PM

Implementing genetic algorithms works excellent on the graphics card because you can try a million alternatives in each draw call and then iterate upon be best results.

Try to find a way to express data using an image and define steps of processing as image manipulations in read-paradigm.


For a single actor:

A pixel's color or location might represent a direction of some action.

Make a utility pass that gets the score of each action in a new image.

A laying 1D texture can look for the best result. Let the height be 1 if you use a 2D texture to represent it since padding is applied per row.

Read the 1D texture back to the CPU. (This will eat up 70% of your time unless you use DirectX 12 or Vulkan to run multiple things at the same time)

Do the last sweep on the CPU taking the best option and execute the action.


For multiple actors:

Each column can represent a unit and each row can represent a possible action.

The code to implement this will look a lot like spaghetti assembler code when fully optimized which is why I abandoned that strategy game when nothing more could be added.


I tried genetic algorithms on the GPU using DirectX and got really nice results but the shader compiler will fail 90% of the time when trying to do anything advanced like physical simulation because it was only tested for graphics.


Vulkan is still in Alpha stage with drivers missing but there you will be able to choose other compilers using SPIR-V intermediate code. What I don't like about Vulkan is that sampler states are connected to views and you have to create pipeline objects. Vulkan might win over DirectX 12 by simply supporting Windows 7 and phones.

#5294686 Building a game like "Game of War"

Posted by on 02 June 2016 - 01:03 PM

Everyone takes ideas or images from somewhere and changes it into their own. So yea. I can take images and change them and nobody would know.

I can look at anything and draw it and change it so it becomes my own. Art works is no problem.

So I can't use just unity? I'll need an art program like gimp? Someone earlier stated all I need is unity. :( I'm confused.

My game has no story. Lol. It doesn't need a story. Here is the story. U r on a map to build the most powerful kingdom. End of story.

Is network programming hard? I understand I have a year to get this game done. I need all the help I can get.

In simplicity. Step by step. Write down the game and mechanics and have a game name that's legal. Do the art work. Next is use gimp to create the art then transfer it to unity. Then use JavaScript to create the code and game mechanics. Then I need networking online for an mmo. Is this about right?
The hardest part to all of this will be learning how to use unity and javascript. I really only need to learn what I need to develope the game. I don't need all.

Would anyone be interested in helping to build the game? As far as advertising. Key words are 65% then 35% word of mouth. I'm not worried about the game being popular. I based my facts on realistic facts and what people like. :)


Everyone who reads your post knows. I would never steal artwork.

#5294684 Switching from C++ to Java

Posted by on 02 June 2016 - 12:49 PM

In a university you will learn the basics of functions, subroutines, lists, sorting, recursion, hashing and tree structures before diving into object orientation since there are many things that can go wrong with inheritance if you start to inherit something as soon as you want to reuse its code. I dislike using classes in C++ because abstraction without memory protection can make it harder to see why the application is crashing while a plain C subset would make it obvious but that might be because I learned C before C++.


For learning programming, Java would make it a lot more difficult to practice functional programming because Java outlaws global functions which is very annoying for functional purists and modular programmers. You might have a course in the first year where you have to write an operating system kernel without using dynamic memory allocation.

#5294677 New fast way to loop!

Posted by on 02 June 2016 - 12:07 PM

If b is written to without being used then a good compiler will cheat and only execute the last iteration of the loop as the first iterations are dead code.


If modified to read the previous result then, the Hexagon compiler for Snapdragon's aDSP would divide the loop into start, multi instruction machine words and termination to run 4 iterations in the same machine instruction with a zero cost hardware loop.

#5233554 Game in pure C99

Posted by on 08 June 2015 - 10:56 AM

I need a framework for my own programming language so that I can test it with real interfaces but haven't found anything for over a year now.

Is there any graphical C99 code sample based entirely on the Windows API and DirectX without any static linking?


I tried to integrate parts of SDL but can't take out one thing without pulling out the whole framework.

#5190542 Quick question about basic lighting

Posted by on 01 November 2014 - 06:14 AM

The normals are linearly interpolated from vertex to pixel so you have to normalize the normals in each pixel or have results close to vertex light. If you have smoothing on an edgy object then vertex light will only produce light spots on the vertices.

#5187713 2D Physics/Game Engine For Massive Environment

Posted by on 17 October 2014 - 02:24 PM

If performance is not an issue, you could use the Bullet engine and lock the position to a plane and rotation to an axis.
Bullet has optional 64-bit precision, continuous collision detection and don't require dynamic linking.

If you end up making your own engine anyway, the trick is to apply some of the force directly to the position to simulate how the velocity is converted into heat and then measure the difference between the stored velocity and displayed velocity to stop items from rotating by themself.

#5128120 Renderqueue / shader system design question

Posted by on 02 February 2014 - 03:45 AM

I only sort by instances since anything advanced will just move the bottleneck to the CPU.


I use one opaque/alpha flag for the whole model and design with separate instances. This is not a problem since it is mostly particles and breakable windows that use alpha filtering.


I once tried removing the code that changed textures and the framerate did not change at all.

#5127959 AreaLight : Rectangle

Posted by on 01 February 2014 - 10:25 AM

I don't see any multiplication with NdotL in the light intensity.

#5125824 Database modeling

Posted by on 23 January 2014 - 03:43 AM

I discovered that higher normal forms on tables that I use to represent things in games reduce code complexity by up to 80% in safe languages. Instead of having 3 loops nested in each other, I have one loop over a list targeting child objects with many different parent objects in other tables.

#5120716 Shader Management for Lighting?

Posted by on 02 January 2014 - 10:46 AM


In DirectX, I pasted some generic light sampling functions at the top of each shader before compiling them.


Pasted as in you paste in on every shader files, or you have some sort of a function that contains light texts in strings and combine it with every shader files to be linked during the first load?

I haven't got into shadow mapping yet, but thank you for your extra information, I'm pretty sure I'm getting there after this.



Pasted as text into every shader that is used for materials. I made it fast by saving pre-compiled shaders with check sums that tell if the shader has changed since the last compilation. The hard thing was to maintain backward compability without bloating the code to insert so try to have a powerful interface from the start that is compatible with, amibient, diffuse and specular light for solid, thin and fog materials. Fog will sample the light without caring much about the direction of the light. Thin materials like fabric will sample the light on 2 sides of the surface. I did not implement anisotropic light but think about how you can implement it later on top of the old interface just in case.


For sampling the depth maps, I sampled with both bilinear interpolation and the percentage closer method. I took the maximum intensity of both to remove acne from the percentage closer method. The depth bias was calculated dynamically, based on depth map resolution and dimensions of the light source. For a spot light, the bias must be multiplied by the depth (not distance) from the light source.

#5120700 Shader Management for Lighting?

Posted by on 02 January 2014 - 09:42 AM

In DirectX, I pasted some generic light sampling functions at the top of each shader before compiling them. An array from the CPU stored up to 64 light sources that passed the culling test. Having more lights than that would be too slow to render anyway. They same thing should be possible in OpenGL and works without dynamic shader linking.


For depth based shadow mapping, I made a 2D allocation argorithm that is 100% free from fragmentation because the only way to free an allocation is to free every light source. Start with a whole square in bucket 0 and let the remaining buckets be empty. Each bucket can at most have 4 unallocated slots and that is only right before one of them is use or divided again. When there is no unused square of the right resolution, divide a larger square until you have something. The only case where you can't get more memory is when the total amount of pixels is not enough because no matter how many smaller sizes that use 3/4, their sum is always smaller than one larger square.


#5066193 Starting C#

Posted by on 30 May 2013 - 11:45 AM

I would stay away from any book that present any paradigm as a "silver bullet" since all programming paradigms have their advantages and pitfalls in different situations.

Functional programming is good for testability and GPU acceleration.

Data driven programming is good when the major bottle neck is loading lots of memory.

Object orientated programming is good when there is a clear one to one mapping between data and methods or you want safe polymorphism.

Relational programming is good when many objects share the same methods or you want persistence with a database.

#5060519 Entity state and animation

Posted by on 09 May 2013 - 03:53 AM

My engine's SDK show how to make procedural bone animation from math so that jumping forward and landing sideway cause the character to sidestep when landing to keep balance. "BoneAnimation" is the simpler example and "GiantMaze" allow colliding with things. Previously I tried following the laws of physics with ragdolls that fall to the ground like drunk people but even with a perfect balance system you would still have to break the natural laws with air acceleration to make it fun to play.