More precisely control mipmapping.

* For images used by Live2D and AssimpModel, it's enabled.
* Other images can opt-in on a per-image basis.
This commit is contained in:
Tom Rothamel
2025-02-13 23:39:47 -05:00
parent cc2486fa82
commit 9e966702ac
4 changed files with 40 additions and 8 deletions
+10 -4
View File
@@ -355,7 +355,7 @@ class Cache(object):
texsurf = ce.surf.subsurface(ce.bounds)
renpy.display.render.mutated_surface(texsurf)
ce.texture = renpy.display.draw.load_texture(texsurf)
ce.texture = renpy.display.draw.load_texture(texsurf, properties={ 'mipmap' : image.mipmap })
# This was loaded while predicting images for immediate use,
# so get it onto the GPU.
@@ -586,7 +586,7 @@ class ImageBase(renpy.display.displayable.Displayable):
obsolete = True
obsolete_list = [ ]
mipmap = True
# If the image failed to load, a placeholder used to report the error.
fail = None
@@ -601,6 +601,7 @@ class ImageBase(renpy.display.displayable.Displayable):
self.cache = properties.pop('cache', True)
self.optimize_bounds = properties.pop('optimize_bounds', True)
self.oversample = properties.pop('oversample', 1)
self.mipmap = properties.pop('mipmap', "auto")
if self.oversample <= 0:
raise Exception("Image's oversample parameter must be greater than 0.")
@@ -2012,7 +2013,7 @@ def image(arg, loose=False, **properties):
"""
:doc: im_image
:name: Image
:args: (filename, *, optimize_bounds=True, oversample=1, dpi=96, **properties)
:args: (filename, *, optimize_bounds=True, oversample=1, dpi=96, mipmap="auto", **properties)
Loads an image from a file. `filename` is a
string giving the name of the file.
@@ -2036,6 +2037,11 @@ def image(arg, loose=False, **properties):
The DPI of an SVG image. This defaults to 96, but that can be
increased to render the SVG larger, and decreased to render
it smaller.
`mipmap`
If this is "auto", then mipmaps are generated for the image only if the game is scaled down to less than
75% of its default size. If this is True, mipmaps are always generated. If this is False, mipmaps are never
generated.
"""
"""
@@ -2160,7 +2166,7 @@ def unoptimized_texture(d):
"""
if isinstance(d, ImageBase):
return UnoptimizedTexture(d)
return UnoptimizedTexture(d, mipmap=True)
else:
return d
+1 -1
View File
@@ -659,7 +659,7 @@ cdef class GLTexture(GL2Model):
self.loader.total_texture_size -= int(self.width * self.height * 4 * 1.34)
else:
self.loader.total_texture_size -= int(self.width * self.height * 4)
except TypeError:
except (TypeError, AttributeError):
pass # Let's not error on shutdown.
def load(self):
+16
View File
@@ -47,6 +47,21 @@ merged with the player's script, a library can be placed under game/libs, and wi
`.rpe` and `.rpe.py` files are also searched in the libs directory.
Optional Mipmaps
----------------
Mipmaps are smaller versions of an image that are used when Ren'Py scales an image down. Using mipmaps
prevents the image from becoming jagged when scaled down, but generating mipmaps takes time and can cause the game
to use more memory.
Ren'Py now leaves the decision of if to create mipmaps to the developer, who knows if the game will scale down an
image. To always enable mipmaps, set :var:`config.mipmap` to True. If this isn't set to true, Ren'Py will only
create mipmaps if the display is scaled down to less than 75% of the virtual window size.
Mipmaps will automatically be created for images loaded for the purpose of Live2D or AssimpModel, as these are
likely to be scaled down. Mipmaps can be created for specific images by providing True to the mipmap parameter
of :func:`Image`.
Features
--------
@@ -84,6 +99,7 @@ apply :ref:`text interpolation <text-interpolation>` to the result. Interpolatio
that the function is called from. The triple underscore function also marks the string contained
inside for translation.
Other Changes
-------------
+13 -3
View File
@@ -18,9 +18,19 @@ such changes only take effect when the GUI is regenerated.
-----
**Mipmaps** By default, Ren'Py now only creates mipmaps for textures if the display is scaled down to
less than .75 of virtual window size. This is suitable for games that do not scale down images. To enable
mipmapping again, set :var:`config.mipmap` to True.
**Mipmaps**
Mipmaps are smaller versions of an image that are used when Ren'Py scales an image down. Using mipmaps
prevents the image from becoming jagged when scaled down, but generating mipmaps takes time and can cause the game
to use more memory.
Ren'Py now leaves the decision of if to create mipmaps to the developer, who knows if the game will scale down an
image. To always enable mipmaps, set :var:`config.mipmap` to True. If this isn't set to true, Ren'Py will only
create mipmaps if the display is scaled down to less than 75% of the virtual window size.
Mipmaps will automatically be created for images loaded for the purpose of Live2D or AssimpModel, as these are
likely to be scaled down. Mipmaps can be created for specific images by providing True to the mipmap parameter
of :func:`Image`.
**Show expression.** The ``show expression`` statement has been changed so that::