SteamVR

SteamVR

46 ratings
Create SteamVR Environments
By Qwiggλlo
This guide will teach you how to use an OBJ as a SteamVR Environment. Specifically for Maya, but will be as general as possible.
 
Rate  
Favorite
Favorited
Unfavorite
Introduction
SteamVR Environments are comprised of Model(s), Texture(s), Material file(s) and a JavaScript Object Notation file.

Before we get any further I want you to know this guide is for people familiar with the basics of creating 3D Computer Generated Imagery. I will not explain what a polygon is or what UV Maps are for. If you don't know what a UV Map is or polygons are then go here[lmgtfy.com].

Models must be OBJs (max of 65,000 polys(triangles)).
Textures must be 8-bit, can be at least 4096x4096 jpg, png, tga and maybe other types but just use png or jpg. There's no reason to use anything else (in the future we may need to use tga for spec, normal, light, etc maps).
Material files come with your OBJ files on export, but may need to be edited before you submit to the workshop.
The JavaScript Object Notation (JSON) file is the link between your multiple OBJs and controls the display of the thumbnail image.

The up axis is +Y and the forward axis is Z, but I'm unsure how to correctly define this (FYI my "room setup arrow" is facing -Z).

The scale is one unit = one meter. One unit in Maya(And Max and Blender) by default is considered 1 centimeter, but will be 1 meter in SteamVR so get out your converters.

Maya's default up axis is Y, but in case your Maya isn't setup this way you can find this setting under Windows -> Settings/Preferences -> Preferences. Select the "Settings" category and click the Up axis: Y radio button.
The Model
In this section I will show you how to make 2 cubes in Maya.
  1. Make sure your menu set is set to "Modeling".
  2. Select the "Polygons" tab.
  3. Click the "Polygon Cube" button.


And a Cube will be created in the center of your scene.

The cube will also have a polyCube input which defines the cube's Width/Height/Depth subdivisions and let's you scale its size. By default in Maya 2016 you will get 1 subdivision in each axis, if you don't then set each axis to have 1 subdivision. Keep the Width/Height/Depth to 1 as well.

Now that we're on the same page we can remove this polyCube input. We don't want any of these inputs when we export to OBJ. These inputs are considered "history" and to remove them from a shape we select the shape and go to Edit -> Delete All By Type -> History. Remember how to do this because you will need to do it before you export any shape if the make any history.

Now we can scale our cube to become a bed or something. If you're American and have an imperial tape measure let me show you how we can get that bed to scale. A typical queen sized bed is 80 inches by 58 inches and 12 inches high. Put each of these numbers here[www.metric-conversions.org] and input them into each axis of the cube's scale. X and Z will be 2.032 meters and 1.473 meters, the Y will be .305 meters.

Let's get our mattress on our virtual floor which is represented by the grid of our scene. We want to snap the mattress to the grid, but right now our pivot is in the center of the shape. To move the pivot hold D and V at the same time, click and drag the Y axis transform and hover your mouse cursor over one of the bottom corner verts of the mattress before letting go. Now your pivot is snapped down to the bottom vertices of the mattress. Hold X, click and drag the Y transform up. This will snap our mattress's Y axis to the grid. Move the mattress on its X or Z axis a few meters away from the scene's center.

Make another cube and follow the same steps above, but make it a different size or something. Don't forget to delete history.

Now that we have our 2 cubes the size and in the positions we want we need to freeze their transforms, which means zeroing out their XYZ translations, scales and rotations. Select both cubes and go to Modify -> Freeze Transformations.

Another thing we need to do is set every shape's pivot to the 0,0,0 of the scene. To do this select both cubes and at the bottom of Maya there is a place to put MEL scripts into, click this text box and enter:
xform -ws -a -rp 0 0 0

That last thing we should do is give each shape a name, "mattress" and "something" are good enough.
The Texture
In order to see your mattress and something in SteamVR it needs a texture associated with a file.



Let's use this texture of wood as our file because who wouldn't want a wooden mattress and a wooden something? Save this to the same folder you will be exporting your OBJs to and name it "woodfloor.jpg".

Now we need basic UV Maps for our mattress and something. Let's make this easy and select both shapes and go to UV -> Automatic. This will give each side a uniform 1 to 1 UV Mapping. If you want to learn more about UV Mapping this is a great video.

Next let's give each shape its own material. Select the mattress, hold right click over it and select "Assign new Material". Then select "Lambert" because he was a pretty cool guy. Next to "Color" click the checkerboxed button and select "File". Click the folder icon next to "Image Name" and browse to our woodfloor.jpg file.

Do the same for the something, you can find a different image for it though. Just make sure you put the file in the same location as woodfloor.jpg.

We probably don't need to do this step, but my OCD won't let this go. When we Automaticly UV mapped, it created history on each shape. We should probably remove this history.
The Export
Recap time.

We're going to export each model separately so each model's pivot needs to be at 0,0,0 worldspace.
Each model needs a texture assigned to it with a corresponding file associated with it.
Each model needs its transforms frozen and history removed.

Let's make sure we have the obj plugin enabled. Windows -> Setting/Preferences -> Plug-in Manager scroll down and make sure "objExport.mll" is Loaded and Auto loaded.

Now select the mattress and go to File -> Export Selection...

At the bottom dropdown "Files of type:" and select OBJexport.

Name your file "mattress.obj" and leave all the options default (everything On) and put it in the same folder as your woodfloor.jpg texture file.

This will create mattress.obj and mattress.mtl.

Open the mattress.mtl in a text editor and make it look something like this:
newmtl lambert1SG illum 4 Kd 0.00 0.00 0.00 Ka 0.00 0.00 0.00 Tf 1.00 1.00 1.00 map_Kd woodfloor.jpg Ni 1.00
I think the only important bit is "map_Kd woodfloor.jpg", but you can leave all the other crap in there. If you made multiple textures it will add all of them into this file for some reason, make sure there's only one map_Kd assigned to the texture you want your mattress.obj to use.

TIP: Once you edit your MTL files copy and paste them into a seperate folder so you won't have to edit them again because it will overwrite these files everytime you export your OBJs.

Repeat this process for the other object, but name it "something.obj".
The JSON
Now we have our OBJ exports and our MTL files look great. We need to bring them all together with a JSON file.

Create a .txt file in this same folder as everything else and rename it to "mattress.json" it needs to share the same name as one of your OBJ files. When you upload to the workshop you will be selecting one OBJ file and it will look for this JSON file of the same name.

Open mattress.json and paste this:
{ "thumbnail": "woodfloor.jpg", "components": { "mattress": {"filename": "mattress.obj"}, "something": {"filename": "something.obj"} } }

Make sure you don't mess up the tabbing or spacing of anything in this file or you might be pulling your hair out trying to figure out what the hell is wrong with this thing that worked fine just last night. BTW you can make a thumbnail image for your beautiful mattress if you desire.
The Workshop Upload
Open SteamVR(Beta ATM), right click somewhere in the SteamVR window and go to Workshop -> Upload New.



Match this image then subscribe to your private Environment submission. Hope it works.
The Beyond
This section will go over everything else you may need to know.

Once you've submitted to the workshop and subscribed to your environment you can go to the folder locally and drag and drop your files directly into this folder so you don't have to keep resubmitting to the workshop for every little change you make.

The folder is located in C:\Program Files (x86)\Steam\steamapps\workshop\content\250820 sort by date and go into the most recent folder which should be your workshop submission.

When you're done making changes don't forget to resubmit to the workshop.

The error log for SteamVR Enivronment is accessed by right clicking SteamVR window -> Create System Report. Then go to the Logs tab -> vrclient_vrcompositor.txt. Most useful for diagnosing JSON issues.
< >
28 Comments
Qwiggλlo  [author] 20 May @ 6:39am 
There aren't any unless they've updated it.
jstubbles 19 May @ 8:23pm 
The JSON only seems to specify the albedo map. How do you specify the gloss, metallic, transparency maps, etc ?
Philipp 18 May @ 2:07pm 
Which program is responsible for parsing the JSON to understand the bundle infos? I have an OBJ and MTL file and made the JSON and thumb as well, all in the same folder too, but it looks to me as if the SteamVR Workshop uploader only lets me select the OBJ and might not upload the MTL, despite the JSON referencing both. I'm not using Maya, which may be part of the problem. Thanks for any help & for this tutorial!
Qwiggλlo  [author] 4 Sep, 2016 @ 11:41am 
Well ya, of course. Mtl stands for Material, without a material on geometry it will be invisible in any 3D application without a 'default' material.
Nondidjos 4 Sep, 2016 @ 6:55am 
Based on my tests, the use of the .mtl file is actually only to associate the texture file with the object. No other parameter has any influence. So all you effects need to be baked in the texture and are purely static.
BOLL 4 Sep, 2016 @ 6:37am 
I've tried using an .obj that only has vertex colors and no actual texture. I get no error from SteamVR and I'm way below the poly count limit, but the scene looks completely empty. I'm guessing no texture == invisible, do you know if this is the case? If so I need to figure out how to bake to a texture instead of to vertex colors.
Nondidjos 4 Sep, 2016 @ 1:50am 
OK... So all lighting must be baked in textures before export to SteamVR.

Thanks!
Qwiggλlo  [author] 1 Sep, 2016 @ 9:20pm 
There is no lighting, unless they've change it. I haven't looked into SteamVR Enviro updates lately.
Nondidjos 1 Sep, 2016 @ 1:05pm 
Thanks for the tutorial. I tried with one object that appears where I want it but the material looks unshaded (like the object is lit).

How is the lighting set up in the environment by the way?
Joybutton 10 Aug, 2016 @ 6:25pm 
I added a credit and link to your guide to the controller and basestation as well as the collection I made out of them. The controller has over 1000 views and almost 700 subs! Thanks again