Unigine::Renderer Class
Header: | #include <UnigineRender.h> |
A basic interface for setting a renderer state (changing rendering passes parameters): pass shader uniforms, set modelview and projection matrices, etc. This class is used for rendering custom nodes (for example, a node inherited from ObjectExtern).
Renderer Class
Enums
RENDER_STEREO_EYE#
Stereo eye enumeration.Members
void clearStates ( ) #
Clears rendering states and textures.The shader will also be cleared.
void clearShader ( ) #
Clears the shader.void setBlendFunc ( Render::PASS pass, const Ptr<Material> & material ) const#
Sets the light blending function for a given rendering pass and material.Arguments
- Render::PASS pass - Rendering pass. One of the following values:
- const Ptr<Material> & material - Material smart pointer.
void setBufferMask ( Render::PASS pass, const Ptr<Material> & material ) const#
Sets the buffer mask for a given rendering pass and material.If the material does not use a depth mask and ambient pass is specified, the BUFFER_COLOR mask will be set; otherwise, the BUFFER_ALL mask will be set.
Arguments
- Render::PASS pass - Rendering pass. One of the following values:
- const Ptr<Material> & material - Material smart pointer.
void setCameraPosition ( const Math::Vec3 & position ) #
Sets a new camera position.Arguments
- const Math::Vec3 & position - New camera position.
Math::Vec3 getCameraPosition ( ) const#
Returns current camera position.Return value
Current camera position.void setDepthFunc ( Render::PASS pass, const Ptr<Material> & material ) const#
Sets depth function for a given rendering pass and material.If the depth_test option of the material is enabled, the DEPTH_GEQUAL function will be used; otherwise the depth comparison function will be disabled.
Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables, except the following: PASS_DEFERRED, PASS_SHADOW, PASS_DEPTH_PRE_PASS, PASS_EMISSION.
- const Ptr<Material> & material - Material smart pointer.
bool hasGeodeticPivot ( ) #
Returns a value indicating if the rendering scene has a GeodeticPivot.Return value
1 if the rendering scene has a GeodeticPivot; otherwise, 0.int getHeight ( ) const#
Returns current screen height.Return value
Screen height.int getWidth ( ) const#
Returns current screen width.Return value
Screen width.Math::Mat4 getIModelview ( ) const#
Returns current inverse view matrix.Return value
Returns current inverse view matrix.void setMaterial ( Render::PASS pass, const Ptr<Material> & material ) #
Sets material and initialize all material textures for the specified rendeting pass.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Material> & material - Material smart pointer.
void setModelview ( const Math::Mat4 & modelview ) #
Sets current view matrix.Arguments
- const Math::Mat4 & modelview - New view matrix to be set.
Math::Mat4 getModelview ( ) const#
Returns current view matrix.Return value
Returns current view matrix.bool isNode ( ) const#
Returns a value indicating if node rendering is in progress.Return value
1 if the node rendering is in progress, otherwise 0.Vector<Ptr<Object>> getObjects ( ) #
Retrieves the list of all rendering scene objects and puts it to the buffer.Return value
Buffer containing all scene objects.void setObliqueFrustum ( bool frustum ) #
Enables or disables obliqueness of the viewing frustum.It is recommended to set oblique viewing frustum using this method, as it doesn't affect the projection matrix. To specify the near clipping plane use the setObliqueFrustumPlane() method.
Arguments
- bool frustum - 1 to enable oblique viewing frustum; 0 to disable it.
bool isObliqueFrustum ( ) const#
Returns a value indicating if the viewing frustum is oblique.Return value
1 if the viewing frustum is oblique; otherwise, 0.void setObliqueFrustumPlane ( const Math::Vec4 & plane ) #
Sets the oblique near clipping plane of the viewing frustum.This method does not affect the projection matrix. To enable the oblique frustum use the setObliqueFrustum() method.
Arguments
- const Math::Vec4 & plane - World coordinates of the oblique near clipping plane to set (Nx, Ny, Nz, D), where Nx, Ny, Nz - coordinates of the plane normal, D - distance from the origin to the plane.
Math::Vec4 getObliqueFrustumPlane ( ) const#
Returns the oblique near clipping plane of the viewing frustum.Return value
World coordinates of the oblique near clipping plane to set (Nx, Ny, Nz, D), where Nx, Ny, Nz - coordinates of the plane normal, D - distance from the origin to the plane.void setOldModelview ( const Math::Mat4 & modelview ) #
Updates the old view matrix.Arguments
- const Math::Mat4 & modelview - Old view matrix to be set.
Math::Mat4 getOldModelview ( ) const#
Returns the old view matrix.Return value
Old view matrix.void setOldProjection ( const Math::mat4 & projection ) #
Updates the old projection matrix.Arguments
- const Math::mat4 & projection - Old projection matrix to be set.
Math::mat4 getOldProjection ( ) const#
Returns the old projection matrix.Return value
Old projection matrix.void setPolygonCull ( Render::PASS pass, const Ptr<Material> & material ) const#
Sets the polygon culling mode for a given rendering pass and material.If the material is one-sided, the back-facing polygons will be culled; otherwise, polygon culling for the material will be disabled.
Arguments
- Render::PASS pass - Rendering pass. One of the RENDER_PASS_* variables.
- const Ptr<Material> & material - Material smart pointer.
Math::mat4 getProjectionWithoutTAA ( ) const#
Returns current projection matrix without TAA.Return value
Projection matrix without TAA.void setProjection ( const Math::mat4 & projection ) #
Updates the current projection matrix.It is not recommended to use this method for setting obliqueness of the near clipping plane of the frustum, as in this case a number of features (such as clouds, shadows, TAA, a number of engine optimizations, etc.) will not function properly. Please, use the setObliqueFrustum() method instead.
Arguments
- const Math::mat4 & projection - Projection matrix to be set.
Math::mat4 getProjection ( ) const#
Returns current projection matrix.Return value
Current projection matrix.bool isReflection ( ) const#
Returns a value indicating if reflection rendering is in progress.Return value
1 if reflection rendering is in progress, otherwise 0.int getReflectionViewportMask ( ) const#
Returns the current reflection viewport mask.Return value
Current reflection viewport mask.void setShaderParameters ( Render::PASS pass, const Ptr<Shader> & shader, bool is_screen_space = 0 ) #
Sets the parameters of the specified shader for a given rendering pass.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Shader> & shader - Shader smart pointer.
- bool is_screen_space - Screenspace flag: 1 to set the parameters for the screen space effect; otherwise 0.
void setShaderParameters ( Render::PASS pass, const Ptr<Shader> & shader, const Ptr<Material> & material, bool is_screen_space = 0 ) #
Sets the parameters of the specified shader for a given rendering pass and material.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Shader> & shader - Shader smart pointer.
- const Ptr<Material> & material - Material smart pointer.
- bool is_screen_space - Screenspace flag: 1 to set the parameters for the screen space effect; otherwise 0.
void setShaderParameters ( Render::PASS pass, const Ptr<Shader> & shader, const Ptr<Material> & material, const Ptr<Object> & object, int surface, bool is_screen_space = 0 ) #
Sets the parameters of the specified shader for a given rendering pass, material, object and surface.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Shader> & shader - Shader smart pointer.
- const Ptr<Material> & material - Material smart pointer.
- const Ptr<Object> & object - Object smart pointer.
- int surface - Surface number.
- bool is_screen_space - Screenspace flag: 1 to set the parameters for the screen space effect; otherwise 0.
void setShaderParameters ( Render::PASS pass, const Ptr<Material> & material, bool is_screen_space = 0 ) #
Sets the parameters of the shader for a given rendering pass and material.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Material> & material - Material smart pointer.
- bool is_screen_space - Screenspace flag: 1 to set the parameters for the screen space effect; otherwise 0.
void setShaderParameters ( Render::PASS pass, const Ptr<Object> & object, int surface, bool is_screen_space = 0 ) #
Sets the parameters of the shader for a given rendering pass, object and surface.Arguments
- Render::PASS pass - Rendering pass. One of the PASS_* variables.
- const Ptr<Object> & object - Object smart pointer.
- int surface - Surface number.
- bool is_screen_space - Screenspace flag: 1 to set the parameters for the screen space effect; otherwise 0.
bool isShadow ( ) const#
Returns a value indicating if shadows are rendered.Return value
1 if shadows are rendered; otherwise, 0.int checkSkipFlags ( int flags ) const#
Returns a value indicating if the specified skip flag is set.Arguments
- int flags - Skip flag.
Return value
1 if the specified skip flag is set; otherwise, 0.static void getAllSurfaces ( Vector <Renderer::RenderSurface> & surfaces ) #
Retrieves all RenderSurfaces visible via the current viewport/camera and puts them to the specified output vector. The RenderSurface structure contains information about an object to which the surface belongs as well as the index of this surface and is defined as follows:struct RenderSurface
{
Ptr<Object> object;
int surface;
};
// implementation of a custom rendering pass
void pass()
{
// declaring a target array to store RenderSurfaces and collecting all currently visible render surfaces to this array
Vector<Renderer::RenderSurface>> surfaces;
Renderer::getAllSurfaces(surfaces);
// creating a new render target and creating a texture for our rendering pass
RenderTargetPtr render_target = Render::getTemporaryRenderTarget();
TexturePtr texture = Renderer::createCustomTexture2D("My Pass Texture", RenderState::getWidth(), RenderState::getHeight(), Texture::FORMAT_RGBA8, Texture::FORMAT_USAGE_RENDER);
// setting necessary textures (color and depth in our case) and enabling the render target
render_target->bindColorTexture2D(0, texture);
render_target->bindDepthTexture(Renderer::getTextureCurrentDepth());
render_target->enable();
// render all visible surfaces in our custom pass if their current material supports this pass
{
RenderState::clearBuffer(RenderState::BUFFER_COLOR, Math::vec4_zero);
for (const auto &s : surfaces)
{
MaterialPtr material = s.object->getMaterial(s.surface);
Render::PASS pass = material->getRenderPass("my_custom_pass");
if (pass == -1)
continue;
RenderState::setDepthFunc(material->isDepthTest() ? RenderState::DEPTH_GEQUAL : RenderState::DEPTH_NONE);
s.object->render(pass, s.surface);
}
}
// disabling the render target and releasing resources
render_target->disable();
render_target->unbindColorTexture(0);
render_target->unbindDepthTexture();
Render::releaseTemporaryRenderTarget(render_target);
}
Arguments
- Vector <Renderer::RenderSurface> & surfaces - Vector to which all rendered surfaces are to be put.
int getSkipFlags ( ) const#
Returns the skip flag set for the rendering viewport.Return value
Skip flag.bool isStereo ( ) const#
Returns a value indicating if stereo rendering is enabled.Return value
1 if the stereo rendering is enabled; otherwise, 0.int getStereoMode ( ) const#
Returns the current stereo mode.Return value
One of the RENDER_STEREO_* variables.Renderer::RENDER_STEREO_EYE getStereoCurrentEye ( ) const#
Returns the current stereo eye.Return value
One of the RENDER_STEREO_EYE_* variables.Ptr<Texture> getTextureAutoExposure ( ) const#
Returns the autoexposure texture.Return value
Autoexposure texture.Ptr<Texture> getTextureAuxiliary ( ) const#
Returns the auxiliary texture.Return value
Auxiliary texture.Ptr<Texture> getTextureBentNormal ( ) const#
Returns the bent normal texture. This texture is used during the Screen-Space Global Illumination stage.Return value
Bent normal texture.Ptr<Texture> getTextureClouds ( ) const#
Returns the clouds texture. This texture is rendered during the separate clouds pass.Return value
Clouds texture.Ptr<Texture> getTextureColor ( ) const#
Returns the color texture.Return value
Color texture.Ptr<Texture> getTextureColorOld ( ) const#
Returns the color old texture.Return value
Color old texture.Ptr<Texture> getTextureColorOldReprojection ( ) const#
Returns the color old reprojection texture.Return value
Color old reprojection texture.Ptr<Texture> getTextureColorOpacity ( ) const#
Returns the color opacity texture.Return value
Color opacity texture.Ptr<Texture> getTextureCurrentDepth ( ) const#
Returns the current depth texture.Return value
Current depth texture.Ptr<Texture> getTextureDOFMask ( ) const#
Returns the DoF mask texture. This texture is used at the camera effects stage.Return value
DoF mask texturePtr<Texture> getTextureGBufferFeatures ( ) const#
Returns the texture that stores intensity of the screen-space bevel effect.Return value
Texture storing intensity of the bevels. The texture is RGBA8, the intensity value is written to the R channel.Ptr<Texture> getTextureGBufferAlbedo ( ) const#
Returns the Gbuffer albedo texture.Return value
Gbuffer albedo texture.Ptr<Texture> getTextureGBufferMaterialMask ( ) const#
Returns the Gbuffer material mask texture.Return value
Gbuffer material mask texture.Ptr<Texture> getTextureGBufferNormal ( ) const#
Returns the Gbuffer normal texture.Return value
Gbuffer normal texture.Ptr<Texture> getTextureGBufferShading ( ) const#
Returns the Gbuffer shading texture.Return value
Gbuffer shading texture.Ptr<Texture> getTextureGBufferVelocity ( ) const#
Returns the Gbuffer velocity texture.Return value
Gbuffer velocity texture.Ptr<Texture> getTextureLights ( ) const#
Returns the array texture storing contents of the deferred light buffer and the deferred reflections buffer. The texture contains four RG11B10F textures: the first layer stores the diffuse light, the second layer stores the specular light, the third one is for the environment reflection color, and the fourth one is for the environment ambient light.Return value
A texture storing contents of the deferred light buffer and the deferred reflections buffer.Ptr<Texture> getTextureOpacityDepth ( ) const#
Returns the opacity depth texture.Return value
Opacity depth texture.Ptr<Texture> getTextureRefraction ( ) const#
Returns the refraction texture.Return value
Refraction texture.Ptr<Texture> getTextureSSR ( ) const#
Returns the SSR texture.Return value
SSR texture.Ptr<Texture> getTextureSSAO ( ) const#
Returns the SSAO texture.Return value
SSAO texture.Ptr<Texture> getTextureSSGI ( ) const#
Returns the SSGI texture.Return value
SSGI texture.Ptr<Texture> getTextureSSShadowShafts ( ) const#
Returns the Screen-Space Shadow Shafts texture.Return value
Screen-Space Shadow Shafts texture.Ptr<Texture> getTextureTransparentBlur ( ) const#
Returns the transparent blur texture. This texture is rendered during the transparent blur pass.Return value
Transparent blur texture.Ptr<RenderTarget> getRenderTarget ( ) const#
Returns the render target.Return value
Render target.Ptr<RenderTarget> getPostRenderTarget ( ) const#
Returns the post texture render.Return value
Post render target.Ptr<Viewport> getViewport ( ) const#
Returns the rendering viewport.Return value
Rendering viewport smart pointer.int getViewportMask ( ) const#
Returns current viewport mask.Return value
Returns current viewport mask.float getZFar ( ) const#
Return current far clipping plane.Return value
Returns current far clipping plane.float getZNear ( ) const#
Returns current near clipping plane.Return value
Returns current near clipping plane.void saveState ( ) #
Saves current renderer matrices.void restoreState ( ) #
Restores current renderer matrices.bool useDynamicReflections ( ) const#
Returns a value indicating if rendering of dynamic reflections is enabled.Return value
1 if rendering of dynamic reflections is enabled; otherwise, 0.bool useOcclusionQueries ( ) const#
Returns a value indicating if the occlusion query test is enabled.Return value
1 if the occlusion query test is enabled; otherwise, 0.bool usePostEffects ( ) const#
Returns a value indicating if rendering of post effects is enabled.Return value
1 if rendering of post effects is enabled; otherwise, 0.bool useShadows ( ) const#
Returns a value indicating if rendering of shadows is enabled.Return value
1 if rendering of shadows is enabled; otherwise, 0.bool useTAA ( ) const#
Returns a value indicating if the Temporal Anti-Aliasing (TAA) is enabled.Return value
1 if the Temporal Anti-Aliasing (TAA) is enabled; otherwise, 0.void setUseTAAOffset ( bool offset ) #
Sets a value indicating if skipping render mode check is enabled for using TAA. Can be used to ensure proper TAA calculation when rendering mode for the Viewport is set to RENDER_DEPTH.Arguments
- bool offset - true to enable skipping render mode check and use TAA; otherwise false.
bool isUseTAAOffset ( ) const#
Returns a value indicating if skipping render mode check is enabled for using TAA. Can be used to ensure proper TAA calculation when rendering mode for the Viewport is set to RENDER_DEPTH.Return value
true if skipping render mode check is enabled for using TAA; otherwise false.bool useVelocityBuffer ( ) const#
Returns a value indicating if rendering to the velocity buffer is enabled.Return value
1 if rendering to the velocity buffer is enabled; otherwise, 0.bool useVisualizer ( ) const#
Returns a value indicating if rendering of the visualizer is enabled.Return value
1 if rendering of the visualizer is enabled; otherwise, 0.Ptr<Texture> getTextureSSCurvature ( ) const#
Returns the texture used by the Screen-Space Dirt (SSDirt) effect.Return value
Curvature texture used by the Screen-Space Dirt (SSDirt) effect.Ptr<Texture> getTextureAutoWhiteBalance ( ) const#
Returns the auto white balance texture.Return value
Auto-white-balance texture.Ptr<Texture> getTextureRefractionMask ( ) const#
Returns the refraction mask texture.Return value
Refraction mask texture.Ptr<Texture> createCustomTexture3D ( const char * name, int width, int height, int depth, int format, int flags = 0 ) #
Creates a custom 3D texture. Such textures can be used in your materials.In your base material:
<!-- ... -->
<texture type="texture_name"/>
<!-- ... -->
Create a corresponding custom texture via code:
// ...
// creating a custom texture
Renderer::createCustomTexture3D("texture_name", 512, 512, 512, Texture::FORMAT_RGBA8);
Arguments
- const char * name - Texture name.
- int width - Texture width, in pixels.
- int height - Texture height, in pixels.
- int depth - Texture depth, in pixels.
- int format - Texture format, one of the Texture::FORMAT_ values.
- int flags - Texture flags. A combination of flags (such as Texture::FORMAT_USAGE_, Texture::SAMPLER_WRAP_, etc.)
Return value
New created custom 3D texture.Ptr<Texture> createCustomTexture2D ( const char * name, int width, int height, int format, int flags = 0 ) #
Creates a custom 2D texture array. Such texture can be used in your materials.In your base material:
<!-- ... -->
<texture type="texture_name"/>
<!-- ... -->
Create a corresponding custom texture via code:
// ...
// creating a custom texture
Renderer::createCustomTexture2D("texture_name", 512, 512, Texture::FORMAT_RGBA8);
Arguments
- const char * name - Texture name.
- int width - Texture width, in pixels.
- int height - Texture height, in pixels.
- int format - Texture format, one of the Texture::FORMAT_ values.
- int flags - Texture flags. A combination of flags (such as Texture::FORMAT_USAGE_, Texture::SAMPLER_WRAP_, etc.)
Return value
New created custom 2D texture.Ptr<Texture> createCustomTexture2DArray ( const char * name, int width, int height, int depth, int format, int flags = 0 ) #
Creates a custom 2D texture array. Such texture can be used in your materials.
<!-- ... -->
<texture type="texture_name"/>
<!-- ... -->
Create a corresponding custom texture via code:
// ...
// creating a custom texture
Renderer::createCustomTexture2DArray("texture_name", 512, 512, 16, Texture::FORMAT_RGBA8);
Arguments
- const char * name - Texture name.
- int width - Texture width, in pixels.
- int height - Texture height, in pixels.
- int depth - Number of elements in the array.
- int format - Texture format, one of the Texture::FORMAT_ values.
- int flags - Texture flags. A combination of flags (such as Texture::FORMAT_USAGE_, Texture::SAMPLER_WRAP_, etc.)
Return value
New created custom 2D texture array.Ptr<Texture> getCustomTexture ( const char * name ) #
Returns a custom texture by its name. Custom textures can be created using createCustomTexture3D(), createCustomTexture3D(), and createCustomTexture3D() methods.Arguments
- const char * name - Custom texture name.
Return value
Custom texture corresponding to the specified name, if it exists, otherwise nullptr.Renderer::CBufferCamera getShaderCBufferCamera ( ) const#
Returns a buffer containing camera parameters to be passed to a custom shader. This method can be used in a callback to obtain camera parameters at a certain stage of the rendering sequence and pass them to a custom shader.Return value
Buffer containing camera parameters to be passed to a custom shader.Renderer::CBufferScattering getShaderCBufferScattering ( ) const#
Returns a buffer containing scattering parameters to be passed to a custom shader. This method can be used in a callback to obtain scattering parameters at a certain stage of the rendering sequence and pass them to a custom shader.Return value
Buffer containing scattering parameters to be passed to a custom shader.Ptr<Light> getCurrentLight ( ) const#
Returns the currently rendered light source. This method can be used to obtain shadow maps for a certain light source in a callback (see BEGIN_SHADOWS callbacks).Return value
Currently rendered light source.void setOverlapEnvironmentTexture ( const Ptr<Texture> & texture ) #
Sets a new environment cubemap texture.Arguments
Ptr<Texture> getOverlapEnvironmentTexture ( ) const#
Returns the currently used environment cubemap texture.Return value
Currently used environment cubemap texture.void resetOverlapEnvironmentTexture ( ) #
Resets the environment cubemap texture to default (no environment texture is used).Ptr<Texture> getTextureNormalUnpack ( ) const#
Returns the texture that stores unpacked normals. Available for the following post-effects: SSR, SSGI, SSRTGI, Shadows screen space.Return value
The texture that stores unpacked normals.Ptr<Texture> getTextureLinearDepth ( ) const#
Returns the texture that stores linear depth data.Return value
The texture that stores linear depth data.void renderMeshStatic ( const Ptr<MeshStatic> & mesh, const Ptr<Material> & material, const char * pass_name, const Math::Mat4 & transform, const Ptr<Camera> & camera ) #
Renders the specified static mesh with the specified material applied to it during the specified render pass as viewed from by specified camera.Arguments
- const Ptr<MeshStatic> & mesh - Static mesh to be rendered.
- const Ptr<Material> & material - Material to be used to render the mesh.
- const char * pass_name - Name of the rendering pass during which the mesh is to be rendered.
- const Math::Mat4 & transform - Transformation to be passed to shader for rendering.
- const Ptr<Camera> & camera - Camera to be used for mesh rendering.
bool isStereoPeripheral ( ) const#
Returns a value indicating if the Stereo Peripheral rendering mode is enabled. This rendering mode is used for HMDs having context (low-res) and focus (high-res) displays.Return value
true if stereo peripheral rendering is enabled; otherwise false.Renderer::CBufferTonemapper getShaderCBufferTonemapper ( ) const#
Last update:
2023-07-08
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)