BS Contact
VRML Tips
Here are some ideas, tips, optimization hints
and examples for VRML world builders.
Doom II worlds converted to VRML
Worlds for the DOOM II Game from ID-software are
stored in a format that is convertable to VRML. In addition there
are shareware and freeware tools available for editing and creating
worlds for DOOM.
Original DOOM II worlds converted to VRML. The following list contains links to the original VRML file, an enhanced version using BSP tree optimizations and the multi-user version:
In BS Contact the textures will look better using
"high quality" or "hardware" rendering settings.
The C key toogles collision detection. the G Key gravitiy
How to build DOOM VRML worlds your self:
First you need to have DOOM II.
Get a free DOOM WAD Editor and construct your
own DOOM WAD-Worlds. WAD Files and editing programs can be found
on the Internet by searching for sites via keywords like "wad",
"doom".
Convert the WAD File to VRML using the Doom2Wrl
program.
Doom 2 wrl was created by Ken Russel, SGI.
We used a modified version for converting to the proper multi-user
coordinate scale, the source is available as zip-file. (Microsoft
Visual C and JPEG Library required for compiliation.)
For tuned performance the generated VRML code
can be BSP-Tree optimized for BS Contact.
The source of Doom2Vrml could be further enhanced
to support things, monsters, teleporters and so on. Currently only some doors
can be opened with a click.
Let us know if you enhanced doom2vrml.
Scripting examples:
Stacker
an active object, you can stack up and down
the sphere sticks with the cone buttons. Adjust the sticks to form the
number 1, 2, 3 and you will win.
Dynamic Surfaces
Want to build a dynamic waving flag or ocean
waves, here is a good starting point example using an Elevation Grid and
a Script (from a Netscape Demo, only converted to vrmlscript)
Slideshow
A VRML 2.0 slide show, clicking on the red
cones exchanges the url field of an ImageTexture node.
Randomizing
Coordinates
A sample modifying the coordinates of an IndexedFaceSet
with a Script.
Building large worlds
A typical problem in 3D is how to create a
large compelling environment without sacrificing the interactivity, i.e.
rendering speed.
In the following are several approaches
for different types of scenes.
Managing
Rooms with a Proximity Sensor
A Script Node with a Proximity Sensor switches
Rooms between an inside and outside view. Turn off collision detection
("C" Key in BS Contact) and move into out of the gray boxes (== outside view).
Managing
Rooms with a BS Contact Occlusion Node
It's the same principle as above, but the
BS Contact extension node Occlusion is being used. Occlusion would allow
more complex Sensor areas composed out of primitives or even convex IndexedFaceSet's.
Scene preprocessing using the BS Contact
BspTree Node
The BspTree is a performant technique to reduce
the amount of geometry passed to the rendering engine. Game Engines are
typically based on some BspTree's logic. The BspTree is introduced as a
native implemented VRML 2.0 node, other browser can display the model by
using a PROTO implementation of the node.
Please check the
BSP documentation
for more technical information about the BS Contact BspTree node.
Optimizations and performance Tips
General
-
reduce and simplify geometry
-
remove unneeded faces
-
use instancing (DEF once USE many Times)
-
don't disable backface culling (solid
FALSE) if it is not totally necessary
-
use unlit textures :
Shape {
appearance Appearance
{
texture ImageTexture
{ url "myimage.jpg"}
}
geometry ...
}
-
Share identical Texture, Material and Appearance
nodes.
-
limit the number of lights, Directional Lights
are fastest
-
help the browser by limiting the amount of
active nodes:
-
using a switch node currently unneeded / invisible
parts can be enabled / disabled
-
complex animations can be disabled by
disabling TimeSensor's ( e.g. enabled FALSE )
General for BS Contact (but may also
be true for other browsers)
-
Specify visibilityLimit in NavigationInfo
for better z-range adaption and for more culled geometry
-
Many Text Nodes are expensive, an alternative
are textures representing text
-
Few IndexedFaceSet's with many faces are more
performant than many single face IndexedFaceSets with few or only a single
face
-
If the plugin is embedded into a frame set
any animations like animated GIF's in the other frame may slowdown the
3D operation
-
Flat shading can be forced with the default
value for creaseAngle 0 and normalPerVertex FALSE
-
For unlit materials use Material {diffuseColor
0 0 0 emissiveColor yourColorHere } The specularColor is already black
by default.
-
Prescale textures to a power of 2
Specific to the BS Contact Direct 3D
Version
-
if using many rectangles each with a different
texture, try to combine several textures in one image, and adapt texture
coordinates
-
color per vertex doesn't work in Direct3D
Ramp Driver ("high speed"), in RGB/Hardware mode color per vertex Shapes
are unlit.
-
Shapes with more than 1024 (hardware) / 2020
vertices (software) or color per face requires some extra preprocessing
-
animating vertex attributes (e.g. coordinates)
of shapes works fastest up to the limit of 1024/2020 vertices
-
try GIF Textures instead of JPEG's for Ramp
Driver
-
prefer modeling with convex polygons instead
of generating an equivalent set of triangles
Specific to OpenGL
If the model is targeted to run on a software
only OpenGL platform or OpenGL hardware without texture acceleration:
-
limit the amount of textures
-
prescale textures to a power of 2
-
use colors per face or color per vertex to
add surface detail
Other considerations
The "software only" rendering speed depends
largely on the size of the rendering window. A VRML World could be presented
using several viewing choices like:
-
a small VRML window embedded in a HTML page
-
a full screen VRML link for users preferring
full screen viewing or using hardware acceleration.
Fixed size windows or fixed size embeds (without
%) are limiting the user to resize the rendering area. Other elements on
the HTML-Page like animated-gif's may slowdown the VRML browser.
Another aspect is how the scene is decomposed
for downloading. BS Contact starts the loading of Inlines and other nodes
with URL fields in the order the children of Group nodes are specified,
walking into the deeper levels first. Inlines in currently not traversed
parts (e.g. non-active children of a Switch/LOD node etc.) are loaded if
needed. In Internet Explorer BS Contact starts the download of such in-active
children if no other download activity is pending. For LOD nodes with direct
Inline child nodes, BS Contact will display the lower LOD-Level if the Inline
is not loaded yet. BspTree nodes are traversed by default in front to back
order with respect to the viewer.
BS Contact currently does not unload nodes from
memory. A script using node.addChildren /removeChildren Browser.createVrmlFromString
could be used to perform scene memory management. A node is being deleted
if no other reference exists to the node.
Specific to BS Contact vrmlscript/javascript
interpreter speed
-
minimize the number of eventOut's generated
-
change an eventOut only if the value really
changed (less redraw)
-
Original
x = 0;
if (t>0.5)
x=t;
event = x;
-
Better
x = 0;
if (t>0.5) {
x=event=t;
else if (x != 0) event
= x;
-
change an MF Event once at the end of the
script and not individual elements in the body of a loop
-
if applicable expensive calculations could
be moved out of inner loops
-
an initialize() script function can be used
to set the startup state