unreal.CanvasRenderTarget2D
¶
- class unreal.CanvasRenderTarget2D(outer=None, name='None')¶
Bases:
unreal.TextureRenderTarget2D
CanvasRenderTarget2D is 2D render target which exposes a Canvas interface to allow you to draw elements onto it directly. Use CreateCanvasRenderTarget2D() to create a render target texture by unique name, then bind a function to the OnCanvasRenderTargetUpdate delegate which will be called when the render target is updated. If you need to repaint your canvas every single frame, simply call UpdateResource() on it from a Tick function. Also, remember to hold onto your new canvas render target with a reference so that it doesn’t get garbage collected.
C++ Source:
Module: Engine
File: CanvasRenderTarget2D.h
Editor Properties: (see get_editor_property/set_editor_property)
address_x
(TextureAddress): [Read-Write] The addressing mode to use for the X axis.address_y
(TextureAddress): [Read-Write] The addressing mode to use for the Y axis.adjust_brightness
(float): [Read-Write] Static texture brightness adjustment (scales HSV value.) (Non-destructive; Requires texture source art to be available.)adjust_brightness_curve
(float): [Read-Write] Static texture curve adjustment (raises HSV value to the specified power.) (Non-destructive; Requires texture source art to be available.)adjust_hue
(float): [Read-Write] Static texture hue adjustment (0 - 360) (offsets HSV hue by value in degrees.) (Non-destructive; Requires texture source art to be available.)adjust_max_alpha
(float): [Read-Write] Remaps the alpha to the specified min/max range, defines the new value of 1 (Non-destructive; Requires texture source art to be available.)adjust_min_alpha
(float): [Read-Write] Remaps the alpha to the specified min/max range, defines the new value of 0 (Non-destructive; Requires texture source art to be available.)adjust_rgb_curve
(float): [Read-Write] Static texture RGB curve adjustment (raises linear-space RGB color to the specified power.) (Non-destructive; Requires texture source art to be available.)adjust_saturation
(float): [Read-Write] Static texture saturation adjustment (scales HSV saturation.) (Non-destructive; Requires texture source art to be available.)adjust_vibrance
(float): [Read-Write] Static texture “vibrance” adjustment (0 - 1) (HSV saturation algorithm adjustment.) (Non-destructive; Requires texture source art to be available.)alpha_coverage_thresholds
(Vector4): [Read-Write] Alpha values per channel to compare to when preserving alpha coverage.asset_import_data
(AssetImportData): [Read-Only] Asset Import Dataasset_user_data
(Array(AssetUserData)): [Read-Write] Array of user data stored with the assetauto_generate_mips
(bool): [Read-Write] Whether to support Mip maps for this render target texturechroma_key_color
(Color): [Read-Write] The color that will be replaced with transparent black if chroma keying is enabledchroma_key_texture
(bool): [Read-Write] Whether to chroma key the image, replacing any pixels that match ChromaKeyColor with transparent blackchroma_key_threshold
(float): [Read-Write] The threshold that components have to match for the texel to be considered equal to the ChromaKeyColor when chroma keying (<=, set to 0 to require a perfect exact match)clear_color
(LinearColor): [Read-Write] the color the texture is cleared tocomposite_power
(float): [Read-Write] default 1, high values result in a stronger effect e.g 1, 2, 4, 8 this is no slider because the texture update would not be fast enoughcomposite_texture
(Texture): [Read-Write] Can be defined to modify the roughness based on the normal map variation (mostly from mip maps). MaxAlpha comes in handy to define a base roughness if no source alpha was there. Make sure the normal map has at least as many mips as this texture.composite_texture_mode
(CompositeTextureMode): [Read-Write] defines how the CompositeTexture is applied, e.g. CTM_RoughnessFromNormalAlphacompression_no_alpha
(bool): [Read-Write] If enabled, the texture’s alpha channel will be discarded during compressioncompression_quality
(TextureCompressionQuality): [Read-Write] The compression quality for generated textures.compression_settings
(TextureCompressionSettings): [Read-Write] Compression settings to use when building the texture.defer_compression
(bool): [Read-Write] If enabled, defer compression of the texture until save.dither_mip_map_alpha
(bool): [Read-Write] When true, the alpha channel of mip-maps and the base image are dithered for smooth LOD transitions.downscale
(PerPlatformFloat): [Read-Write] Downscale source texture, applied only to textures without mips 0.0 - use scale value from texture group 1.0 - do not scale texture > 1.0 - scale texuredownscale_options
(TextureDownscaleOptions): [Read-Write] Texture downscaling optionsfilter
(TextureFilter): [Read-Write] The texture filtering mode to use when sampling this texture.flip_green_channel
(bool): [Read-Write] When true the texture’s green channel will be inverted. This is useful for some normal maps.force_pvrtc4
(bool): [Read-Write] For DXT1 textures, setting this will cause the texture to be twice the size, but better looking, on iPhoneglobal_force_mip_levels_to_be_resident
(bool): [Read-Write] Global and serialized version of ForceMiplevelsToBeResident.gpu_shared_flag
(bool): [Read-Write] Whether to support GPU sharing of the underlying native texture resource.lod_bias
(int32): [Read-Write] A bias to the index of the top mip level to use.lod_group
(TextureGroup): [Read-Write] Texture group this texture belongs tolossy_compression_amount
(TextureLossyCompressionAmount): [Read-Write] How aggressively should any relevant lossy compression be applied.max_texture_size
(int32): [Read-Write] The maximum resolution for generated textures. A value of 0 means the maximum size for the format on each platform, except HDR long/lat cubemaps, which default to a resolution of 512.mip_gen_settings
(TextureMipGenSettings): [Read-Write] Per asset specific setting to define the mip-map generation properties like sharpening and kernel size.mip_load_options
(TextureMipLoadOptions): [Read-Write] The texture mip load options.mips_address_u
(TextureAddress): [Read-Write] AutoGenerateMips sampler address mode for U channel. Defaults to clamp.mips_address_v
(TextureAddress): [Read-Write] AutoGenerateMips sampler address mode for V channel. Defaults to clamp.mips_sampler_filter
(TextureFilter): [Read-Write] Sampler filter type for AutoGenerateMips. Defaults to match texture filter.never_stream
(bool): [Read-Write] Never Streamnum_cinematic_mip_levels
(int32): [Read-Write] Number of mip-levels to use for cinematic quality.on_canvas_render_target_update
(OnCanvasRenderTargetUpdate): [Read-Write] Called when this Canvas Render Target is asked to update its texture resource.padding_color
(Color): [Read-Write] The color used to pad the texture out if it is resized due to PowerOfTwoModepower_of_two_mode
(TexturePowerOfTwoSetting): [Read-Write] How to pad the texture to a power of 2 size (if necessary)preserve_border
(bool): [Read-Write] When true the texture’s border will be preserved during mipmap generation.render_target_format
(TextureRenderTargetFormat): [Read-Write] Format of the texture render target. Data written to the render target will be quantized to this format, which can limit the range and precision. The largest format (RTF_RGBA32f) uses 16x more memory and bandwidth than the smallest (RTF_R8) and can greatly affect performance. Use the smallest format that has enough precision and range for what you are doing.size_x
(int32): [Read-Write] The width of the texture.size_y
(int32): [Read-Write] The height of the texture.srgb
(bool): [Read-Write] This should be unchecked if using alpha channels individually as masks.target_gamma
(float): [Read-Write] Will override FTextureRenderTarget2DResource::GetDisplayGamma if > 0.use_legacy_gamma
(bool): [Read-Write] A flag for using the simplified legacy gamma space e.g pow(color,1/2.2) for converting from FColor to FLinearColor, if we’re doing sRGB.virtual_texture_streaming
(bool): [Read-Write] Is this texture streamed in using VT
- classmethod create_canvas_render_target2d(world_context_object, canvas_render_target2d_class, width=1024, height=1024) → CanvasRenderTarget2D¶
Creates a new canvas render target and initializes it to the specified dimensions
- Parameters
world_context_object (Object) – The world where this render target will be rendered for
canvas_render_target2d_class (type(Class)) – Class of the render target. Unless you want to use a special sub-class, you can simply pass UCanvasRenderTarget2D::StaticClass() here.
width (int32) – Width of the render target.
height (int32) – Height of the render target.
- Returns
Returns the instanced render target.
- Return type
- get_size() -> (width=int32, height=int32)¶
Gets a specific render target’s size from the global map of canvas render targets.
- Returns
width (int32): Output variable for the render target’s width
height (int32): Output variable for the render target’s height
- Return type
tuple
- property on_canvas_render_target_update¶
[Read-Write] Called when this Canvas Render Target is asked to update its texture resource.
- Type
- receive_update(canvas, width, height) → None¶
Allows a Blueprint to implement how this Canvas Render Target 2D should be updated.
- Parameters
canvas (Canvas) – Canvas object that can be used to paint to the render target
width (int32) – Width of the render target.
height (int32) – Height of the render target.
- update_resource() → None¶
Updates the the canvas render target texture’s resource. This is where the render target will create or find a canvas object to use. It also calls UpdateResourceImmediate() to clear the render target texture from the deferred rendering list, to stop the texture from being cleared the next frame. From there it will ask the rendering thread to set up the RHI viewport. The canvas is then set up for rendering and then the user’s update delegate is called. The canvas is then flushed and the RHI resolves the texture to make it available for rendering.