area42 - Agentur & Systempartner
 

Creating Web3D-Content (VRML/ X3D) using Blender

The VRML/X3D exporter turns Blender in a real authoring application for Web3D content. As both the VRML and X3D exporters use the same options, this help page applies to both of them.
 

General

Exporting Meshes


 

Textures and Materials

Lights


 

Grouping Nodes

Special Nodes


General

What is VRML97 and what is X3D?

VRML stands for Virtual Reality Modelling Language and is the open ISO certified 3D format for the internet. The VRML97 standard (sometimes named as VRML 2.0) is the successor of VRML 1.0. VRML97 very good supported by different 3d applications and converters and often used for exchanging meshes between them too. With VRML97 you can design realtime interactive 3D scenes that can simply viewed using a browser with an installed VRML plugin.
Extensible3D (X3D) is the successor of VRML97, it is ISO certified too and offer a lot of more features. X3D can be encoded as VRML97 or in XML style. The Web3D consortium (something like W3C is for HTML) will develop the X3D format further.

How to export

You can export your Blender scene in VRML or X3D using menu "File->Export->VRML97 (.wrl)..." or "File->Export->Extensible3D (.x3d)...".
The Blender scene can exported from the "Scripts" window too.
Exporting VRML/ X3D from File menu
Exporting VRML/ X3D from "File" menu
    Exporting VRML/ X3D from Scripts window
Exporting VRML/ X3D from "Scripts" window

About

The VRML/ X3D exporters are developed by area42 - Agentur & Systempartner and released under the GPL license. They build up on the source of Rick Kimball's VRML exporter that shipped with earlier versions of Blender.
Bug reports and suggestions can be submitted at the VRMLsuck board or site.

Thanks

Links

Exporting Meshes

The VRML/ X3D exporter of Blender does not support basic 3D primitives (such as boxes, cones or cylinders). All meshes are exported as IndexedLineSet or IndexFaceSet, since Blender doesn't support anything else. Note that subsurfed meshes must be converted to normal meshes with "ALT-C" before export, or you will lose the subsurf detail.

The object name (OB)

The name of a mesh is used as the definition (DEF) of the shape field in the exported code. This is done so you can make sense of the resulting text file, making it easier to perform further editing after export.
Giving a name with expression in Blender on Editing (F9)
Giving a name with expression in Blender on "Editing (F9)"
    Name located inside the VRML/ X3D code
Name located inside the VRML/ X3D code
 
More about the "Link and Materials panel" of "Editing (F9)" can be found at the Blender documentation. Informations about the DEF and USE concept of VRML/ X3D can be read at The Annotated VRML97 Reference Manual.

Duplicte Linked (DEF/ USE)

When you create instances of meshes in Blender (Duplicate Linked Alt+D) they will be exported as instances too using the DEF und USE semantic.
Exporting a LINEAR fog with visibilityRange 20
Creating instances of meshes in Blender
using "Duplicate Linked Alt+D)
    The exported code
The exported code (DEF/ USE ME_Suzanne)
 

Solid or Wireframe (IndexedFaceSet/ IndexLineSet)

Meshes can be exported as a solid object with filled faces (IndexedFaceSet) or as a wireframe (IndexLineSet). Normally a mesh is exported as a IndexedFaceSet. If you'd like to export a mesh as an IndexLineSet you must set the "Drawtype" mode of this object to "Wire".
Setting the Drawtype to wire in Object (F7) - panel Draw
Setting the "Drawtype" to wire in
"Object (F7)" - panel "Draw"
    Drawtype Shaded and Wire
Drawtype "Shaded" and "Wire"
 

Setting up smoothing (creaseAngle)

Meshes get exported without surface-normal information, but you can setup smoothing (creaseAngle) using Set Solid, Set Smooth and the degrees of Auto Smooth at "Editing" (F9) in the Panel "Link and Materials" or "Mesh".
Setting up the smooth angle on Editing (F9)
Setting up the smooth angle on Editing (F9)

The twosided issue (solid TRUE/ FALSE)

Normally all meshes in VRML/ X3D are one sided to save CPU time, since they will be viewed in realtime. This means that each face is visible from one side only. Normally, however, Blender will display each face two sided, in an effort to make mesh editing both easier and more flexible. So when exporting an object to VRML/ X3D it may not visible in you VRML/ X3D viewer.
But you can control two sided or one sided in Blender when entering UV Face Select (F key from Object Mode). In this mode you see which side is visible and which faces are two sided. In Edit Mode (Tab key from Object Mode) you can change the visible side of an face by flipping the normals of it (W 9 keys). You can also press CTRL-N to recalculate the normals outside the mesh.
Setting twosided in UV Face Select for objects with texture or vertex color
Setting two sided in UV Face Select for objects
with texture or vertex color
    Setting twosided in UV Face Select for exporting just the material
Set "Twoside"+"ObColor" for exporting an mesh
that has no texture but should be two sided too
Wrong flipped normals in UV Face Select
Wrong flipped normals in "UV Face Select"
    Change the visible side of an face by flipping the normals
Change the visible side of an face by flipping the normals in "
 
Note: Don't forget to copy the texture face options to any face of a mesh using "Copy DrawMode" button.

Textures and Materials

Only the following texture and material settings can be exported: Note: After export you must copy alle used textures in the same directory where the VRML or X3D file is located. The exporter can't collect external sources!

Material settings

To export materials correct you must use diffuse shader "Lambert" and specular shader "CookTorr". Following material settings will act on the exported materials:
Supported material settings in panel Material
Supported material settings in panel "Material"
    Supported material settings in panel Shader
Supported material settings in panel "Shader"

Tiling (TextureTransform)

Instead of scaling textures to tile them and creating tons of texture coordinates on export you can use the "Tiles" option in the "Texture face" panle or at the properties panel at the "UV/Image Editor".
The values of "Tiles" in "Properties" panel (press N key if it does not appear) at the "UV/Image Editor" will be exported as TextureTransform into VRML/ X3D.
Setting up tiling in Blender at the UV/Image Editor
Setting up tiling in Blender at the "UV/Image Editor"
    The exported code
The exported code

Vertex colors

Vertex colors can be painted in Blender with normal (face colors) or with soft brush, both modes can be exported.
If you have painted vertex colors in mode "Vertex Paint" with soft brush and like to export them switch to mode "UV Face Select". Select all faces and turn in panel "Texture face" the button "Shared" on. After that press button "Copy DrawMode" to apply this to all other faces of the mesh.
If you used a normal brush in vertex paint and like to export face colors you must set in panel "Texture face" of mode "UV Face Select" "Shared" and "ObColor". Then press button "Copy DrawMode" to apply this to all other faces of the mesh.
Giving a name with expression in Blender on Editing (F9)
Exporting vertex colors (colorPerVertex TRUE)
using face mode "Shared"
    Name located inside the VRML/ X3D code
Exporting face colors (colorPerVertex FALSE)
using face modes "Shared" and "ObColor"

Lights

All VRML/ X3D types of lights are supported, but not all light types of Blender can be exported. Not all values of Blender can be exported 1:1 too so don't be confused when you see other values in th VRML/ X3D code. More about the lightning model of VRML/ X3D can be read at The Annotated VRML97 Reference Manual.
For previewing lightning just render a frame using the internal renderer and turn shadows and ambient occlusion off.

Lamp (PointLight)

Use a simple lamp when like to export a PointLight:

Spot (SpotLight)

Of course a spot in Blender is exported as a SpotLight to VRML/ X3D.

Sun (DirectionalLight)

Blender's sun light will be exported as a DirectionalLight to VRML/ X3D.

Headlight

Headlight is a light that always follows the viewer and an attribute of the node NavigationInfo. If there are no lights at the Blender scene it will be turned on, if a light is present it will be turned off.

Grouping Nodes

Some of Blenders "Texture face" options can be used for exporting grouping nodes. So the mesh with these activated options are a child of this grouping node in VRML/ X3D.
Note: Don't forget to copy the texture face options to any face of a mesh using "Copy DrawMode" button.

Billboard

You can export a billboard node by turning on the "Halo" or "Billboard" button at the panel "Texture face" when you are entering the "UV/Face Select" mode. As described in Blender itself "Halo" will exported as a screen aligned billboard and "Billboard" will exported as a billboard rotating around the Y Axis (in Blender Z axis).
Billboard will exported as a billboard rotating around the X Axis (in Blender Z axis)
"Billboard" will exported as a billboard rotating
around the X Axis (in Blender Z axis)
    The exported billboard code using Billboard
The exported billboard code using "Billboard"
 

Collision

Normally in walk through mode all meshes colliding in VRML/ X3D with the activated viewport but you can turn collision for objects off. This can be exported turning "Collision" in the "Texture face" panel off (normally it is on).
Turning Collision in the Texture face panel off will export a collision group
Turning "Collision" in the "Texture face" panel off
will export a collision group
    The code of the grouping node collision
The code of the grouping node collision
 

Special Nodes

Background

You can export the X3D/ VRML background node by using the color and textures assigned to the "World (F8)" of the Blender file.
Normally (if you don't change anything) it exports the horizon color as skyColor and groundColor of the X3D/ VRML background. By changing the modes (Real, Blend, Paper) in the preview panel you can change it as the the preview shows: By changing the name of the Blender world from "world" or "world.xxx" to another non standard name, a definition (DEF) for the the X3D/ VRML background will be created using the given name. Example: naming the world "landmark" will export a X3D/ VRML background "DEF landmark Background { ... }".
The lightness of the ambient color from the world object will effect lights of the scene. The color itself will affect materials too.
Enabling/ Disabling Real, Blend and Paper will exported as the preview shows for different background blendings
Enabling/ Disabling Real, Blend and Paper will exported as
the preview shows for different background blends
    The exported billboard code using Billboard
Supported settings of the world object
 
 
To export textures for the X3D/ VRML background node you must assign them to the texture of the Blender world (switching from "World (F8)" to "Texture (F6)") and give them the following names:
Enabling/ Disabling Real, Blend and Paper will exported as the preview shows for different background blendings
Enabling/ Disabling Real, Blend and Paper will exported as
the preview shows for different background blends
    The exported billboard code using Billboard
Supported settings of the world object
 
 
Make sure you selected "Texture Type" "Image" and assigned a image to it otherwise it doesn't export it.
Note: X3D and VRML viewers/ plugins supports normally images in GIF, JPG and PNG format only. Some X3D/ VRML viewers support other formats like BMP and DDS too.

Camera (Viewpoint)

Cameras in blender will be exported as Viewpoints into VRML. They are supported by rotation (orientation), location (position) and lens (fieldOfView). The object name of a camera (OB) will be exported as a definition (DEF) and as the descriptions appears in the VRML/ X3D plugin viewpoint list.
Note: The calculation of the fieldOfView (lens) depends on aspect ratio of width and height at the render settings.
Setting the description for a Viewpoint in Blender
Setting the description for a Viewpoint in Blender
    The exported code
The exported code
Viewpoint list in the VRML plugin
Viewpoint list in the VRML plugin
    Setting up width and height for aspectratio
Setting up width and height for aspect ratio

Exporting Mist (Fog)

From Blender you can directly exporting the X3D/ VRML fog node using "Mist" feature of the Blenders "World". The color of the exported fog node is given by the horizon color of Blender (see Background too). The "Di" field (distance) will be exported as attribute visibilityRange.
To export the mist as X3D/ VRML fog node select the type:
Exporting a LINEAR fog with visibilityRange 20
Exporting a "LINEAR" fog with visibilityRange 20
    The exported code
The exported code

Creating Inlines

In Blender you can arrange different scenes in one file. This feature could be used for creating and exporting Inlines.
The first scene at the list is the main scene any following is linked as an Inline to it and must have a none standard name (means not Scene or Scene.001). The following scenes can be exported as normal VRML/ X3D files. Use the scene names then as there file names.
Note: There is no syntax checkup so you must enter a valid VRML or X3D name. Only the current scene will be exported not all at once.
Enabling/ Disabling Real, Blend and Paper will exported as the preview shows for different background blendings
Creating different scenes in Blender
    The exported code
The exported code

Setting unsupported VRML/ X3D nodes in 3D space

If you like to export unsupported notes that requires 3D coordinates you can use an "Empty" for that.
Exporting content of the text editor
Creating an Empty object
   
Put it anywhere in the scene and give it as a name a valid VRML/ X3D node name.
The location and rotation of the empty will be exported as attributes.
Note: There is no syntax checkup so you must write valid VRML or X3D syntax.
Exporting content of the text editor
Naming an Empty as a valid VRML/ X3D node
    The exported code
The exported code

Protos, Scripting, Routes and unsupported nodes

For exporting unsupported nodes, own scripts and missing features you can use the Blender built in text editor. Just create a new text file and name it "proto" or open a external file named "proto.js" or "proto.txt" when you like inserting code at the beginning of the file (after header, before any other node).
When you create a new text file and name it "route" or open a external file named "route.js" or "route.txt" then the code will be inserted at the end of the file (after any other node).
The content of the "web3d" text window will be placed at the end of the file.
Note: There is no syntax checking so you must write valid VRML or X3D syntax.
Exporting content of the text editor at the beginning of the VRML/ X3D file
Exporting content of the text editor at the beginning
of the VRML/ X3D file
    Exporting content of the text editor at the end of the VRML/ X3D file
Exporting content of the text editor at the end
of the VRML/ X3D file