Advice for playing card model

Hello, as a thesis assignment I created a tarock game. Tarock is a card game played in Europe. First I used JSONLoader for my playing card model. The card object consisted of a single mesh with three materials. I then made a new object and exported it as gltf. Now when I import it using the new gltf loader, the object is a group of three meshes, each with its own material. However, the performance was better using the old model.
I need 3 materials because I use a separate texture for the front and back. I use the third material for the edge that lights up at a certain action.

Anyway I need advice on how to make perfomance better.

karta.json (10.1 KB)

front_50 k2.bin (25.5 KB) k2.gltf (6.6 KB)

There are some screen shots at, site is in Slovenian language.
If you wana try the game, It uses google sign-in and registration … For registration just check and click Google or Facebook. Then Igraj Tarok.

Is the game itself a 3D game? Why would you use models instead of a simple sprite, export cards as textures (ideally compress them using the appropriate ktx format) and map textures onto sprites instead?

Given that approach you can even get away with a single texture atlas (in that case you can use instancing to render all the cards with a single call)

Based on screenshots, the cards are always facing towards the camera, so IMO sprites would be a better way to render cards.

1 Like

I tried to create sort of realistic environment, 3D room with cards and nice animation. It works ok. I just need some advice, how to make game better on slower machines …

how to make game better on slower machines

Mesh instancing (Sprite or 3D planes), texture compression and texture atlasses.

If heavy computations occur in main thread: Web workers.

Rounded edges on cards = More vertices = Takes more time to render them. Instead just render a simple quad with baked texture which already has rounded corners on a transparent background. That’d be my suggestion. Good luck!

1 Like

Hi, welcome to the community :partying_face:

Three materials per single (and quite simple) object is a recipe for disaster. If you start showing many cards simultanously, you’ll get tons of unnecessary draw calls.
I would recomend you to work on your card model and ‘merge’ the materials into just one

  1. For backside and frontside textures, you can make a texture atlas or simply put both the front and back images into one image (which I think will be closer to a squarish shape so less texture space wasted)
  2. I didnt see the edge light-up effect, but if its a simple edge highlight or something along those lines, then it can be achieved in a shader with usage of uvs or you can add an emission map to your model and then animate the material’s emissive factor/color for activating the highlight.

Once your card is a single material object, you life will become much easier, not only because the draw calls will be reduced to 1/3 (which is already really good by itself), but you’ll also be able to use Instancing to render all cards in just one draw call.
In general, the more cards you have in your game displayed at the same time, the more beneficial the instancing will be, but be warned that implementing different textures per each instance might take some work :face_with_monocle:

With the current info that you’ve presented us with, I believe thats the best direction to go to.

1 Like

Thanks for the tips.

I tried exporting the model in collada format, this returns a 3d object with one mesh and three materials, the same as jsonloader, which I like.

Then I tried to use texture atlas but I don’t know how to use single texture for 54 instances using offset.

You can do that with Blender. You can read on how to do that on blender-related places.

Basically it’s just a UV layout. This is not something complex, you might have to do a bit of reading to grasp basics though. It’s just modelling knowledge, nothing related to programming specifically.

1 Like