Hello - newbie questions

Hi Guys - I’m new to PlayCanvas, coming from the CG side of things (C4D, Houdini, Arnold, Redshift).

I’m wanting to create a 3D virtual gallery, whereby a player can walk around the gallery and look at various pieces of artwork on the walls. But I’ve got a few best-practise type questions:

  • in terms of efficiency (speed and load times), would it better to break the geometry for the walls into lots of smaller ‘chunks’ (each with smaller texture sizes, say 1024x1024) or fewer bigger ‘chunks’ (with larger textures of 4096x4096)…?

  • are there any general rules for how many total polygons a scene can handle comfortably? I know it will probably depend on graphics card etc, but are there any best practises in terms of total polygon count? I’m trying to figure out if I can afford to bevel all the geometry, for example!

Many thanks,
Adam

@adametheridge
There can be collision problems with high-poly models, but if your map is hand modeled with primitives it should be fine, and smaller chunks should be better than big chunks, and you should use blank entities to group the peices, its way easier.

(p.s, i also have an fps script you can use if you dont have time to code your own)

Thanks for such a speedy reply Gavin, thats great.

Do you think there’s an approx max total number of polygons in a scene I should stay under?

I have some experience with CG optimization for mobile devices. All I saying is valid for mobile devices, I am not sure about the desktop:

  1. Bigger chunks are faster because 1 chunk = 1 draw call. Mobile devices are very sensitive to draw calls, especially in WebGL.
  2. Yeah, It depends on your graphics card. For something like Samsung Galaxy 7 it could be 100000 polygons, but for an Intel Core i9 + GTX3080 it could be 10000000. You never know until you try.

Welcome to PlayCanvas, Adam!

Generally, the walls are pretty cheap vertex count wise, as they a flat. It is pretty safe to add bevels, ornaments and other small decors. For example, my old Samsung S6, can easily run at least half a million polygons.

You want larger objects, merging sperate objects into one wherever possible. As @Dan_Organ mentioned, separate 3D object will make a new draw call each and you have a limit of those on a mobile phone. Even a single model, that has different polygons assigned a different material in your modelling software, will make new draw calls for each new material in PlayCanvas. Merging picture frames on the walls with the wall itself and using a single diffuse map for everything would be a good optimization. If the room is too large, the texture would blur, so you might consider making a room smaller and having several rooms instead. Once you get there, we can help you with some additional advanced methods, like dynamically unloading/loading rooms, to preserve the memory.

Often, the performance on mobile phone is suffering because of the limited VRAM and the textures you use. Atlas maps help reducing the draw calls too. In your case, four 1k x 1k art pieces on a single 4k x 4k texture is better than having them as separate textures. A wall may have a small piece of texture that is tiled across its surface. Try not to use high resolution textures for objects that will never occupy the whole screen. For example, a chair in the 3D world will always take only a small portion of the application screen, so no need to give it a 4k resolution texture. Also, reusing textures is a good practice. If one door is black and the other is dark brown - consider using a single texture for both.

A target draw calls for low-end device is 40-60. High end can handle 3-4 times more. Computers 300 and more, depending on GPU.

You also want to bake all the lights, either in your modelling software or PlayCanvas Editor. Unless you need dynamic lights, which you probably don’t in a gallery type of setup. Dynamic lighting is expensive.

4 Likes

ive never ran into that problem, therefore i don’t know, im sorry.

Hi LeXXik, Hi Dan_Organ

Thank you both for such thorough answers, that’s so helpful. Coming from the offline rendering world, I must admit I’d never even heard of draw calls before. Sounds like they are much more important than poly count (assuming I keep sub 500K which should be fine).

Just so I’m 100% clear, a draw count constitutes: the rendering of either a single model, and/or a new material?

What triggers a draw call? Is it anything that the camera can ‘see’? Or is it everything within scene, regardless of what the player is looking at? Does camera frustum culling help reduce it?

I was hoping to build one large gallery, for the user to be able to explore at will. Initially I was planning to make it circular, but with various inner walls and dividers to break up the space, and to make it more interesting. However I’ve got 90 pieces of art that I need to feature:

  • 70 are just pictures that I was planning to place on v simple canvases on walls
  • 20 are handwritten stories… which is more complicated. The idea here was to create an animated book (FBX import), and place the books on simple pedestals within the gallery. As a player approaches a particular book, the book would open. Most of the stories are short (a few pages), the longest is 6 pages. The user would press a key to advance the animation to the next page. The stories are handwritten by children, so each pages needs to be an image (rather than rendered text).

… but based on the above, and from you’ve said, it sounds like maybe one large room won’t work on mobile?? For example, it’s likely that each page of the books will need its own material (although I may be able to pack all the pages of one book onto 1 UV layout and a single 4K texture, per book). Unless a draw count is only what the camera can ‘see’… and therefore breaking up the space with enough inner walls will reduce the count???

As for lighting. Yes, static all the way. I was planning to bake AO (and even Global Illumination) within Arnold for the general room lighting.

Sounds like they are much more important than poly count (assuming I keep sub 500K which should be fine).

Yeah, that is right. At least in the mobile world.

Just so I’m 100% clear, a draw count constitutes: the rendering of either a single model, and/or a new material?

One material is causing one draw call. For materials, it is the same rule as for models.

What triggers a draw call? Is it anything that the camera can ‘see’?

In most cases, yes. A draw call is triggered when something is in the camera’s field of view.

The whole draw call topic is quite complicated because all game engines are trying to optimize it. There is a batching feature in the Playcanvas: https://developer.playcanvas.com/en/user-manual/optimization/batching/ It is automatically combining static meshes and doing other work to reduce draw calls.

Also, you can import your scene to Unity and run the Frame Debugger to examine all draw calls per frame.

1 Like

A draw call is a command from your CPU to GPU to draw something. For example, a floor with a texture is a single draw call. A ceiling with another texture is another draw call. If floor and ceiling models are separate but share a texture, they could be batched and the engine can draw them both in a single draw call. I’d recommed adding a Spector plugin for Chrome - it can help dissecting the draw calls of any WebGL application.

There are various optimization techniques to reduce the number of draw calls. You can start from the guide:
https://developer.playcanvas.com/en/user-manual/optimization/guidelines/

Also, search for performance and optimization topics on the forum - there are a number of good reads here. I can tell you that 90 textures of good resolution is probably too much for most mobile phones. You will want to dynamically load/unload. Perhaps on entering another room, or gallery section. That also means there should be some consideration for UX, as the textures will take time loading. Large games use some tricks, like elevators, where a player is riding it until the next chunk is loaded. You could probably get away with simpler approach, like simply replacing a placeholder image once the real one loaded. Another option is that you have a large room, but load only the images that are in proximity to the player. Adding small inner walls can help blocking the missing pictures in the distance from the view.

2 Likes

So draw calls is the amount of textures you can have? :confused: