SamplerState

from panda3d.core import SamplerState
class SamplerState

Bases:

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

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.

__eq__(other: SamplerState) bool
__init__()

Creates a new SamplerState initialized to the default values.

__init__(param0: SamplerState)
__lt__(other: SamplerState) bool
__ne__(other: SamplerState) bool
property anisotropic_degree int
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 getEffectiveAnisotropicDegree().

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.

property border_color LColor

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

property effective_anisotropic_degree 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.

property effective_magfilter 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.

property effective_minfilter 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.

static formatFilterType(ft: FilterType) str

Returns the indicated FilterType converted to a string word.

static formatWrapMode(wm: WrapMode) str

Returns the indicated WrapMode converted to a string word.

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 getEffectiveAnisotropicDegree().

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.

static getClassType() TypeHandle
static getDefault() SamplerState

Returns a reference to the global default immutable SamplerState object.

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.

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.

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.

getLodBias() float

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

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().

getMaxLod() float

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

getMinLod() float

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

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().

getWrapU() WrapMode

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

getWrapV() WrapMode

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

getWrapW() WrapMode

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

static isMipmap(type: FilterType) bool

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

isPrepared(prepared_objects: PreparedGraphicsObjects) bool

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

property lod_bias float
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.

property magfilter FilterType
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.

property max_lod float
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.

property min_lod float
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.

property minfilter FilterType
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.

prepare(prepared_objects: PreparedGraphicsObjects)

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.

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.

release(prepared_objects: PreparedGraphicsObjects)

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.

setAnisotropicDegree(anisotropic_degree: int)

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)

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.

setLodBias(lod_bias: float)

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.

setMagfilter(filter: FilterType)

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

setMaxLod(max_lod: float)

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.

setMinLod(min_lod: float)

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

setMinfilter(filter: FilterType)

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

setWrapU(wrap: WrapMode)

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)

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)

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

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.

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.

usesMipmaps() bool

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

property wrap_u WrapMode
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.

property wrap_v WrapMode
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.

property wrap_w WrapMode
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.