Page MenuHome

Initial BGE font resolution now taken from blender "Render U" ui-field
AbandonedPublic

Authored by Pierluigi Grassi (pgi) on Mar 31 2015, 2:59 PM.

Details

Summary

Currently font objects in bge (KX_FontObject) have a predefined resolution attribute that can only be changed through the python api, by calling

font_object.resolution = some value

The patch simply takes the initial value of the resolution from the field "Render U" in the "Resolution" panel. This bypasses the need to create a script to change the resolution. The resolution has to be changed because when the rendered text is visually small it appears otherwise pixellated. It also makes sense to bind the resolution property to the already existing field.

Diff Detail

Event Timeline

Pierluigi Grassi (pgi) retitled this revision from to Initial BGE font resolution now taken from blender "Render U" ui-field.
Pierluigi Grassi (pgi) updated this object.
Jorge Bernal (lordloki) requested changes to this revision.Apr 5 2015, 1:34 AM

Additionally to the inline comment, it is necessary to add a do_versions (versioning_270.c) to assign 1.0f to the Render U resolution when loading old blends.

Apart from this the feature seems useful to me.

I add to Dalai as reviewer also.

source/gameengine/Ketsji/KX_FontObject.cpp
94

As we can see in the Font panel when the Render U = 0 it should take the resolution from Preview slide.

Then it should be:

m_resolution = max(1.0f, (float)((text->resolu_ren != 0) ? text->resolu_ren : text->resolu));

but this has the inconvenient that the default value for preview is 12 (very high for real time purpose).

Therefore, I propose to modify the text label of Render U removing "(zero uses preview resolution)". Only for game engine, of course :-)

This revision now requires changes to proceed.Apr 5 2015, 1:34 AM

Assuming that existing applications didn't change the value in the render field - because it didn't have any effect - using the preview value may introduce a tiny performance penalty for existing applications (I take this for granted but I don't really know if that is actually true).
Even though I think that the correct solution would be to use the preview value, because that is what the UI is telling to the user, I'd rather use the default value of 1.0 when the render field is set to 0, to avoid existing programs starting to behave differently.

I'll look into the the versioning thing.

I think this only makes sense if/when the BGE font code get to use the same drawing code that Blender does for the Viewport. There is no BGE-specific doversioning, so this will be complicated to handle (and a high resolution will cost a lot for unaware games).

Ok, this is what I understood so far.
The version file handles transitions from version to version. If an old field that has a wrong/non existing value is found, it is "fixed".
I might be wrong but I'm not proposing to change anything in the blender file, the bge font object is created on the fly by the engine.
If I understand this thing correctly, no transformation is needed from version to version.
I'd also like to point that the current default value (1.0) is the same value applied by the patch.
If for some reason a old blender file - used for a game - has a render resolution value other than zero, then and only then, the program will behave differently.
I don't see how the way the text is rendered - via custom routines or sharing ui code - can make a difference. Right now for each Text object one has to create a binding to a python function that fixes the font resolution, otherwise the text is an unfathomable mud of pixels.
So, to recap, I think:

  1. it is not advisable to use the higher preview resolution because it will suddenly introduce a performance hit (users already implemented fixes for the resolution issues)
  2. there is no need to add transformations for older files

therefore the proposed patch, in its original form, is (again, imo) correct and useful. Actually, I'd like to change it in the more explicit form:

/* Sets the real time initial resolution for the rendered font */
const float renderFontResolutionU = (float) text->resolu_ren;
const float minimumFontResolutionU = 1.0f;
if(renderFontResolutionU > minimumFontResolutionU) {
    m_resolution = renderFontResolutionU;
} else {
    m_resolution = minimumFontResolutionU;
}

Of course, feel free to use it or not, I'm not trying to shove it down anybody's gullet :D.

BGE was removed in Blender 2.80 this patch is being closed as a result.