SteamVR

SteamVR

84 ratings
Create SteamVR Environments
By Qwigs
This guide will teach you how to use an OBJ as a SteamVR Environment. Specifically for Maya, but will be as general as possible.
2
   
Award
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.
37 Comments
Qwigs  [author] Dec 31, 2022 @ 1:33am 
gee I wonder why
niki'smaster Dec 29, 2022 @ 8:28pm 
seems out of date
Joe Gaming Apr 14, 2022 @ 7:56am 
how do i delete environments
[AiR] Bango Oct 4, 2018 @ 7:35am 
I try to import a model via model editor. For this I need to create a new folder that looks like ".../steamtours_addons/popcorn/models/popcorn" -> I'm following the tutorial from this page https://developer.valvesoftware.com/wiki/SteamVR/Environments/Getting_Started#Bring_your_model_into_SteamVR_Workshop_Tools exactly but when I try to accept the destination following error occurs:

--------------
Invaild Content Model Directory

Model Directory must be under 'models' in the current mod or addon content path
--------------

This is very annoying! Does anybody have a solution or knows a better tutorial?
Super Beubeu ! Oct 28, 2017 @ 9:53am 
We can no longer directly import a 3D object from maya or blender... Now we have to do it with their software, Hammer. It's more difficult, longer and useless :/ I don't know why they removed that because it was so convenient and easy...
Qwigs  [author] Oct 5, 2017 @ 1:46pm 
I'll look into this eventually, but pretty busy atm.
BOLL Oct 1, 2017 @ 9:28am 
I think this is out of date now yeah. I cannot edit my old broken environment (had edited local files and uploaded the wrong ones) and now only background _images_ can be uploaded with the same tool. It seems like we will have to use Hammer and make an actual Home environment now.
kiD7 Aug 16, 2017 @ 8:46am 
there is no option like "upload new". im looking for an uptodate tutorial out there. can anyone help? upload seems only working via hammer and im a total noob.
PuzzaBug Aug 10, 2017 @ 2:36am 
is there any way to still do this? I have a really simple environment and don't want all the steam home overhead.
Qwigs  [author] May 20, 2017 @ 6:39am 
There aren't any unless they've updated it.