concepts rendering - melowntech/vts-browser-unity-plugin GitHub Wiki
Rendering
The Map represents a data source only, it does not render anything. The actual rendering is done with Camera Cmd Bufs or Camera Objects attached to Game Object with Unity Camera component.
Camera
Multiple Cameras
The VTS Browser as well as the Unity plugin allows for multiple cameras on single map. This is as simple as attaching some VTS Camera component to multiple Unity cameras.
Stereoscopic Rendering
Use Camera Objects. If you notice issues with missing objects at screen edges, try experimenting with cullingOffsetDistance camera option.
VTS vs. Unity Control
The Camera component has some properties, that can be set to Vts or Unity:
- Transformation
- VTS - the camera position and rotation are updated to correspond to the internal camera in VTS, which is controlled by Navigation.
- Unity - internal VTS camera is updated to correspond to the unity transformation.
- Near and Far
- VTS - the distance to near and far clipping planes is computed by VTS in such a way that it works well for the used position and the unity camera component is updated accordingly. Note that the clipping planes are computed independently of the Game Objects that should be rendered. VTS will only consider the map (terrain) to compute the planes.
- Unity - internal VTS camera near and far are updated to correspond to the setting on the unity camera component.
Materials
The Camera Cmd Bufs has a field for material that will be used for the rendering.
The Camera Objects will instantiate the prefabs. It uses separate prefabs for opaque and semi-transparent objects.
Shaders
The VTS has some additional requirements on the shader.
- two uv sets - internal and external
- two textures - color and mask (the two uv sets do not directly map to the textures)
- discarding fragments by uv (always uses external uv)
- discarding fragments with the mask texture (uses internal or external uv, based on uniform value)
- color with the texture (same uv as mask) and uniform
There are 3 types of shaders provided with the plugin.
- Unlit - this is the most basic shader, it just renders the map without any light or shadow interactions.
- Shadowed - this shader does no light calculations, but the color is dimmed by received shadows.
- Surface - this is fully featured shader that allows for interaction with multiple lights with or without shadows.
All of these shaders have two variants, one for opaque objects and one for semi-transparent objects.
See Atmosphere for information about integrating VTS atmosphere.