DarkBASIC Professional Help File

DX11 SET NEW CAMERA RENDER TARGET

Creates a new render target image and sets it as the render target for the specified camera.

This function was named DX11 SET CAMERA RENDER TARGET prior to build version 0.4.7.5

A render target is an image that everything the camera sees will be drawn to.
One of the features of DirectX 11 is that you can have up to 8 render targets that can be drawn to
in a single render pass. Perfect for deferred shading.
When using multiple render targets your pixel shader will output a struct which contains members using
the SV_TARGET (SV_TARGET0 - SV_TARGET7 are valid) semantic.
Take note that while the different render targets associated to the same camera can have different formats,
they must have the same dimensions. This function will fail if you try to set several render targets having
different sizes.
Only a single render target per camera can exist in DX10 mode however, which would then be bound to stage 0.
The render target image created by this function can be used as a texture for objects / limbs, however it can
not be assigned as a texture to any object that is drawn to this camera. You can use the camera mask of the
object, manually exclude it, change its texture before rendering the camera writing to its render target texture or
some other approach to avoid this.
Note that you will have to delete the returned image when you are done with it; for safety reasons it will not be
automatically deleted when the camera is / the render target is released. This is to ensure that you will not
accidentally end up with an invalid image pointer if you used the render target image as a texture for something else or similar.

Syntax

    Return Dword rtimage  = DX11 SET NEW CAMERA RENDER TARGET(camera, width, height, [id], [format])

Parameters

    camera

> Dword
> The camera to create / replace the render target for.

    width

> Dword
> The width of the render target to create. Must be the same for all render targets bound to the same camera!.

    height

> Dword
> The height of the render target to create. Must be the same for all render targets bound to the same camera!.

    [Optional] id

> Dword
> The render target id. Valid values are 0..7. Refer to them in your pixel shader output as SV_TARGETX where X is this id. Defaults to 0.

    [Optional] format

> Dword
> The format of the render target image to be created. Corresponds directly to the DXGI_FORMAT enumeration that you can find on MSDN. Defaults to B8G8R8A8.

Returns

An image that corresponds to the created render target, or 0 if the provided ID is out of range.

See also

CAMERA Functions Menu
DX11 Function Categories