API Documentation
Public Member Functions | Static Public Member Functions | List of all members
nkAstraeus::ImageEnvironmentEffect Class Referencefinal

Effect using a texture as an input to use it as an environment for the view. More...

Inheritance diagram for nkAstraeus::ImageEnvironmentEffect:
nkAstraeus::Effect

Public Member Functions

 ImageEnvironmentEffect (System *system) noexcept
 
virtual ~ImageEnvironmentEffect ()
 
nkGraphics::TexturegetSourceTexture () const
 
nkGraphics::SamplergetSourceSampler () const
 
nkGraphics::CameragetSourceCamera () const
 
IMAGE_ENVIRONMENT_PROJECTION getSourceProjection () const
 
void setSourceTexture (nkGraphics::Texture *value)
 
void setSourceSampler (nkGraphics::Sampler *value)
 
void setSourceCamera (nkGraphics::Camera *value)
 
void setSourceProjection (IMAGE_ENVIRONMENT_PROJECTION value)
 
virtual bool load () override
 
virtual void unload () override
 
- Public Member Functions inherited from nkAstraeus::Effect
 Effect (EFFECT_TYPE type) noexcept
 
virtual ~Effect ()
 
nkMemory::StringView getName () const
 
nkGraphics::ShadergetShader () const
 
EFFECT_TYPE getType () const
 
void setName (nkMemory::StringView value)
 

Static Public Member Functions

static nkMemory::UniquePtr< ImageEnvironmentEffectcreate (System *system=nullptr)
 
static IMAGE_ENVIRONMENT_PROJECTION getRequiredProjection (const ImageEnvironmentEffectInfo &info)
 

Detailed Description

Effect using a texture as an input to use it as an environment for the view.

This effect allows to create environment only based on images. For instance, it can use cubemaps as input, which will make it use a given camera's direction to derive pixel directions to sample the texture from.

This effect can be used to easily add a more living background than the clear color.

Constructor & Destructor Documentation

◆ ImageEnvironmentEffect()

nkAstraeus::ImageEnvironmentEffect::ImageEnvironmentEffect ( System system)
noexcept

Constructor. Alternatively, see ImageEnvironmentEffect::create(), or EffectManager::createOrRetrieve().

Parameters
systemThe system the resource should live in.

◆ ~ImageEnvironmentEffect()

virtual nkAstraeus::ImageEnvironmentEffect::~ImageEnvironmentEffect ( )
virtual

Destructor. See EffectManager::erase().

Member Function Documentation

◆ getSourceTexture()

nkGraphics::Texture* nkAstraeus::ImageEnvironmentEffect::getSourceTexture ( ) const
Returns
The source texture used.

◆ getSourceSampler()

nkGraphics::Sampler* nkAstraeus::ImageEnvironmentEffect::getSourceSampler ( ) const
Returns
The source sampler used.

◆ getSourceCamera()

nkGraphics::Camera* nkAstraeus::ImageEnvironmentEffect::getSourceCamera ( ) const
Returns
The source camera used, if any, nullptr else.

◆ getSourceProjection()

IMAGE_ENVIRONMENT_PROJECTION nkAstraeus::ImageEnvironmentEffect::getSourceProjection ( ) const
Returns
The source projection used.

◆ setSourceTexture()

void nkAstraeus::ImageEnvironmentEffect::setSourceTexture ( nkGraphics::Texture value)

Sets the source texture that will be used by the effect.

Parameters
valueThe texture to use as source.
Remarks
This parameter can be changed without reloading the effect, provided the texture has the same projection than the texture previously set. See setSourceProjection() for more info about the projections.

◆ setSourceSampler()

void nkAstraeus::ImageEnvironmentEffect::setSourceSampler ( nkGraphics::Sampler value)

Sets the sampler that will be used by the effect. If none or nullptr is provided, then a default sampler will be used.

Parameters
valueThe sampler to use if required, nullptr to reset to the default one.
Remarks
This parameter can be changed without reloading the effect.

◆ setSourceCamera()

void nkAstraeus::ImageEnvironmentEffect::setSourceCamera ( nkGraphics::Camera value)

Sets the camera that will be used to derive the required pixel directions. If none or nullptr is provided, then the camera used by the context using the effect at drawing time will be used.

Parameters
valueThe camera to use if required, nullptr to reset to the default behavior.
Remarks
This parameter can be updated without reloading the effect. Note that this is only relevant for source projections using the camera direction (for instance, FLAT does not use any camera).

◆ setSourceProjection()

void nkAstraeus::ImageEnvironmentEffect::setSourceProjection ( IMAGE_ENVIRONMENT_PROJECTION  value)

Sets the projection to use to correctly recompute the source texture's uvs. Defaults to AUTO, for which the projection will be EQUIRECTANGULAR for a 2D texture, and CUBE for a cubemap. This will be derived at loading time from the set source texture. If the texture is not loaded at that time, it is better to set it manually from this setter to be sure the right projection will be picked up during loading.

Parameters
valueThe projection to assume for the source texture set.
Remarks
This parameter requires a reload of the effect to be changed. As such, if a texture requiring a new projection is set, the effect needs to be reloaded. In such case, the projection can be updated manually, or AUTO will pick up the change (from EQUIRECTANGULAR to CUBE, for instance).

◆ load()

virtual bool nkAstraeus::ImageEnvironmentEffect::load ( )
overridevirtual

Loads the effect and make it ready for rendering.

Returns
Whether the loading went well (true) or not (false).

Implements nkAstraeus::Effect.

◆ unload()

virtual void nkAstraeus::ImageEnvironmentEffect::unload ( )
overridevirtual

Unloads the effect and its internal memory. After that, the effect is unusable for rendering.

Implements nkAstraeus::Effect.

◆ create()

static nkMemory::UniquePtr<ImageEnvironmentEffect> nkAstraeus::ImageEnvironmentEffect::create ( System system = nullptr)
static

Creates an instance of the class, and returns ownership over it.

Parameters
systemThe system the resource should live in. If left to nullptr, will seek the singleton instance of the system.
Returns
Ownership over the created instance of the class.
Remarks
The instance is not part of any manager if instantiated this way. If the resource's lifetime should be managed within the manager, then calling ComplexEffectManager::createOrRetrieve() might be a better option. Alternatively, registering it afterwards through ComplexEffectManager::record() is another option.

◆ getRequiredProjection()

static IMAGE_ENVIRONMENT_PROJECTION nkAstraeus::ImageEnvironmentEffect::getRequiredProjection ( const ImageEnvironmentEffectInfo &  info)
static

Allows to access the projection that will be used from a given info state. Used internally to derive the final projection used when AUTO is selected.

Parameters
infoThe information structure the selection will be based on.
Returns
The projection that will be used by the effect for the given info state.

The documentation for this class was generated from the following file: