panda3d.core.SamplerState

class SamplerState

Represents a set of settings that indicate how a texture is sampled. This can be used to sample the same texture using different settings in different places.

Inheritance diagram

Inheritance diagram of SamplerState

__init__() → None

Creates a new SamplerState initialized to the default values.

__init__(param0: SamplerState) → None
static getDefault() → SamplerState

Returns a reference to the global default immutable SamplerState object.

Return type

SamplerState

setWrapU(wrap: WrapMode) → None

This setting determines what happens when the SamplerState is sampled with a U value outside the range 0.0-1.0. The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.

setWrapV(wrap: WrapMode) → None

This setting determines what happens when the SamplerState is sampled with a V value outside the range 0.0-1.0. The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.

setWrapW(wrap: WrapMode) → None

The W wrap direction is only used for 3-d SamplerStates.

setMinfilter(filter: FilterType) → None

Sets the filtering method that should be used when viewing the SamplerState from a distance.

setMagfilter(filter: FilterType) → None

Sets the filtering method that should be used when viewing the SamplerState up close.

setAnisotropicDegree(anisotropic_degree: int) → None

Specifies the level of anisotropic filtering to apply to the SamplerState. Set this 0 to indicate the default value, which is specified in the SamplerState-anisotropic-degree config variable.

To explicitly disable anisotropic filtering, set this value to 1. To explicitly enable anisotropic filtering, set it to a value higher than 1; larger numbers indicate greater degrees of filtering.

setBorderColor(color: LColor) → None

Specifies the solid color of the SamplerState’s border. Some OpenGL implementations use a border for tiling SamplerStates; in Panda, it is only used for specifying the clamp color.

setMinLod(min_lod: float) → None

Sets the minimum level of detail that will be used when sampling this texture. This may be a negative value.

setMaxLod(max_lod: float) → None

Sets the maximum level of detail that will be used when sampling this texture. This may exceed the number of mipmap levels that the texture has.

setLodBias(lod_bias: float) → None

Sets the value that will be added to the level of detail when sampling the texture. This may be a negative value, although some graphics hardware may not support the use of negative LOD values.

getWrapU() → WrapMode

Returns the wrap mode of the texture in the U direction.

Return type

WrapMode

getWrapV() → WrapMode

Returns the wrap mode of the texture in the V direction.

Return type

WrapMode

getWrapW() → WrapMode

Returns the wrap mode of the texture in the W direction. This is the depth direction of 3-d textures.

Return type

WrapMode

getMinfilter() → FilterType

Returns the filter mode of the texture for minification. If this is one of the mipmap constants, then the texture requires mipmaps. This may return FT_default; see also getEffectiveMinfilter().

Return type

FilterType

getMagfilter() → FilterType

Returns the filter mode of the texture for magnification. The mipmap constants are invalid here. This may return FT_default; see also getEffectiveMinfilter().

Return type

FilterType

getEffectiveMinfilter() → FilterType

Returns the filter mode of the texture for minification, with special treatment for FT_default. This will normally not return FT_default, unless there is an error in the config file.

Return type

FilterType

getEffectiveMagfilter() → FilterType

Returns the filter mode of the texture for magnification, with special treatment for FT_default. This will normally not return FT_default, unless there is an error in the config file.

Return type

FilterType

getAnisotropicDegree() → int

Returns the degree of anisotropic filtering that should be applied to the texture. This value may return 0, indicating the default value; see also get_effective_anisotropic_degree.

getEffectiveAnisotropicDegree() → int

Returns the degree of anisotropic filtering that should be applied to the texture. This value will normally not return 0, unless there is an error in the config file.

getBorderColor() → LColor

Returns the solid color of the texture’s border. Some OpenGL implementations use a border for tiling textures; in Panda, it is only used for specifying the clamp color.

Return type

LColor

getMinLod() → float

Returns the minimum level of detail that will be observed when sampling this texture.

getMaxLod() → float

Returns the maximum level of detail that will be observed when sampling this texture.

getLodBias() → float

Returns the bias that will be added to the texture level of detail when sampling this texture.

usesMipmaps() → bool

Returns true if the minfilter settings on this sampler indicate the use of mipmapping, false otherwise.

static isMipmap(type: FilterType) → bool

Returns true if the indicated filter type requires the use of mipmaps, or false if it does not.

static formatFilterType(ft: FilterType) → str

Returns the indicated FilterType converted to a string word.

static stringFilterType(str: str) → FilterType

Returns the FilterType value associated with the given string representation, or FT_invalid if the string does not match any known FilterType value.

Return type

FilterType

static formatWrapMode(wm: WrapMode) → str

Returns the indicated WrapMode converted to a string word.

static stringWrapMode(str: str) → WrapMode

Returns the WrapMode value associated with the given string representation, or WM_invalid if the string does not match any known WrapMode value.

Return type

WrapMode

prepare(prepared_objects: PreparedGraphicsObjects) → None

Indicates that the sampler should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.

Use this function instead of prepareNow() to preload samplers from a user interface standpoint.

isPrepared(prepared_objects: PreparedGraphicsObjects) → bool

Returns true if the sampler has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.

release(prepared_objects: PreparedGraphicsObjects) → None

Frees the texture context only on the indicated object, if it exists there. Returns true if it was released, false if it had not been prepared.

prepareNow(prepared_objects: PreparedGraphicsObjects, gsg: GraphicsStateGuardianBase) → SamplerContext

Creates a context for the sampler on the particular GSG, if it does not already exist. Returns the new (or old) SamplerContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new textures. If this is not necessarily the case, you should use prepare() instead.

Normally, this is not called directly except by the GraphicsStateGuardian; a sampler does not need to be explicitly prepared by the user before it may be rendered.

Return type

SamplerContext

static getClassType() → TypeHandle
Return type

TypeHandle

property wrap_u
Getter

Returns the wrap mode of the texture in the U direction.

Setter

This setting determines what happens when the SamplerState is sampled with a U value outside the range 0.0-1.0. The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.

Return type

WrapMode

property wrap_v
Getter

Returns the wrap mode of the texture in the V direction.

Setter

This setting determines what happens when the SamplerState is sampled with a V value outside the range 0.0-1.0. The default is WM_repeat, which indicates that the SamplerState should repeat indefinitely.

Return type

WrapMode

property wrap_w
Getter

Returns the wrap mode of the texture in the W direction. This is the depth direction of 3-d textures.

Setter

The W wrap direction is only used for 3-d SamplerStates.

Return type

WrapMode

property minfilter
Getter

Returns the filter mode of the texture for minification. If this is one of the mipmap constants, then the texture requires mipmaps. This may return FT_default; see also getEffectiveMinfilter().

Setter

Sets the filtering method that should be used when viewing the SamplerState from a distance.

Return type

FilterType

property magfilter
Getter

Returns the filter mode of the texture for magnification. The mipmap constants are invalid here. This may return FT_default; see also getEffectiveMinfilter().

Setter

Sets the filtering method that should be used when viewing the SamplerState up close.

Return type

FilterType

property effective_minfilter

Returns the filter mode of the texture for minification, with special treatment for FT_default. This will normally not return FT_default, unless there is an error in the config file.

Return type

FilterType

property effective_magfilter

Returns the filter mode of the texture for magnification, with special treatment for FT_default. This will normally not return FT_default, unless there is an error in the config file.

Return type

FilterType

property anisotropic_degree
Getter

Returns the degree of anisotropic filtering that should be applied to the texture. This value may return 0, indicating the default value; see also get_effective_anisotropic_degree.

Setter

Specifies the level of anisotropic filtering to apply to the SamplerState. Set this 0 to indicate the default value, which is specified in the SamplerState-anisotropic-degree config variable.

To explicitly disable anisotropic filtering, set this value to 1. To explicitly enable anisotropic filtering, set it to a value higher than 1; larger numbers indicate greater degrees of filtering.

Return type

int

property effective_anisotropic_degree

Returns the degree of anisotropic filtering that should be applied to the texture. This value will normally not return 0, unless there is an error in the config file.

Return type

int

property border_color
Getter

Returns the solid color of the texture’s border. Some OpenGL implementations use a border for tiling textures; in Panda, it is only used for specifying the clamp color.

Setter

Specifies the solid color of the SamplerState’s border. Some OpenGL implementations use a border for tiling SamplerStates; in Panda, it is only used for specifying the clamp color.

Return type

LColor

property min_lod
Getter

Returns the minimum level of detail that will be observed when sampling this texture.

Setter

Sets the minimum level of detail that will be used when sampling this texture. This may be a negative value.

Return type

float

property max_lod
Getter

Returns the maximum level of detail that will be observed when sampling this texture.

Setter

Sets the maximum level of detail that will be used when sampling this texture. This may exceed the number of mipmap levels that the texture has.

Return type

float

property lod_bias
Getter

Returns the bias that will be added to the texture level of detail when sampling this texture.

Setter

Sets the value that will be added to the level of detail when sampling the texture. This may be a negative value, although some graphics hardware may not support the use of negative LOD values.

Return type

float

enum FilterType
enumerator FT_nearest = 0

Point sample the pixel

enumerator FT_linear = 1

Bilinear filtering of four neighboring pixels

enumerator FT_nearest_mipmap_nearest = 2

Point sample the pixel from the nearest mipmap level

enumerator FT_linear_mipmap_nearest = 3

Bilinear filter the pixel from the nearest mipmap level

enumerator FT_nearest_mipmap_linear = 4

Point sample the pixel from two mipmap levels, and linearly blend

enumerator FT_linear_mipmap_linear = 5

A.k.a. trilinear filtering: Bilinear filter the pixel from two mipmap levels, and linearly blend the results.

enumerator FT_shadow = 6

The OpenGL ARB_shadow extension can be thought of as a kind of filtering.

enumerator FT_default = 7

Default is usually linear, but it depends on format. This was added at the end of the list to avoid bumping TXO version #.

enumerator FT_invalid = 8

Returned by string_filter_type() for an invalid match.

enum WrapMode
enumerator WM_clamp = 0

coords that would be outside [0-1] are clamped to 0 or 1

enumerator WM_repeat = 1
enumerator WM_mirror = 2
enumerator WM_mirror_once = 3

mirror once, then clamp

enumerator WM_border_color = 4

coords outside [0-1] use explicit border color Returned by string_wrap_mode() for an invalid match.

enumerator WM_invalid = 5

coords outside [0-1] use explicit border color Returned by string_wrap_mode() for an invalid match.