This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API Reference
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Render

Gui to Texture#

This sample demonstrates how to render GUI elements into a texture using Gui.Render(). Instead of drawing directly to the screen, the GUI is redirected to a custom framebuffer, which isolates its rendering pipeline and allows the resulting texture to be applied to materials.

The GuiToTexture component supports two update modes:

  • In manual mode, the texture is updated only when explicitly calling RenderToTexture() method. This is used in the WidgetClock component, where the GUI (a digital clock) is re-rendered once per second, only when the displayed time changes.

  • Automatic mode is enabled by default and updates the GUI texture every frame. This is demonstrated in the WidgetNoSignal component, where a "No Signal" label moves across the screen like a screensaver. Because the position of the widget changes every frame, the texture must be continuously updated to reflect those changes.

The render flow involves saving and clearing the current render state, binding a texture, configuring the viewport, rendering the GUI widgets, and restoring the render state. Mipmaps are also generated to ensure proper filtering at different scales and distances.

You can use this sample to display dynamic GUI elements on in-game monitors, control panels, or other similar surfaces.


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/gui_to_texture

Material Parameters#

Changing parameters of materials at runtime.

The Materials sample illustrates how to change the following parameters of materials in runtime:


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/material_parameters

Weapon Clipping#

In first-person games, weapon models can clip through walls or geometry when the camera gets too close. This sample solves the problem by rendering the weapon separately into a texture and overlaying it on top of the main camera view.

The setup uses two cameras with identical transforms to keep their views aligned. Viewport masks for cameras are set via UnigineEditor: the main camera renders everything except the weapon, while the secondary (weapon) camera renders only the weapon. The weapon view is captured into a texture using Viewport.RenderTexture2D().

Each frame, this texture is overlaid onto the screen using Render.RenderScreenMaterial(), compositing the weapon on top of the environment. The component handles screen resizing, maintains isolated render states, and offers optional settings like skipping shadows in the weapon rendering pass.

This approach keeps the weapon always visible, even when the camera is close to walls, without interfering with the main rendering pipeline


SDK Path: <SDK_INSTALLATION>data/csharp_component_samples/render/weapon_clipping

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 2025-06-30
Build: ()