Say I have a 4k texture, I want to scale it accordingly based on system performance (to ensure I can get a certain amount of FPS).
Would downscaling the texture/image be a good or bad idea? It takes processing power to do so and would be for the whole level so could potentially run into a bit of frame delay, especially upon initialization.
On the other hand creating individual images in different sizes and loading the correct image would work but increases overall file size of the whole game.
Assigning textures in game withe texture module can be tricky. It doesn’t always work and I’m not always sure why.
If you’re designing your game to have variable graphics settings it can be better to have two (or more) different blends with different quality graphics and lib load the one you require. That way you can handle other variables like mesh density or alpha settings to give faster performance at the cost of reduced graphics.
When:
When loading a lot of textures, some of them fail to load, with no error, they just aren’t available.
When loading very large textures (2048 and above) it fails.
Both of these could be related to my computer’s low RAM (4gigs), but don’t expect that it won’t happen on other people’s computers too.
I’ve had experiences with conflicting names when using lib load. That’s definitely something to watch out for as suddenly a texture can be replaced with one from your libloaded assets.
I’m not saying, “don’t use the texture module” but you should be aware that if someone has a bit of a crappy computer they might not get the same gaming experience as you intend. I’m using it myself, but with quite small textures.
Is there any easy way to downscale a texture in realtime?
The bge.texture.imageffmpeg doesn’t seem to have a scaling function to allow this.
At the moment I’m just going off generic FPS over a time period. Using GPU latency from the profiler info may be possible but I’m not sure if it is a viable method to base performance off.
Would it be a good idea to only load ‘light’ assets, such as sounds/textures/animations, and leave heavier assets (character models) in the initial .blend file?
Previously I have experienced lots of crashes with Libload, so I would like to avoid this.
One of the most frequent problems with libload comes from a conflict of names.
When you load in a new scene it loads everything in that scene. If you have a cube called “cube” and it has a texture called “texture.001” and your camera is called “camera” you are bound to get problems since objects with those names probably already exist in the file you’re importing to.
I use a bpy script to rename everything in the libload library to something unique.
“vehicle_assets_camera” for example.
But you need to cover everything, including animations, lamps, textures, images, armatures, sounds, logic bricks, world, etc… if you want to be sure of avoiding crashes and glitches.
One good idea is to import only the assets you need in to a fresh empty blend before saving it. That way you should lose any hidden junk that you might have forgotten about.
You can downscale an image using PIL (python imaging library) either before you load it or once it is in memory.
I believe you can just pass PIL’s image buffer into the image.source? I think BluePrintRandom has used PIL with BGE.
Or you could manually downscale by sampling pixels from one and writing them into the other.
I think PIL is intended for an older version of python. I’m not sure they continued development to more recent versions.
I think there’s a fork or something though… PILLOW maybe?
But I agree it can cause conflicts, especially when you are relying on object names when you are dynamically searching for objects without further criteria. This is a matter how you design your game. It makes a lot of sense to think about naming.
@monster:
I think smoking_mirror was meaning behind the scenes. So while in your code you may manage things properly in your script, does, for example, the action actuator index actions by name?
Running a simple bpy script to add the scene name to the object + mesh name should fix the problem right (before libload runs)?
Regarding using PIL and PyQt these are python extensions right? So do you just throw them into the executable folder? How do you ensure that this code is available for the standalone player?
You have to bundle those extensions in with your executable. It can be a pain to get it right. I think Youle posted some useful info about using external libraries before.
I don’t think libload does a very good job of checking for identical names, and there are times, like when setting an action or switching a mesh, or using the texture module when we use names directly.
It would be nice if there was an addon to check for and correct naming conflicts in advance, but I don’t have the time or know-how to write something like that right now.
Ah right, I suspected the worst for this…for now I might have to just use separate .dds images less than 4k with the texture module.
Hmm I wouldn’t think an addon like this should be too hard to create, specify the target .blend then run through each datablock and compare each item. It could potentially be quite slow because you have to compare every possible combination, but apart from this it shouldn’t be too hard.
If I get some spare time I might code up a free addon like this just for everyone’s convenience.