Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Jul 2010
Offline Last Active Jul 27 2016 05:18 AM

#5296604 Batching draws - keeping buffers up to date

Posted by bwhiting on 15 June 2016 - 04:11 AM

I really like this question (or set of questions) as it presents a large number of the issues developers in your position face.

From my experience if you are already on the right track, you identified a large bottleneck and improved it.


What you need to avoid it trying to catch/handle every situation in the most efficient way - this can often end up worse! I recommend an approach that doesn't try to solve all of the issues but just the main ones. Often enough the performance of such a solution is plenty good enough for most applications.


If you are optimising your engine for this game and this game alone things might be different, but suppose you want to use the engine for a future game one that has more transparent objects, or transparent objects completely mixed in with opaque ones all over the place? Then a seemingly good solution might end up being a bad one.


In terms of over complexity avoiding you could start with very simple dirty flags for things like children changed or not, rather that trying to work out which exact child was removed or added it might be easier just to know IF one was added or removed and respond accordingly, hope that makes some kind of sense.


You will have to make those calls though based on your needs.


That said some kind of double buffer might work for handling changes (or lack thereof) well i.e. for each frame swap buffers and copy large chunks from the last one where possible when no changes occur otherwise just write in the new data.

Just remember that blasting through more linear data can often be faster than jumping around all over the place trying to avoid unnecessary work due to cache misses anyway.


Look forward to seeing other replies in here :)


#5292247 Starfield with 3D points: ideas on how to create light effect around the star...

Posted by bwhiting on 18 May 2016 - 04:46 AM

Some kind of bloom effect would probably help get nearer what you want.

I think if you did that coupled with a fractal noise you could be well on the way.


So use a down-sampled version of the image to blur it based on light intensity, then overlay that onto the original image. I would also use that blur texture as a alpha map for some kind of noise (such as fractal) to get that "cloudy" look. Depending on how you built the initial image you may need to think about how a noise texture might swim as the camera moves and you will need to fix that, i.e. maybe sample a cube map there, just guessing at this point :D

#5275908 instancing with multiple meshes

Posted by bwhiting on 16 February 2016 - 07:56 AM

You can do all the VS-based custom vertex pulling trickery on the D3D9/GL2 APIs, by storing your vertex data in a floating point texture instead of a buffer ;)

Before you bother though, first make sure that you actually do need to dramatically optimise your CPU-side GL/D3D time per frame.


Ahh sneaky, and just move texture lookup locations to point to the correct "mesh".

I doubt it will make it into any sort of production, but I like to find alternatives and put them though their paces, better the devil you know ey

#5275898 instancing with multiple meshes

Posted by bwhiting on 16 February 2016 - 05:38 AM

Thanks guys! Looks like it was as expected, possible - but requiring modern apis. Which is a shame as I am limited to older ones but at least I was along the right track :-D


Will experiment with passing in ids in a buffer and degenerating triangles. I have a feeling it might still be a faster approach than the additional draw calls.

#5234882 Game Development Help Please (language choice)

Posted by bwhiting on 15 June 2015 - 07:42 AM

HTML5 etc....
But for some insane reason they built the game you linked to in flash - very odd considering you can do all that with js, css and html no probs.

Someone should probably let the devs know they made a mistake!


In all seriousness though; while web technologies allow you to create games like that, there are still a host of reasons you might not want to use them and would be better of with something else.


If the web is your target then html might well be the way to go, if is isn't then don't limit yourself by choosing it.

#5233112 AS3 platformer, making a TileMap scroll.

Posted by bwhiting on 06 June 2015 - 04:28 AM

@Wyrframe, massive points to you for the big effort you are putting in helping out on this one. Folks like you are what make communities like this what they are!

Forums were a big help with my learning many many moons ago so I think it is so important to keep up the tradition of helping people when you can!

#5229810 Virtual Multiple Viewports with Render to Texture (CryEngine 3)

Posted by bwhiting on 19 May 2015 - 07:38 AM

I have not used cryengine 3 but I can't imagine that they don't support render to texture - if they don't that is a real shame, because it makes your task a great deal harder... can't even think how you would do it without it.

#5229781 Communication between objects and systems in Game engines.

Posted by bwhiting on 19 May 2015 - 03:39 AM

you could just create something that manages that task separately, like a player collision manager.

that gets access to the player and the scene and takes care of all the logic it needs inside of its own update function.


This way the player stays cleaner as does the engine code.

Plus it gets easier to maintain, say if you wanted to change from a raycast to an ellipsoid collision detection.

It doesn't work for every situation but it keeps things tidy and easy to tweak.
If you only need something really simple you could just do a single raycast and player update in the main update function, should only be a few lines of code.. but then that approach can get messy quickly as things get more complex.


All that said there are many many ways to skin a cat :)

#5219283 Skeletal animation issues

Posted by bwhiting on 26 March 2015 - 05:21 AM

I am working on something similar at the moment and what I did was to render things on on the cpu as an overlay showing the positions of each of the transformed nodes to ensure they all line up properly visually.


It is pretty easy to do and very useful for debugging, essential you draw a line from each transform to it's parent if it has one, that way you can start to isolate where the issue is as with skinning there are many points of failure, from the shaders to the interpolation to the correct hierarchies.


Also for testing I made a simple 3 bone test shape and also exported the bone geometry - so much easier to debug when you are dealing with a simple 3 bone 2 parent system :D


Best of luck!!

#5218528 Programmatic Pixel Art

Posted by bwhiting on 23 March 2015 - 11:53 AM

Sure it would work, and you could indeed build something like that for fun.

But when you want to add colour, and have larger images it is going to be severely limiting.

Drawing images will always be so much faster with image editing software than editing text... and if  you wrote a converter (image->text) well then it is self defeating as the image will generally compress much smaller/faster and be faster to decode.

If you used a raw array of data then you could just use a memcopy to create an image, and that would be fast - but might not worth the effort to geneate the code anyway in the first place, as it would no doubt take up more space.


That said... I have done this exact kinda thing before in a tiny console utility, I cached the bitmap data for the characters 0-9 in 10 unsigned integers in an array.
the first 24 bits described the character's shape (4x6 grid) and then the other bits can be used to store metadata such as the characters width in pixels.


This enabled me to blit numbers to a bitmap very quickly with very little data - just 1 uint to describe the pixels of a character :D

#5216813 Best Language to Program a Facebook game in?

Posted by bwhiting on 16 March 2015 - 03:58 AM

Erm I have no idea why everyone thinks flash is dead  or slow here, it works fine on desktops and will work fine on devices too if you want (just export with same code using air).


For quite some time flash has been the go to tech for facebook games - this is not without reason.

It also supports vector graphics and has better 3d support through stage3d than html does at the moment.


"There is literally nothing that Flash can do that HTML5 cannot" well not quite literally rolleyes.gif 

Animated optimized vector graphics, compressed source, compiled source (not so easy for someone to just change your in game values), compressed pngs, easy use of fonts, anti aliasing, smoothing bitmaps, blend modes, code hinting, solid performance analysis tools, 1 click deploy to web, android or ios without any extras needed, sub pixel positioning, DRM support, fullscreen support that doesn't crash all the time, easy binary manipulation, works in very old browsers (no need to write your own array.indexOf implementation...), same across browsers, rapid prototyping using flash ide.... am sure there are more too.


Not to mention you can avoid js - always a bonus.


Performance with flash is not a problem for any decent developer. No browser is going to outright stop supporting flash anytime soon either.

Even if you build it in flash first, then port it down the line if you have to that might be a better idea, as you will have a working game build faster already.


Just to clarify, I write games in flash, js and unity - and when it comes to facebook games like the op wants- flash is the better/faster option.

#5214495 Bitmap graphics pixels scanning

Posted by bwhiting on 04 March 2015 - 09:23 AM

Ah it was more for an example of the result not really the implementation, there is much more going on there than you need to be interested in.

Take a look here:


or here:


and choose the convolution filter and plug in the numbers from the first link

or here for some code in js you can easily port to java:


#5214183 Bitmap graphics pixels scanning

Posted by bwhiting on 03 March 2015 - 06:24 AM

dammit, wrote you a long reply and accidentally closed the tab and lost it :(


in summary you made a good start but with a flawed approach, hard coded values won't work well given the unpredictability of the users lighting conditions.


You are better of using a edge/feature detection type solution. The idea being to compare each pixel against its surroundings and extract its contrast from that.

i.e sample some neighbouring pixels and compare luminance against those.


Take a look at some common convolution filters for some ideas.

Here is an example I made where I run them on the gpu:


#5203866 Weird framerate drop

Posted by bwhiting on 13 January 2015 - 03:22 AM

Just to echo Sean, who is probably right with regards to the cause of your issues, when writing games in languages like Java, object pools are your friend! The stop the GC having to do much work at all while your game is running.


Just have a look through your game code an if you are seeing any "new Vector2D, new GameObject, new Texture2D, or anything like that then you are already wasting CPU.


At the start of a level (or earlier) you can just create pools of these objects and then get them from your pool when you need them and put them back when you are done. The code for these are really easy to do and the impact they create in memory managed languages can be huge.



//in game loop somewhere

GameObject badGuy = GameObjectPool.getGameObject();   //new GameObject();

//later on

GameObjectPool.returnGameObject(badGuy);    //badGuy = null;


Your aim should be as close to zero allocations during game-play as possible - reuse the living crap out of everything you can.

#5202830 Programming a Level Editor

Posted by bwhiting on 08 January 2015 - 08:12 AM



There is a little video of a "simple" level editor that the guys made for overgrowth, it is pretty neat - very few features but enough to start building levels with.

The bare minimum is a load/save level function, a load object function, and move/rotate/scale functions.

After that you can expand into material editing but in reality you can do that in the code initially easy enough.