Model Displayable: Class Model (Size None, Properties)
Model Displayable: Class Model (Size None, Properties)
The Model displayable acts as a factory to created models for use with the model-based renderer.
class Model(size=None, **properties)
This is a displayable that causes Ren'Py to create a 2D or 3D model for use with the model-based
renderer, that will be drawn in a single operation with the shaders given here, or selected by an
enclosing Transform or Displayable.
size
If not None, this should be a width, height tuple, that's used to give the size of the Model. If
not given, the model is the size of the area provided to it. The fit parameter to a texture
takes precedence.
If no mesh method is called, a mesh that sets a_position and a_tex_coord to match the way
Ren'Py loads textures is created if at least one texture is supplied. Otherwise, a mesh that only
sets a_position is used.
All methods on this calls return the displayable the method is called on, making it possible to
chain calls.
child(displayable, fit=False)
This is the same as the texture method, except that the focus and main parameters are set to
true.
grid_mesh(width, height)
Creates a mesh that consists of a width x height grid of evenly spaced points, connecting
each point to the closest points vertically and horizontally, and dividing each rectangle in
the grid so created into triangles.
width, height
The number of points in the horizontal vertical directions, a integer that is at least 2.
properties(name, value)
name
A string giving the name of the GL property, including the "gl_" prefix.
value
The value of the gl property.
shader(shader)
Add a texture to this model, by rendering the given displayable. The first texture added will
be tex0, the second tex1, a and so on.
focus
If true, focus events are passed to the displayable. It's assumed that coordinate
relative to the model map 1:1 with coordinates relative to the displayable.
main
If true, this is marked as a main child of this displayable, which allows it to be
inspected using the displayable inspector.
fit
If true, the Model is given the size of the displayable. This may only be true for one
texture.
uniform(name, value)
name
A string giving the name of the uniform to set, including the "u_" prefix.
value
The value of the uniform. Either a float, a 2, 3, or 4 element tuple of floats, or a
Matrix.
u_renpy_dissolve 0.0
linear delay u_renpy_dissolve 1.0
Vertex shader:
gl_Position = u_transform * a_position;
Vertex shader:
v_tex_coord = a_tex_coord;
Fragment shader:
gl_FragColor = vec4(0.);
float renpy_blur_norm = 0.;
gl_FragColor /= renpy_blur_norm;
Vertex shader:
v_tex_coord = a_tex_coord;
Fragment shader:
vec4 color0 = texture2D(tex0, v_tex_coord.st, u_lod_bias);
vec4 color1 = texture2D(tex1, v_tex_coord.st, u_lod_bias);
Vertex shader:
v_tex_coord = a_tex_coord;
Fragment shader:
vec4 color0 = texture2D(tex0, v_tex_coord.st, u_lod_bias);
vec4 color1 = texture2D(tex1, v_tex_coord.st, u_lod_bias);
vec4 color2 = texture2D(tex2, v_tex_coord.st, u_lod_bias);
Fragment shader:
gl_FragColor = u_renpy_solid_color;
Vertex shader:
v_tex_coord = a_tex_coord;
Fragment shader:
gl_FragColor = texture2D(tex0, v_tex_coord.xy, u_lod_bias);
Fragment shader:
gl_FragColor = u_renpy_matrixcolor * gl_FragColor;
Fragment shader:
gl_FragColor = gl_FragColor * vec4(u_renpy_alpha, u_renpy_alpha, u_renpy_alpha,
u_renpy_alpha * u_renpy_over);