Title: CS461561 Virtual Environments: Principles
1CS461/561Virtual Environments Principles
ApplicationsOptimizations
- 4-04-2007
- Prof. Searleman
- SC375
- jets_at_clarkson.edu
2Outline
- Presentations
- topics must be approved 1 week in advance
- schedule will be posted on webpage
- VRpong modelling the paddle
- Model Management Optimizations
- Virtools VR Pack
- Do the tutorial on portals
- Gauthier, Chapter 8, section 10 (pp. 399-404)
3Model Management
- Model management combines techniques designed to
help the VR engine render complex virtual
environments at (predefined) interactive rates
without a significant impact on the simulation
quality - Approaches
- Select object level of detail
- Cell Segmentation
- Off-line precomputations
- Database management
4Model Optimization
- use texture maps (reduces the level of geometric
detail) - use primitive solids (sphere, cube, ) reduce
the number of polygons - use distance-dependent levels of detail (LODs)
- choose lighting special effects carefully
- use billboards (planar objects that always face
the viewpoint) - selectively load objects (determine which part of
the model is being viewed and so which geometry
needs to be loaded and rendered and which
behavior scripts need to be active.
5LOD
- Have a database containing, for each object, a
dataset of that object with different numbers of
polygons - Static use pre-determined distance from virtual
camera to select the object model - Adaptive
- Allow multiple LODs to co-exist within the same
model - Dynamically select appropriate LOD to assure a
constant frame refresh rate
6Frame rates (reminder)
- Minimum requirement for interaction 10 frames
per second w/ latency of 0.1 second (Rosenblum
Cross, 1997) - Rendering of the virtual environment ranges
from simple wire-frame to smooth Gourand shading
to lighting effects and transparency. If too
complex, the frame rate will degrade. - Minimum requirement at which a stream of still
images are perceived as smooth animation about
20 frames per second
7Cutting Objects
When a Virtools camera see an object, that means
the entire mesh is in memory. The more complex
the object is, more the memory is filled, even if
only a very little part is visible. Example a
big landscape with mountains a small character.
If you separate this big mesh in several parts,
when the camera looks in a direction, then parts
behind you are not loaded in the memory, saving
rendering time.
8Subdivision Level
Particularly for round objects, you have to
choose a good subdivision level. The visual
quality depends only if you have correctly
adapted the optimization to the smooth tolerance
of the render engine. The normal angle to keep
maximum smoothing is 180 , try to keep this
value and see the difference between the
subdivision levels in this example of columns.
In the above example, notice that the quality is
not affected when you optimize from 240 faces to
96. The column smoothing aspect is perfect you
can only see the difference near the ground due
to the topology which has changed. Even the
optimization level of 48 faces could be enough
for a background object, far from the camera
position.
9Polygon Count
The sphere on the left has approximately fifty
polygons, and the sphere on the right has
approximately two thousand faces. Both are
recognizable as spheres, but one is much more
accurate, at a cost of processing time.
10Billboard (3D Sprite)
A billboard is a plane composed of 2 faces that
can be auto-oriented to follow the camera
position. Generally you apply this behavior for
circular objects. In the previous example, the
column can be transformed to a billboard. You
render a high def column that you map on a plane,
and you make this plane become a billboard. An
alpha mask will control the border cut. In
Virtools you create a 3Dsprite entity, load the
column picture and its alpha, and active the
billboard flag to the 3Dsprite. Typically
billboards are used to simulate trees in a huge
landscape. Each image tree is loaded in a
3Dsprite and auto-orientated in the Y axis.
11Simplified Collision Objects
When you need collision detection, you can make
collision objects very simple and optimized,
around the real complex objects. They will be
invisible for rendering, and used only for
collision behaviors. It is faster to test a
collision on a simple model, and even though it
is more complex than a bounding box, it can
provide more realistic behaviors. Essentially you
are making your own bounding box. It is very
useful in a complex building or landscape to
quickly limit some character moves, and to block
some zones. Above, the collision objects (in
blue) are only composed of few faces. This test
is very fast in Virtools, and they are invisible
and not calculated during the rendering.
12Choosing between 3D objects maps
What optimization level has to be applied to an
object or a landscape zone? Do we need to keep
an object in real 3D or is a mapping enough?
Sometimes a mapping is more visual than a real
object and produces a great optimization. But
sometimes you must reduce the number of maps and
it's better to keep the real object. The choice
is really given by the scenario. If a camera can
go very near to an object, it should be kept in
3D and the more you have to zoom in, the more
you have to keep topologic details. Here, the
background objects became a texture map which is
pre-lit.
13Choosing Rendering Techniques
You have to choose a good rendering technique for
objects in a scene, depending on the desired
quality and optimization constraints. Several
techniques are possible to render a mesh a
colored material ( without any texture ), vertex
lighting, simple texture mapping, mapping with
prelighted textured. It is also possible to
combine these methods to achieve a more
sophisticated result.
14Default render
Objects are simply colored with their materials
without using texture maps. There is no
particular visual work this is essentially a
rush level technique to quickly ensure that
objects run correctly in the real time engine.
15Vertex lighting
In this technique lighting values are directly
written in the object topology. You can write a
color value (RGB) and even a transparency value
into each polygon vertex. The principal advantage
is that the object doesn't need light spots any
more in order to be rendered (otherwise, it
would be black without light spots ) The object
is auto lighted in the real time engine and the
calculation to render it is much faster. However,
you will have to combine this with other
techniques like mapping, to get good results.
16Texture Mapping (UV)
First you create projections of pictures over the
objects. Then mapping coordinates of these
projections _ UV_ are written in the object
topology and you can tweak then. You can project
realistic pictures so as to increase the quality
aspect of your scene.
17Pre-lighting
In pre-lighting, the image maps are pre-lit maps
including lights and shadows. These maps are
obtained with 3D software, making a rendering of
a high definition object with very detailed
textures, full effects, lights, shadows, complex
shaders. The object is rendered with multi camera
views to cover all its angles. Then these high
quality rendered pictures representing the object
are organized in a texture map compilation.
Finally you re-map this compilation in the real
time version of the object. This can give the
illusion of a high quality object, and is a good
way to optimize the number of faces in your
scene. But be careful, on the other side, you may
increase the number of textures. So don't use
pre-lighting systematically. Still, most
real-time, 3D games use pre-lighting.
Here a high definition front camera view render
was done, representing the wall and the objects
behind with all details, lights and shadows. Then
in the low definition scene, the background
objects and the background itself are completely
removed.
18Merging Techniques
Combining these different techniques together can
achieve very good results. Generally, vertex
lighting is used with mapping it is in fact its
principal purpose. Similarly, if you combine this
vertex lighting with pre-lighted maps you could
reach a really high quality visual level, and a
very good scene optimization.
19Choosing Lighting
- There are three different lights in Virtools.
Shown left to right in increasing complexity (and
realism) the lights are - directional,
- point, and
- spot.
(a) Directional like a bank of lights projecting
from a plane in the same direction used to
emphasize extra, directed lighting coming from an
outside window, or to easily illuminate the floor
of an entire composition.
20Choosing Lighting
(b) Point originates at a single point and
encompasses a spherical area within which there
is a falloff factor, allowing simulation of such
light sources as a candle or a lamp which start
off bright in the center.
21Choosing Lighting
(c) Spot has a central cone of illumination,
illustrated by the blue lines, where the light is
the most intense and even. Beyond this central
area out to the orange boundaries, the light
falls off. Useful for overhead room lighting
situations, such as the light over a dining room
table, an exterior setting as a streetlamp, or
car headlights.
22Map Size Constraints
Due to how graphic cards process texture maps,
the maps must have a size that is a power of 2,
although they are not obliged to be square (like
128x128). Isolate textures that will be
repeated (tileable maps) from others (like
pre-lit maps, which are grouped in
compilations). Tileable maps can't be compiled
because of their borders -- the left border must
be identical to the right one to produce the
repetition. (Same for the top and bottom).
23Map Level
If you want to make either tileable pictures or
non-tileable compilations, say in 256x256 for
example, it's recommended to work first in big
resolutions like 512x512. That way you could
later choose between one level or another. If
your final Virtools composition still has a good
frame rate with the larger maps, you could keep
them. You could make several composition
versions to run on several hardware
configurations, using either 128 level maps or
256, 512, Graphic cards generally have 32 or
64 of texture memory, and recent cards accept
2048 or higher level maps.
24Levels Scenes
The level contains all the objects of the
composition, and a given scene only contains
references on some or all of these objects.
Within the Level Manager, level and scenes appear
almost identical. In the Level / Scene Setup
window, if you want a setup to be used when you
launch a scene, the Use settings at Scene Start
must be checked.
25Scenes
Creating / Swapping / Deleting Scenes To create a
scene, use the Create Scene button on the left
toolbar of the level manager. The scene is added
in the list of scenes available in this same
toolbar. To swap from one scene to another, click
on the scene you want to activate in this list,
the current scene is deactivated at the same
time. To delete a scene, select it in the Level
Manager and delete it from the context menu, or
press the Delete" key. Click on the Level
button of the left toolbar to go back to the
level and access any object of any scene. Adding
Objects to a Scene There are 2 methods to add a
new object to a scene (1) Select the level where
you want the object to be and drop your resource
in the 3D Layout. The object is directly added to
the currently active scene and to the level. (2)
Drop the resource on the 3D Layout adding the
object to the level. Then, in the Level Manager,
drag and drop the object to your scene.
26Places
A place is a geographic area of the world that
creates a common parent to the objects it
contains, and is used to optimize Rendering. It
can contain only 3D Entities and derivative
types. Places appear in the Level Manager as
shown. It is also a good way to organize your
objects within the level manager.
Creating / Deleting Places To create a place,
click on the Create Place button of the left
toolbar of the Level Manager. To delete it,
select it in the Level Manager and choose
"Delete" in the contextual menu or press the
Delete" Key. Adding Objects to a place To add
an object to a place, go to the Level Manager,
select the object and drag and drop it directly
in the place.
27Place Hierarchy
Example on the left is the default Virtools
configuration, where every object is a child of
the root on the right, these objects are
grouped into places, where each object appears
exactly once in a region.
28Rendering Places
Without Places
With Places
In the above, the position and orientation of the
camera is shown as an orange arrow. Without
places all four rooms are rendered, even though
the camera can only see the blue room and part of
the yellow room. With places activated, only the
two rooms that are visible to the camera are
rendered.
29Portals
Portals are a contiguous zone between two areas,
and are used with "places" which are assigned to
it. This means you need to organize your scene
into several different places, and then assign
the places to each contiguous portal (using the
Place Setup window).
30Portals
Places work in conjunction with portals the
location of which are indicated by the green
circles above. For places to be accurately
rendered or not rendered, portals identify each
opening between places. Each doorway and window
to and from every place must have a portal, which
is then configured in Virtools to connect a
certain place to another place. The camera used
by the person navigating the 3D environment is
set to use the places and it tells Virtools what
portals it can see as the user moves through the
world. As a new portal becomes visible, the
place it is connected to is added to the list of
places to render. Likewise, as the last portal
to a place passes from view, that place is no
longer rendered.
31Optimization Summary
- use texture maps (reduces the level of geometric
detail) - use primitive solids (sphere, cube, ) reduce
the number of polygons - use distance-dependent levels of detail (LODs)
- choose lighting special effects carefully
- use billboards (planar objects that always face
the viewpoint) - selectively load objects (determine which part of
the model is being viewed and so which geometry
needs to be loaded and rendered and which
behavior scripts need to be active.
32Virtools VR Pack
- complex VR systems
- - PC clusters
- - stereovision
- - tracking
- two versions
- - Publishing edition
- - Development edition
33VR Pack Concepts
- distribution
- runs the composition on each PC in a cluster,
where each host uses a different camera - swaplock/genlock
- for cluster synchronization
-
34Distributed Composition
- cluster of hosts one master the others are
slaves - each host has a unique Id number
- the master is Id0
- two ways to distribute the composition
- 1. Cause distribution
- 2. Effect distribution
35Cause Distribution
- master reads the peripheral state (VR trackers
and controllers, keyboard, mouse, etc.) and sends
this state to every host - slave waits for this state to arrive, and sends
an ack to the master - when all hosts have the shared state, they
compute their next frame - VR Distrib BB synchronizes time random events
- advantage simple
- disadvantage if a slave goes down, the whole
cluster has to be informed to reset all elements
that rely on the previous frame
36Effect Distribution
- master computes the result of the user
interaction, and shares this with the slaves
(time and random synchronization are not used) - creates more network traffic requires more
complex scripting - good for environments where slaves often stop and
restart
37VR Pack Resources Docs
- VRResources.rsc
- program filesVirtoolsVirtools Dev3.0 VRPack
- Virtools VR Pack 1.6.4 User Guide
- VIRTOOLSHOMEVRPackDoc
- Compiled help files VRimmersive VRDistrib
- VIRTOOLSHOMEDocumentation
- Demos ChateauLaval, VRShowcase, etc.
- VIRTOOLSHOMEVRPack Samples
38VR Distrib BB
All Ready activated the first time all expected
hosts join the cluster.Waiting for all
activated while the cluster waits for hosts.Host
Missing activated when a host leaves the
cluster.All Again activated when all expected
hosts join the cluster again.
This building block shares values between the
master and slaves to allow you to create
distributed interactivity you can add as many
Outputs Parameters (pOut) as you want (from any
type). The Input Parameters (pIn) will be added
automatically, and pIn values of the Master
script are then broadcast to the entire cluster
via the pOut values.
39VR Host Id BB
Master activated if host is the master
(Id0).Slave activated if host is a slave
(Id!0).Error activated when an error
occurs.Host Id computer's identity.Hosts
Number number of computers in the cluster.
40VR Distrib BB
Out all tokens using Parameter In (pIn) names
were found.Error at least one token using pIn
names was not found.
pIn and pOut you can create as many Parameter
Out (pOut) as the number of tokens that you want
to retrieve from the config file. To do so-
Right click on the BB and select the
"construct\Add Parameter Out" sub menu.- Specify
the token type to the pOut that is created it
can be any Virtools parameter type.- specify the
token name in the corresponding pIn.
41VR Get Config Token BB
Out all tokens using Parameter In (pIn) names
were found.Error at least one token using pIn
names was not found.
pIn and pOut you can create as many Parameter
Out (pOut) as the number of tokens that you want
to retrieve from the config file. To do so-
Right click on the BB and select the
"construct\Add Parameter Out" sub menu.- Specify
the token type to the pOut that is created it
can be any Virtools parameter type.- specify the
token name in the corresponding pIn.