Renderer.set_environment_texture#
- Renderer.set_environment_texture(
- texture,
- is_srgb=False,
- resample: bool | float | None = None,
- rotation: TypeAliasForwardRef('pyvista.RotationLike') | None = None,
- show_background=True,
Set the environment texture used for image based lighting.
This texture is supposed to represent the scene background. If it is not a cubemap, the texture is supposed to represent an equirectangular projection. If used with raytracing backends, the texture must be an equirectangular projection and must be constructed with a valid vtkImageData.
- Parameters:
- texture
pyvista.Texture Texture.
- is_srgbbool, default:
False If the texture is in sRGB color space, set the color flag on the texture or set this parameter to
True. Textures are assumed to be in linear color space by default.- resamplebool |
float,optional Resample the environment texture. Set this to a float to set the sampling rate explicitly or set to
Trueto down-sample the texture to 1/16 of its original resolution. By default, the theme value forresample_environment_textureis used, which isFalsefor the standard theme.Down-sampling the texture can substantially improve performance for some environments, for example, headless setups or if GPU support is limited.
Note
This will resample the texture used for image-based lighting only, for example, the texture used for rendering reflective surfaces. It does not resample the background texture.
Added in version 0.45.
Changed in version 0.48: Resampling now uses linear interpolation with anti-aliasing instead of nearest-neighbor, which gives smoother results for continuous environment textures.
Changed in version 0.49: The image-based lighting textures are down-sampled at the same rate: the specular prefilter integrates fewer samples per texel, and for cube map textures the diffuse irradiance map shrinks as well. Both are clamped between a floor and their default size, so a very low rate stops making them cheaper. Only a single rate is accepted; a sequence of per-axis rates raises
ValueError.- rotation
RotationLike,optional Rotation to apply to the environment texture for image-based lighting and the background texture. Accepts any 3x3
numpy.ndarray, vtkMatrix3x3, or SciPyRotation. Requires VTK >= 9.6.Added in version 0.48.
- show_backgroundbool, default:
True Whether to also show the environment texture as the renderer background. Set this to
Falseto keep image-based lighting enabled while using a solid or gradient background instead.Added in version 0.48.
- texture
Examples#
Download Python source code | Download Jupyter notebook
Add a skybox cubemap as an environment texture and show that the
lighting from the texture is mapped on to a sphere dataset. Note how
even when disabling the default 'light kit', the scene lighting will still
be mapped onto the actor.
>>> from pyvista import examples
>>> import pyvista as pv
>>> pl = pv.Plotter(lighting=None)
>>> cubemap = examples.download_sky_box_cube_map()
>>> _ = pl.add_mesh(pv.Sphere(), pbr=True, metallic=0.9, roughness=0.4)
>>> pl.set_environment_texture(cubemap)
>>> pl.camera_position = 'xy'
>>> pl.show()