UDK and Unity restrictions

I have recently downloaded the UDK which includes the entire project of the famous Epic Citadel demo. I have spent quite some time studying this project and the Epic Citadel demo and I would like to make some comments:

  1. Conversely to what has been said several times on the forum, Epic Citadel does not only use baked normal maps. Several elements of the demo use very complex shaders with multiple texture maps:
    a. Most of the ground and walls use parallax mapping shaders, sometimes simultaneously with the normal map baked in the lightmap but not always.
    b. The monk statue in the church use a very complex environment bumpmap shader with at least 4 textures: diffuse map + normal map + env map + glossiness map
    c. The torrent uses a very complex shader with uv scrolling, a texture mask, normal mapping and a vertex color mask, with at least 4 textures: diffuse map of the rocks under and above water + mask + normal map + water surface map

  2. The Unreal Engine is of course totally different from Unity3D and Epic makes use of occlusion culling and LOD to optimize the rendering performances. But still, Epic Citadel intensively uses techniques that are pointed as REALLY REALLY BAD by Unity, especially on iPhone:
    a. No texture atlases: instead of packing textures, Epic Citadel uses dozens of individual tiling textures. And those textures are huge: 1024x1024 for most of them.
    b. Lots of drawcalls: Epic Citadel is constituted of a great number of separate objects with many of them simultaneously on screen. Each of them can have any number of different shaders, often 4 or more. These objects (in the highest LOD) are very detailed.
    c. Lots of transparent faces: Epic Citadel uses lots of transparent faces for the trees and vegetation (for example each leaf of each ivy plant is an individual quad). These objects have high resolution diffuse and opacity maps.
    The sea is done with two huge big triangles and a tiling semi transparent texture. These alpha blended triangles cover half the screen surface.
    The reflective floor of the church is done with the classic trick of mirroring the church model and using a semi transparent shader for the floor tiles. Thus a large portion of the screen is filled with alpha blended triangles.

Someone could object that Unreal uses very specific BSP rendering techniques with very specific modeling tools, namely ”brushes”. But in fact, most of Epic Citadel is made with “static meshes” which are basically meshes imported from 3DS MAX or any other modeling package, very similarly to what Unity does.
I am at an early stage of development so performances are not a problem yet for me. But I can see on the forum that many people have performances problems on the iPhone. They are all desperately trying to reduce the number of draw calls, polygons and textures.

So here is my question:

What is the magic trick used by Epic and the UDK which allow them to maintain an acceptable frame rate in Epic Citadel whereas at the same time they are so obviously despising the rules which, Unity is telling us, are “mandatory” on iPhone, “due to the limitations of the platform”?!

Is there a chance to see a new version of Unity3D achieve such performances in the near future?

Epic Citadel don’t work on Iphone 3G…
Good tech demo, but not much interaction in it: If you don’t have a complet gameloop, like in a real game, you can use this power for eye candy stuff.

Unity is behind, but not far from UDK.

You can’t attribute performance and visual quality entirely to a game engine. Epic Citadel’s prettiness has little to do with engine tech, and more to do with good art assets. You could drop those same models, textures and pre-baked lighting into unity and it would look fantastic and no doubt run impressively too.

Also, I would discourage you from drawing any conclusions on Unity’s performance limitations based on what you simply gather from reading these forums. This is akin to drafting foreign policy based on what your cousin told you he saw on the news last night.

Epic citadel is a demo.
And it’s aimed at PC/PS3/X360.
So… they put everything they could in there to impress.
Unity3d - when I downloaded it I was amazed not by the complexity and beauty of the demos but rather simplicity of development.
And I think that You could make very complex games on the PC using Unity. Epic game engine is of course more advanced but also more expensive and difficult to learn.

Well… I’d say it like this:
UDK crashed my machine until I figured out that it simply refuses to work on newer ATI drivers:P
I downloaded the examples, tried the engine and found that it’s really impressive, but excessively expensive. I mean - 25% off profits >5000$ is a lot. Another thing is that it’s a lot more complex to work in. But in the end it’s more powerful. Sometimes much more powerful than Unity because of the more advanced engine.
But I couldn’t find myself in it like I find myself in Unity.
It’s my sixth day learning Unity and I see many possibilities that I couldn’t see in UDK after a month and a half. I think UDK is more complex and provides worse user experience in the toolset.

So:
UDK - and later full Unreal Engine license(heard full U3Engine license costs about 700 000$, is that true?) - when You have a bigger team.
Unity - when You want to make a game a bit less impressive graphically than - say MassEffect2, but much faster and easier.
I think that both toolsets have their market - and it overlaps only slightly in the area of indie devs.

I myself prefer Unity. Unity has a lot of things I’d have to build otherwise. And it’s simple.

You may want to re-read the original post. This is not a generic Unity vs. UDK debate, and none of your points relate to what is being discussed.

Ok.
What I meant was - EpicCitadel is doing “bad things”, because it’s meant to impress while giving the potential user a nice overview of how some things are done. They don’t care about performance on small machines like iphone and don’t much care for real-life performance because it’s a demo.
that covers all three points - a, b and c.

What I wrote was an answer to that - it’s not a question of performance but rather different targets and performance in the specific target is very close in both cases with UDK a bit ahead.

Tried to explain it properly, apparently failed :stuck_out_tongue:

If I still don’t satisfy Your sense of logic then I’m sorry, I might just understand some words a little differently.

“a. No texture atlases:”
Yeah, this is why the game takes 300mb of memory…

“b. Lots of drawcalls”
Are you sure? I checked and I’m sure that in a normal area you never have more than 100 drawcalls, like in unity.

“c. Lots of transparent faces”
If you use alpha blending, the big problem with performance is resolvet (at least is much faster), BUT you lost all zorder. Is easy to see, check any tree and see how it has zorder problems.

UDK have the same limitations than any unity game. They don’t use any magic.

About shader complexity, what they do (check the docs) is to bake complex shaders in a simple shader. In the wiki there is code to do exactly the same with unity.

If you read the docs of UDK, you will see that they say exactly the same than unity: low drawcalls, low alphas, bake shaders.

@ Hercule: of course Epic Citadel is just a visual demo with limited interactivity. It seems that Epic had to lower a bit the rendering quality for Infinity Blade. But still my question regarding the specs of this demo and the Unity “iphone guidelines” stands.

@MikaMobile: 1) it seems that you didn’t read my post. Epic Citadel is just not feasible on iphone with Unity because the necessary shaders and baking technology don’t exist in Unity3D. And even if they did exist, they are great chances that the frame rate would be very very low. (or it would mean that Unity’s very restrictive guidelines just don’t make sense).
2) My question concerns the official guidelines that Unity is advising iphone developers to respect (nb of drawcalls, nb and size of textures, texture atlasing, fill rate for transparent triangles,nb of polygons, etc). I’m just saying that developers are dedicating a lot of efforts to respect those guidelines but still get an average frame rate and not so good looking visuals because of so many restrictions whereas Epic with Epic Citadel uses lots of non optimized assets and obtain a fairly good frame rate.
Besides a lot of the posts which I am referring to are from Unity developers.

@sivael you are wrong: Epic Citadel is an iphone only demo it is not aimed at all at PC/PS3/X360. (The Epic Citadel is a UDK Mobile Editor project).
You are also right when you say that the UDK is much more powerful than Unity. That’s exactly my point: Unity developers are strongly advised to dedicate a lot of their time to optimizing their assets and get rather average visuals and average frame rates whereas UDK developers don’t have to fight the same limitations and can dedicate a lot of time to creating gorgeous assets.
@Daniel Brauer: thanks for your support.
So back to my original question: Epic are not magicians, they use the exact same hardware as Unity (I’m only referring to the iphone version of both engines). This hardware is rather simple (one CPU, one GPU and unified memory) compared to say a PS2 or a PS3.
What is so different in Epic’s technology that makes the iphone UDK so powerful and unrestrictive? Is there a chance for Unity to evolve in that direction?

@sivael: you are sooooooooo wrong: Epic Citadel is an IPHONE EXCLUSIVE demo meant to “sell” the engine to iphone developers. Of course they do care about performances!!!

@aigam: what you say is very interesting:

Hmm… you’re right.
It is a mobile demo.
I worked on it in the non-mobile version though so it got stuck to my mind that it’s not a mobile demo -.-‘’
Sorry, my mistake.

Hmm… What is so different? From my experience with UDK:
Lower level usage I guess.
In unity things are simple to use but overhead is bigger.
In UDK things are more complex to do and sometimes less intuitive but overhead might be smaller.

Still - it’s probably a question of money investment and time. With time and money, Unity will get there.
Epic is on the market since 1991 and has had BIG games out. A lot. Unity is only since 2001 and first version of their engine was out in 2005.
If you play less and have less gold, your level is lower xD

Ninja’d Edit:
Yeah, I know I was wrong.
Sorri.
Mea culpa.
Sumimasen -.-‘’

@aigam: what you say is very interesting:
a) regarding texture atlases: my understanding was that texture atlases are good for global performances because they allow to reduce the nb of draw calls. Is really the goal of atlases just to reduce the memory size?

b) regarding drawcalls: i didn’t think that Unity’s limit was so high (on iphone i mean). I keep reading posts of people striving to reduce the number of drawcalls say to 15 - 30. I even saw the post of someone trying to render the GUI in one single drawcall because the 5 - 10 drawcalls of his GUI were just killing the performances of his game!
If you are right and 100 drawcalls is ok then that’s just great!

c) transparent faces: indeed they are using alpha blending it seems. But they manage to limit the sorting problems so they must perform some kind of rough sorting. I think that they sort the transparent faces by object and render them back to front after everything else.
By reading Unity’s guidelines, it seemed that rendering many transparent faces may very negatively impact the performances because of the fillrate.

Regarding the shaders,I am getting confused. How exactly can you bake the environment bumpmap of the monk statue shader, the parallax mapping shaders or the torrent shader?

I am attaching a screenshot of the ground shader with parallax mapping and one of the monk statue shader.
It seems to me that those are the exact shaders used on the iPhone. What do they bake and how can they simplify those shaders?


Draw calls on first-gen iDevices is a quite different matter compared to 3GS+ models, which have significantly faster hardware. Some people seem to have trouble understanding that there isn’t a single iPhone model.

–Eric

You know, there are a lot more to this than we’re talking about! We’re all trying to cover a part of it, but we can’t analyze all of it, right? Pixel lighting is a very bad bottleneck in current mobile devices! We all know that, real-time per-pixel lighting is evil!
I’ve seen both Epic Citadel and Infinity Blade on iPhone 3Gs, 4 and iPad… the frame rate can barely go beyond 30 or so!
Lighting can be as complex as global illumination, photon mapping, radiosity, etc… Or it could be as simple as a vertex lighting approach, right?

I’m just taking parallax mapping as an example here… Unity3D’s parallax mapping calculates pixel lighting, right? So, that just wrong to compare unity’s parallax mapping with udk’s! There’s been some optimization in 3.2, there are a quite unlit shaders in there, etc. but if you use parallax mapping w/pixel lighting in an environment like Epic’s, u can kill the frame rate pretty easily, as we’ve done it in unity… and that’s what happened in Unity3D, people saw the Epic’s demo and tried do accomplish the same quality in Unity3D with little or no shader coding knowledge! Or I could say they just used the default parallax mapping built-in unity3d…

The trick in Epic’s parallax mapping is that they are just doing the parallax part of parallax mapping (no pixel lighting, no specular, they just read stuff from highly compressed baked maps btw) based on camera position, there’s no real-time per-pixel lighting going in there, there’s NO real-time shadows, etc. The infinity blade is using ONE directional light on main characters ONLY, there’s just two of them that are practically culled by half in the scene!

But Unity sure lacks the full/optimized support for OGLES 2.0+
OGL ES 2.0 is another factor in UDK’s incredible visuals (besides the great artwork in there!)

Just my 2 cents

@Eric5h5 : thanks for the clarification regarding the differences between iPhone generations. I will of course target the latest devices with Open GL ES 2.0. So what would be the upper limit of the number of drawcalls?

I am also a bit surprised by the “official guidelines” for the fill rate and the number of on screen triangles: the official specs of the PowerVR SGX 535 are:
fillrate : 1000 Mpixel/s
nb of triangles: 14 Mtriangles/s

This would mean 470,000 triangles per frame at 30fps. Of course, these are the maximum performances which can not be achieved in a real game.

But 50,000 - 100,000 rendered triangles per frame should be achievable, no?

Sorry!!! Double post!

@curious. thanks for your reply. This is exactly the kind of information that I am looking for.

In fact, the rendering of the parallax mapping and normal mapping is different for different surfaces in Epic Citadel.

Indeed, their parallax mapping itself just modifys the UVs when rendering the diffuse texture and performs a nice realtime displacement (the node is called “BumpOffset”). But there is no lighting nor shadowing nor specularity involved. Anyway, I have tried the demo with and without that feature and it changes everything.

For some surfaces, the ground for example, there is only the parallax mapping. (but with some specularity as you can see in my screenshot of the node based shader editor). But there is no normal map at all (baked or not).

For others, like the walls, they have the parallax mapping (with a heightmap) and baked normal mapping (in the lightmaps). The shaders themselves do contain a normal map though. But the render is different ingame and in the shader editor. So they must have some kind of global setting which enables the normal mapping only for baking.

So my next question is: since shaders are programmed there is no reason why the exact same shaders as in Epic Citadel could not be implemented in Unity? Or is there anything else missing in the Unity engine which makes this impossible to achieve?

Btw the frame rate of both Infinity Blade and Epic Citadel sometimes seems to drop to 20fps if not 15fps. But most of the time the frame rate is 30fps which would be enough for my game.

a) Well, what you say is true ^^UU They are to reduce drawcalls. In fact UDK don’t batch meshes, so there is no need to use atlas. (with this, unity is better, because this reduce drawcall).

b) This depends a LOT of your project (polys, shaders complexity, etc) and the hardware. The 15-30 drawcalls for unity 1.7 and old devices. In 3gs+ devices the number is more or less 100. (10 drawcalls for GUI is a lot, because it means at least 10% of drawcalls).
But as I say, it depends of your project, the number is between 50 and 150.

c) I’m pretty sure that they don’t sort anything. The z problem with the trees are quite spectacular.
But yeah, use a lot of alphas kill performance, this is way in udk you can almost never see alphas (trees are separated, grass is done by polis). Yes, they have big alphas, but they are alone (check the church on ipad, the framerate is low).
They use alphas? Yes, but in a clever way so you never see alot of them, or at least they are separated.

d) shaders:
Check the documentation about flattening:
http://udn.epicgames.com/Three/MobileMaterialReference.html#Flattening
Sometimes the normal is baked, some times not, but in general yes.

Check the new unity 3.2 shaders, you can use bump mapping and all this cool effects

@aigam thank you so much for the UDK mobile shaders documentation. It clarifies many things.
most of the shaders don’t use the autoflatten option though.

for example the ground shader uses:

  • diffuse map
  • mobile specular (per vertex specular)
  • bump offset (simple parallax mapping)

Yeah, the flatten is only for complex shaders. Diffuse, specular and bump offset are not flattened, but check the new included shaders in 3.2 and you will be able to do exactly the same ^^