blueprints.texture module#
There are currently three types of textures supported in blueptints.
Boxes, 2D-Planes and Meshtextures. To apply a texture to a Thing it has
to be mediated through a Material.
>>> texture = blue.texture.Plane()
>>> material = blue.Material(texture=texture)
>>> plane = blue.geoms.Plane(material=material)
Texture Types#
We will present the basic Texture Types here for image textures. The same types are also usable for Procedural Textures (see below).
Plane#
The Plane texture encodes 2D images which can be provided by a file path.
For clarity the MIME type and the number of channels can be made explicit with
content and n_channel. To flip the image vertically or horizontally
v_flip and h_flip can be used.
>>> sand_tex = blue.texture.Plane(filename='sand.png')
>>> sand_mat = blue.Material(texture=sand_tex)
>>> blue.geoms.Plane(material=sand_mat)
Box#
There are two ways of specifying the six sides of a Box we give the first
as an example here and the second for the equivalent Skybox texture.
The provided file paths are as always taken relative to the file instantiating the World.
>>> grass_tex = blue.texture.Box(filename_up ='grass_top.png',
>>> filename_left ='grass_side.png',
>>> filename_right='grass_side.png',
>>> filename_front='grass_side.png',
>>> filename_back ='grass_side.png',
>>> filename_down ='grass_bottom.png')
>>> grass_mat = blue.Material(name='grass', texture=grass_tex)
>>> grass = blue.geoms.Box(material=grass_mat)
Mesh#
If a Mesh has texture coordinates (like .obj files)
a :class:’Plane’ texture can be applied to it. If a mesh does not have texture coordinates
they can also be provided manually from the user through Mesh.texcoord.
>> creeper_tex = blue.texture.Plane(filename='creeper.png')
>> creeper_mat = blue.Material(texture=creeper_tex)
>> creeper = blue.geoms.Mesh(filename='creeper.obj')
SkyBox#
Instead of applying a Skybox texture via a Material
it can be applied directly to the World through the World.texture
attribute. Skybox and Box textures use equvalent attributes and constructions.
Warning
As of Mujoco 3.3.2 there is a bug that prevents a skybox from being loaded if no other textured Material
if included in the World.
To load a cube like texture from a single file it is partitioned into a grid through the
grid_size argument. The number of cells (i.e. the product of grid_size) must not
exceed 12. The assignment of each cell to a side of the cube is then specified via the
grid_layout string. Each row is read left to right with the character,
'U' up, 'D' down, 'L' left, 'R' right, 'F' front, 'B' back and '.' skip
mapping sides to grid cells.
>>> sky = blue.texture.Skybox(filename='sky.png',
>>> grid_layout='.U..LFRB.D..',
>>> grid_size=[3, 4])
>>> world.texture = sky
Procedural Textures#
Mujoco supports simple procedurally generated textures which are accessable
through the bultin attribute. Their apperance for Box Textures
and Plane Textures differs so we present both in the
following examples.
Note
Though they are named identically and we present Box Geoms with Box Textures and Plane geoms with Plane Textures, the opposite assignment is also possible.
>>> box_tex = ...
>>> plane_tex = ...
>>> ...
>>> box_mat = blue.Material(texture=box_tex)
>>> box = blue.geoms.Box(material=box_mat,
>>> x=-1.5,
>>> z=0.5,
>>> gamma=TAU/8)
>>> plane_mat = blue.Material(texture=plane_tex,
>>> texrepeat=[2, 1])
>>> plane = blue.geoms.Plane(material=plane_mat,
>>> x_length=2,
>>> y_length=1,
>>> x=1.5,
>>> z=0.5)
>>> world.attach(box, plane, blue.geoms.Plane(color='orange'))
Gradient#
>>> box_tex = blue.texture.Box(builtin='gradient',
>>> color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> plane_tex = blue.texture.Plane(builtin='gradient',
>>> color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> ...
Checker#
>>> box_tex = blue.texture.Box(builtin='checker',
>>> color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> plane_tex = blue.texture.Plane(builtin='checker',
>>> color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> ...
Flat#
>>> box_tex = blue.texture.Box(builtin='flat',
>>> color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> plane_tex = blue.texture.Plane(builtin='flat',
>>> p color_1='white',
>>> color_2='black',
>>> width=1000,
>>> height=1000)
>>> ...
Mark#
Additionally there are three variations of markings: 'edge', 'cross' and 'random'.
The last marking takes the additional argument random indicating the probability of a texture
pixel being colored with the color_mark.
>>> edge_tex = blue.texture.Box(builtin='flat',
>>> color_1='white',
>>> color_2='black',
>>> color_mark='orange',
>>> mark='edge',
>>> width=50,
>>> height=50)
>>> cross_tex = blue.texture.Box(builtin='flat',
>>> color_1='white',
>>> color_2='black',
>>> color_mark='orange',
>>> mark='cross',
>>> width=50,
>>> height=50)
>>> random_1_tex = blue.texture.Box(builtin='flat',
>>> color_1='white',
>>> color_2='black',
>>> color_mark='orange',
>>> mark='random',
>>> random=0.05,
>>> width=50,
>>> height=50)
>>> random_2_tex = blue.texture.Box(builtin='flat',
>>> color_1='white',
>>> color_2='black',
>>> color_mark='orange',
>>> mark='random',
>>> random=0.5,
>>> width=50,
>>> height=50)
- class blueprints.texture.BaseTexture[source]#
Bases:
BaseThingMost attribute descriptions are partially taken from Mujoco.
- property asset: TextureAssetType#
The attributes of the texture are stored in a separate asset object. If this texture is assign to multiple objects, and then gets modified through
Material.texture.attribute = valueall other Materials referenceing the Texture will be unaltered. SeeUniqueThing.- Return type:
blue.TextureAssetType
- property content: str | None#
Content type (MIME type) taking values
None,'image/png','image/ktx'and'image/vnd.mujoco.texture'.- Return type:
str | None
- property filename: str | None#
Name of the texture file.
- Return type:
str | None
- property grid_size: list[int]#
Grid size attrigute
[n_rows, n_cols]defining the grid. For non-grid Textures this value is ignored.- Return type:
list[int]
- property grid_layout: str | None#
The layout of the grid. See example above.
- Return type:
str | None
- property filename_right: str | None#
The file name for the right side of a
Box.- Return type:
str | None
- property filename_left: str | None#
The file name for the left side of a
Box.- Return type:
str | None
- property filename_up: str | None#
The file name for the upper side of a
Box.- Return type:
str | None
- property filename_down: str | None#
The file name for the down side of a
Box.- Return type:
str | None
- property filename_front: str | None#
The file name for the front side of a
Box.- Return type:
str | None
- property filename_back: str | None#
The file name for the back side of a
Box.- Return type:
str | None
- property builtin: str | None#
If set, this attribute specifies a builtin procedural Texture. See examples above.
- Return type:
str | None
- property mark: str | None#
If set this attribute specifies additional markings on a procedural Texture. Possible values are
None,'edge','cross'and'random'. See examples above.- Return type:
str | None
- property random: float#
If the
markattribute is set to'random', this attribute specifies the probability of a pixel in the texture being themark_color.- Return type:
float
- property width: int#
The width of a procedural texture, i.e., the number of columns in the image. Larger values usually result in higher quality images, although in some cases (e.g. checker patterns) small values are sufficient. For textures loaded from files, this attribute is ignored.
- Return type:
int
- property height: int#
The height of the procedural texture, i.e., the number of rows in the image. For
BoxandSkyboxtextures, this attribute is ignored and the height is set to 6 times the width. For textures loaded from files, this attribute is ignored.- Return type:
int
- property h_flip: bool#
If true, images loaded from file are flipped in the horizontal direction. Does not affect procedural textures.
- Return type:
bool
- property v_flip: bool#
If true, images loaded from file are flipped in the vertical direction. Does not affect procedural textures.
- Return type:
bool
- property n_channel: int#
The number of channels in the texture image file. This allows loading 4-channel textures (RGBA) or single-channel textures (e.g., for Physics-Based Rendering properties such as roughness or metallic).
- Return type:
int
- class blueprints.texture.Plane[source]#
Bases:
PlaneTextureType,BaseTexture- __init__(content=None, filename=None, builtin=None, color_1=[0.8, 0.8, 0.8], color_2=[0.5, 0.5, 0.5], mark=None, color_mark=[0.0, 0.0, 0.0], random=0.01, width=1000, height=1000, h_flip=False, v_flip=False, n_channel=3, name=None, asset=None)[source]#
- Parameters:
content (str | None)
filename (str | None)
builtin (str | None)
color_1 (object)
color_2 (object)
mark (str | None)
color_mark (object)
random (float)
width (int)
height (int)
h_flip (bool)
v_flip (bool)
n_channel (int)
name (str | None)
asset (TextureAssetType | None)
- class blueprints.texture.Box[source]#
Bases:
BoxTextureType,BaseTexture- __init__(content=None, filename=None, grid_size=[1, 1], grid_layout=None, filename_right=None, filename_left=None, filename_up=None, filename_down=None, filename_front=None, filename_back=None, builtin=None, color_1=[0.8, 0.8, 0.8], color_2=[0.5, 0.5, 0.5], mark=None, color_mark=[0.0, 0.0, 0.0], random=0.01, width=1000, height=1000, h_flip=False, v_flip=False, n_channel=3, name=None, asset=None)[source]#
- Parameters:
content (str | None)
filename (str | None)
grid_size (list[int])
grid_layout (str | None)
filename_right (str | None)
filename_left (str | None)
filename_up (str | None)
filename_down (str | None)
filename_front (str | None)
filename_back (str | None)
builtin (str | None)
color_1 (object)
color_2 (object)
mark (str | None)
color_mark (object)
random (float)
width (int)
height (int)
h_flip (bool)
v_flip (bool)
n_channel (int)
name (str | None)
asset (TextureAssetType | None)
- class blueprints.texture.Skybox[source]#
Bases:
SkyboxTextureType,Box- __init__(content=None, filename=None, grid_size=[1, 1], grid_layout=None, filename_right=None, filename_left=None, filename_up=None, filename_down=None, filename_front=None, filename_back=None, builtin=None, color_1=[0.8, 0.8, 0.8], color_2=[0.5, 0.5, 0.5], mark=None, color_mark=[0.0, 0.0, 0.0], random=0.01, width=1000, height=1000, h_flip=False, v_flip=False, n_channel=3, name=None, asset=None)[source]#
- Parameters:
content (str | None)
filename (str | None)
grid_size (list[int])
grid_layout (str | None)
filename_right (str | None)
filename_left (str | None)
filename_up (str | None)
filename_down (str | None)
filename_front (str | None)
filename_back (str | None)
builtin (str | None)
color_1 (object)
color_2 (object)
mark (str | None)
color_mark (object)
random (float)
width (int)
height (int)
h_flip (bool)
v_flip (bool)
n_channel (int)
name (str | None)
asset (TextureAssetType | None)