- Wildfire Games Community Forums
- → Highest Reputation Content
Highest Reputation Content
#252249 Video Editor - Brynn
Posted
BrynnOfCastlegate
on 08 October 2012 - 06:15 PM
Let me know if you like it!
--Brynn
#261266 0 A.D. Development Report #10
Posted
plumo
on 20 January 2013 - 09:54 PM
Wildfire Games, the international group of volunteers developing 0 A.D., are happy to present this week's 0 A.D. development report.
If you want to find out more about the development of this open-source, cross-platform real-time strategy game or if you are interested in game development in general, it might be an interesting read.
If you want to be part of this project, we urge you to post your application in our forums. We are currently looking for Gameplay, AI, Sound and Graphics Programmers along with Animators and 3D & texture artists. You prefer to do something else than programming or drawing? Luckily for your portfolio we are also looking for a Sound Lead, Video Editors, a Documentation Manager and Scenario Designers. Still no luck? Head to our forums and join our active community!
!!! We are in need of (skilled) programmers. Are you one of them? Redirect yourself to this thread. Your contributions are crucial !!!
Screenshot of the

The Mauryan Indians will make their spectacular debut in 2013! Stay tuned.
Art & Programming & Sound
historic_bruno committed a plethora of fixes! He updated libpng to v1.5.13, fixed multilined text alignment and added a link in-game to the manual. This is only the tip of the iceberg though. For a full list of code revisions check this link. Or maybe it was this one.
stwf has been working on a complete rewrite of the sound manager. This ought to fix bugs and remove memory leaks in the code.
Pureon has finished work on the 'Crannog' building and he has also made new technology, unit and building icons. He has also finished the Mauryan houses (which are a treat!). Check for yourself in the monthly screenshot!
Mythos_Ruler also worked on the Mauryan Indians, adding new textures and portraits, among with some general balance work.
Enrique finished work on a couple of Mauryan buildings, notably the temple and the stables. Can you spot them in the screenshot (see above)?
quantumstate updated the technology code (making it much cleaner), among many other bug fixes. He has applied Kingadami's patches for adding an fps counter to the game setup and right click selection removal.
leper implemented some patches (by supertesters zoot , mimo and kingadami), stopping formation members from sliding, among many other fixes and small new features.
Gen.Kenobi added fireworks! Yes, ... fireworks. But he also got enrolled in medical school, so yay, FIREWORKS!
Spahbod fixed some major random map bugs, including the notorious "chicken problem". Doesn't ring a bell? Consider yourself lucky!
Yves is working on a javascript debugger. As we are using javascript for many things, this tool will come in very handy. K776 is working on the web-GUI for the debugger.
Last but not least we ought to thank Lordgood for his amazing design sketches for the Mauryan Indians.
See you in a couple of weeks with the latest development news!
#263968 Hero Portraits!
Posted
JustinOperable
on 05 March 2013 - 06:25 AM
A while back I offered to do some portraits for the game units but was unhappy with my portraiture at the time. I have since remedied that dissatisfaction and so i'm back to paint some heroes. First is hannibal, second is ashoka the great. They're rough works in progress and their costumes are left vague for now so people have a chance to throw reference at me before I waste time rendering something inaccurate. I intend to do a portrait for each faction then move into whatever appeals. Let me know what you think.
#266077 modern warfare reaches 0 A.D.
Posted
Ilves
on 30 March 2013 - 08:59 PM
this time let's have a swim. I really adore what the creators of Pyrogenesis did with water and how many options it has. It was fun just playing with all those settings available o_O
Man, I really can't stop enjoying the sexiness of this water. Just give me turrets and I'll be in love.
#268049 User Interface concepts
Posted
Pureon
on 21 April 2013 - 04:00 PM
I've started working on a concept for our user interfaces and will showcase some of the new layouts below.
Here are some windows using the existing UI theme:



**** Work in Progress warning ****
Here are the windows using the new UI theme:



On flat white and black backgrounds:

Thoughts: I focused on making the design more modern, clean, and legible. The thick gold frames are gone, being replaced by a solid top frame with an optional title area, and a lower 'weight' frame to hold it in place. This somewhat resembles the structure of a Roman Standard flag. I'm using a temporary background pattern texture that comes with Adobe Photoshop for now just to quicken the design process, but this will be replaced with a compliant texture.
That's it for now.
Hope you guys like it!
#269782 FreeType - TTF fonts in OpenGL
Posted
RedFox
on 05 June 2013 - 11:49 PM
- Texture fonts aren't scalable (you need to generate fixed sizes).
- No dynamic font stroke, outlines or drop-shadow effects (unless baked into the texture).
- No wide Unicode support (cyrillic, greek, extended latin, arabic, etc.).
- Small text is quite hard to read (no font hinting).
1. Old bitmap fonts
The old bitmap-font system in 0 A.D. is very simple, yet limited. A bitmap font is usually generated with an external tool and contains glyph information (*.fnt) and the bitmap (*.png). To illustrate, here is the current 0 A.D. 'Serif 12px' bitmap:

You can immediately notice that most characters looks somewhat pixelated and dirty, making some characters pretty hard to read. This is mostly due to imperfect anti-aliasing for small scale fonts and no font hinting.
Adding new fonts is especially difficult, since you need to generate font bitmaps for any variation you want. Say you wish to have Arial text in sizes 10, 12 and 14; you also might want regular, italic, bold, bolditalic styles. You also might want to have a regular, stroked and drop-shadow variant.
If you had to generate all these bitmap fonts, you'd quickly have [sizevariants] * [stylevariants] * [fxvariants] font variants. In this case it might be 3 * 4 * 3 = 36 variants. So now adding a new font into the game with all the features you want turns out to be a real hassle since you need to generate so many variants that its crazy. Running tests to find your 'favorite' font and style combination quickly becomes pretty much impossible. Once you've generated your Arial variants, you'll just be glad its over.
Furthermore, if 0 A.D. ever wishes to become a fully localized / multi-lingual game, at least partial unicode support is required to draw cyrillic, greek, extended latin, arabic, etc. glyphs. Can you imagine generating bitmap fonts for such a broad variety of languages? Add 6 different codepage support and you'll be looking at 36*6 = 216 bitmap fonts.
Currently 0 A.D. bitmap fonts range from plain ASCII and Latin1 up to Latin Extended-A, which basically just covers most western characters. If you wanted to add support for Greek characters, you'd need to either regenerate all fonts to add the glyphs you need, or you'll have to create a separate bitmap for just Greek characters. That would be like reinventing codepages.
2. TrueType and FreeType
A few decades ago this problem was addressed by designing a vector-based font format, which we now know as TrueType. I'll spare you the details, but the gist of it is to use vector outlines to describe all the style variants for every glyph in the font.
There are only two issues here: 1) Getting a font that supports all the glyphs you need. 2) Reading these complex font files and turn them into an image.
First is easily solved, the web is full of TrueType fonts: http://www.fontsquirrel.com/
Second is a lot harder, but luckily enough, we have the FreeType library: http://www.freetype.org/
Still though, Freetype isn't designed to be a full-fledged text displaying engine. All it does for us is a specific glyph image and some sub-pixel data to position it correctly.

The rest is all up to us. We have to actually do the hard thing and get all this data through OpenGL 3.1 and onto the screen.
Note: Due to some specific design decision, using an existing library like freetype-gl was out of the question and as we can see later, the end result is better optimized to our needs.
3. Runtime texture atlas
This is exactly like bitmap fonts, with one major difference - we generate the texture atlas during runtime to suit our needs. If we need an emboldened font, we'll only generate that and be done with it.
The first step is to generate the basic ASCII subset, which is [0..127] inclusive, which is actually easy enough to do. We use a very basic shelf-styled packing method to create an 8-bit RED channel bitmap with just the size we need. The only requirement set by OpenGL is to align image width to 4-byte boundary.
We use a neat font called 'Anonymous Pro' - a monospace font that looks perfect for lots of text:

Using freetype library, some programming hocus-pocus and the simplest shelf-packing algorithm, we get a neat 1-channel bitmap for our 'Anonymous Pro 12px':

Can you notice the extra clarity compared to the 'Serif 12px' texture font? If you zoom in really close, you'll actually notice that the characters are neatly anti-aliased and also somewhat distorted. This is because 'auto-hinting' was enabled in order to make the small font look sharp and clear - making it a lot easier to read at smaller sizes.
4. Glyphs
We also need to store information about every character - or glyph in the atlas, otherwise we wouldn't know how to display it:
struct Glyph
{
ushort code; // unicode value
ushort index; // freetype glyph index
byte width; // width of the glyph in pixels
byte height; // height of the glyph in pixels
byte advance; // number of pixels to advance on x axis
char bearingX; // x offset of top-left corner from x axis
char bearingY; // y offset of top-left corner from y axis
byte textureX; // x pixel coord of the bitmap's bottom-left corner
ushort textureY;// y pixel coord of the bitmap's bottom-left corner
};
Since we could have a lot of these glyphs (several thousand in fact), it's in our (and L2 cache) best interest to keep them small. In this case, each glyph has been optimized to be exactly 12 bytes in size and keep all the needed information to render and place a glyph.To make glyph lookup faster, they are placed in a vector and sorted by the unicode character value. Each lookup is done with binary-search, which keeps it consistent and very fast. We should also remember that OpenGL textures are bottom-up, so pixel 0 would be the bottom-most and pixel N the topmost.
5. OpenGL 3.1 and a custom Text Shader
Now that we have everything we need, we actually have to display the glyphs on the screen. In OpenGL, everything is displayed by using Triangles and the same applies to this case. With some additional testing, I found that using a single Vertex Buffer Object with 6 vertices per glyph is the fastest and most memory efficient version. This is mostly due to the small size of the Vertex2D structure:
struct Vertex2D
{
float x, y; // position.xy
float u, v; // coord.uv
};
The generated glyph Quad itself looks something like this:
The simplest fragment shader to display our text in any color:
#version 140 // OpenGL 3.1
varying vec2 vCoord; // vertex texture coordinates
uniform sampler2D diffuseTex; // alpha mapped texture
uniform vec4 diffuseColor; // actual color for this text
void main(void)
{
// multiply alpha with the font texture value
gl_FragColor = vec4(diffuseColor.rgb, texture2D(diffuseTex, vCoord).r * diffuseColor.a);
}
Which basically gives our Quad a color of diffuseColor.rgb and makes it transparent by using the font-atlas texture.Once displayed on the screen, both filled and wireframe views of the same text:

Great! We now have a neat mono-space font perfect for displaying readable text.
6. Freetype
If we dig through some Freetype documentation, we will notice that the library also supports:
- Glyph stroke - Will give a neat outline to our fonts
- Glyph outline - You can just render an outline of a character.
- Glyph emboldening - You won't need a 'bold' font.
- Glyph slanting - You can generate italic text on the go.
- Auto-hinting - Makes small text more readable (http://en.wikipedia....ki/Font_hinting)
Stroke effect (48px white font + 3px black stroke):

Outline effect (48px white font + 1.5px outline):

Shadow effect (48px white font + 2px black shadow):

7. Magic of Stroke and Shadows
The stroke and shadow effect can have their own Outline color, in order to achieve this, we actually need to use another channel - Green. So for stroked and shadowed text a 2-channel Red-Green texture is generated instead of a 1-channel Red.
The best way is just to show the generated Red-Green texture:

You can see how powerful this sort glyph imaging is, since you can combine any kind of Diffuse and Outline colors to create your text effects. Best of all, fonts that don't use this effect still use a single 1-channel Red bitmap.
Even though the glyphs look really sharp and anti-aliased, they can be made blurry by just lowering the Outline alpha.
The shader used to combine this effect and work consistently for both 1-channel and 2-channel bitmaps, looks like this:
#version 140 // OpenGL 3.1
varying vec2 vCoord; // vertex texture coordinates
uniform sampler2D diffuseTex; // alpha mapped texture
uniform vec4 diffuseColor; // actual color for this text
uniform vec4 outlineColor; // outline (or shadow) color for the text
void main(void)
{
vec2 tex = texture2D(diffuseTex, vCoord).rg;
// color consists of the (diffuse color * main alpha) + (background color * outline alpha)
vec3 color = (diffuseColor.rgb * tex.r) + (outlineColor.rgb * tex.g);
// make the main alpha more pronounced, makes small text sharper
tex.r = clamp(tex.r * 2.0, 0.0, 1.0);
// alpha is the sum of main alpha and outline alpha
// main alpha is main font color alpha
// outline alpha is the stroke or shadow alpha
float mainAlpha = tex.r * diffuseColor.a;
float outlineAlpha = tex.g * outlineColor.a * diffuseColor.a;
gl_FragColor = vec4(color, mainAlpha + outlineAlpha);
}
It looks a bit more complex, but the idea is simple: combine R and Diffuse, combine G and Outline, add them together.8. Going Unicode
Now it's nice that we could achieve all this with plain ASCII, but we still haven't touched Unicode. The main reason it's so hard to support Unicode, is because there are thousands of combinations of different glyphs. It's impossible to generate all of them into a single texture - you'll easily overflow the 16384px limitation of OpenGL textures. Worst of all, even if you generate all of them, you'll probably only use 5% of them.
This is also something that freetype-gl is bad at. It's only useful for generatic a limited subset of glyphs into a single texture. If you want to support unicode, you'll go crazy with such a system.
To be honest, I also had to scratch my head quite a bit on how to solve this. If I were to use regular texture coordinates [0.0 - 1.0] on the glyph quads, they would immediatelly break if I resized the font-atlas texture. So using any conventional means pretty much flies out of the window.
The solution is pretty obvious, I have to use pixel values for the texture coordinates and generate the actual texture coordinates in the Vertex Shader. Now if I add glyphs to the end of the texture, thus resizing it, I won't break any glyph coordinates. The Vertex Shader:
#version 140 // OpenGL 3.1
attribute vec4 vertex; // vertex position[xy] and texture coord[zw]
uniform mat4 transform; // transformation matrix; also contains the depth information
uniform sampler2D diffuseTex; // alpha mapped texture
varying vec2 vCoord; // out vertex texture coord for frag
void main(void)
{
// we only need xy here, since the projection is trusted to be
// orthographic. Any depth information is encoded in the transformation
// matrix itself. This helps to minimize the bandwidth.
gl_Position = transform * vec4(vertex.xy, 0.0, 1.0);
// since texture coordinates are in pixel values, we'll need to
// generate usable UV's on-the-go
// send the texture coordinates to the fragment shader:
vCoord = vertex.zw / textureSize(diffuseTex, 0);
}
The code for generating text looks like this:
Font* font = new Font();
font->LoadFile("fonts/veronascript.ttf", 48, FONT_STROKE, 3.0f);
VertexBuffer* text = new VertexBuffer();
font->GenerateStaticText(text, L"VeronaScript");
If I were to include any unicode characters like õäöü, the font atlas would automatically generate the glyphs on-demand and add them into the atlas.font->GenerateStaticText(text, L"Unicode õäöü");
Here's a simple before-after comparison:

With this neat feature, we can support the entire unicode range, as long as the entire range isn't in actual use. If the texture size reaches its limit of 16384px, no more glyphs are generated and all subsequent glyphs will be displayed using the 'invalid glyph'.
9. Addendum
In the first paragraph, four problems of current 0 A.D. texture fonts were raised. Now we have provided solutions to all of them:
- Freetype allows dynamic font scaling.
- Freetype provides dynamic font effects (stroke, outline, embolden, italic).
- Unicode support depends on the .ttf font. The provided method ensures reasonable unicode support.
- Freetype provides auto-hinting, which drastically improves small text readability.
Regarding performance:
Even with large volumes of text, there was no noticeable performance hit. Volumes of text that are all in a single Vertex Buffer Object especially benefit from very fast render times. The more text you can send to the GPU in a single VBO, the faster the rendering should be in theory.
What's still left to do:
- Implement embolden, slanting, underline, strikethrough.
- Improve the naive shelf-packing algorithm to achieve better texture space usage. (performance)
- Improve font-face loading to share between font-atlases. (performance)
- Buffer all static text into a single Vertex Buffer Object, render by offset into buffer. (performance)
- Implement this beast into 0 A.D.
I hope you liked this little introspect into the world of real-time text rendering.


Regards,
- RedFox
About Jorma Rebane aka 'RedFox': Jorma is a 22-year old Real-Time Systems programmer, studies Computer Engineering at Universitas Tartuensis and enjoys anything tech related. His weapon of choice is C++.
#270170 Hawk
Posted
Micket
on 16 June 2013 - 09:50 PM
http://www.flickr.co...shi/6580254701/
http://www.flickr.co...shi/5488404797/
Edit: Aw crap. He had NC on those photos.
Edit2: I sent him an email asking if he would consider dropping NC on those two photos.
#238611 Suggestion: search and destroy option and scouting options, and upnp.
Posted
fcxSanya
on 23 April 2012 - 05:20 AM
quantumstate, on 22 April 2012 - 09:37 PM, said:
#238952 Suggestion Floods
Posted
quantumstate
on 29 April 2012 - 05:50 PM
#260584 Wonders, Special Buildings, and Special Projects
Posted
LordGood
on 12 January 2013 - 05:40 PM
I modeled all of the basic structures,
Civ centre
4 house variations
mill
farmstead
temple
barracks
3 defensive tower variations
walls
gate
new palisade and outpost variation for desert cultures
market
dock
and fortress
which leaves revision, remodelling and whatever special buildings we've got that we haven't already given to the Macedonians
#264592 ===[TASK]=== Mauryan War Elephant (and hero elephant)
Posted
Zaggy1024
on 11 March 2013 - 03:09 AM

*stomp*
#269788 Oryx (Beisa)
Posted
Micket
on 06 June 2013 - 09:45 AM
Modeling an Oryx. It's a big to high poly this time, (currently 850 triangles).
I was aiming for 700, like specified in the art document, but there is plenty of regions that could be simplified, but I figured I'd finish this model first before tweaking it for 0AD
I've been rigging it up to see how it looks (but it's not quite finished). Here is a sample
#270137 Partridge (chukar)
Posted
Micket
on 16 June 2013 - 03:09 PM
Felt like doing a quick one.
Based on this image for shape and texture:
http://en.wikipedia....-chukar-001.jpg
Attached Files
-
partridge.zip 72.55K
3 downloads
#237539 Post your cities!
Posted
Mythos_Ruler
on 07 April 2012 - 05:02 AM
EDIT: I just thought of a feature. It would be cool to be able to pause a single player custom map, then export it as its own custom map to be open-able in Atlas. Or maybe to just be able to open saved games in Atlas.
#237952 Ticket for in-game tutorial
Posted
FeXoR
on 13 April 2012 - 12:06 PM
#239220 Post-processing effects test (SSAO/HDR/Bloom)
Posted
myconid
on 06 May 2012 - 04:35 AM
I've been coding some very rough GLSL post-processing tests just to see what they'd look like in 0ad, and thought I might share some results. The following images are in pairs, with the "plain" images first and the filtered images after: http://imgur.com/a/zZe2L
These images use SSAO, HDR and Bloom filters. The dark halos around the character models are due to the SSAO, which otherwise looks pretty decent.
Credit where it's due: the shaders are modified versions of the fantastic work of user martinsh on the Blender Artists forums.
Peace
Myc
- Wildfire Games Community Forums
- → Highest Reputation Content
- IMPORTANT! Please read before posting!





