Vive | Setting up basic teleportation in Unity3d

The best solution at the moment is following Theston's work, which is an all-in-one script that you drop on the controllers. It handles a laser pointer, teleportation, and even some ability to grab objects. See what he's doing here, https://youtu.be/uTZ0xw4SPn0 - and here, https://www.reddit.com/r/Vive/comments/4gdxgt/steamvr_unity_toolkit_my_attempt_at_making_useful/

Download the assets here, https://github.com/thestonefox/SteamVR_Unity_Toolkit. And my steps I go through to integrate the files into my projects:

  • Import the latest SteamVR Plugin
  • Download the zip of SteamVR UNity Toolkit from Github
  • Copy SteamVR_Unity_Toolkit folder into your Unity project's Assets folder
  • Edit / Project Settings / Graphics, add a new included shader - choose 'Unlit/TransparentColor
  • Drop CameraRig into scene from, Assets / SteamVR_Unity_Toolkit/Prefabs
  • Put Steam VR_Basic Teleport script on CameraRig (found in the Assets / SteamVR_Unity_Toolkit/Scripts folder)
  • Put Steam VR_Controller Events & Steam VR_Simple Pointer scripts on both Controllers.
  • Have the floor be a physics collider. I break my floor geometry off from the rest and put a Mesh Collider on them. The teleporter will now only work when pointed at the floor.

Workflow Exploration; 3dsmax to Unity3d, updated!

Here's my latest method.  I've also included some new tools that are linked below. This post is pretty text heavy, but I hope it might help some people. I think this method is a great compromise on getting a space VR ready, while at the same time delivering still renderings that clients ask for:

My work is done on a 2013 Retina Macbook Pro, running Windows 7 as my benchmark for performance. If things can run decently on my set up then I assume most others should have a buttery smooth experience. (specs: 2.8GHZ, 16GB memory, GeForce GT 650M)

 

1. First step, optimize all geometry. Reduce turbosmooths, and reduce curve interpolation on rendered splines and/or sweeps. Sometimes I'll just apply an optimize modifier to reduce poly count. I try to keep the total scene poly limit to 500k - 1mil.

 

2. Check for flipped normals. I've been running into this problem when dealing with real world projects. Sometimes objects have been mirrored and instanced or just built too quickly and care wasn't taken to double check flipped normals. Sometimes you can get away with this within 3dsmax since it can render back-faces. Unfortunately, in Unity you'll see right through them :)

 

3. Combine. At this point I combine the entire scene into a single object. This is done so that the elements can be broken up by material name, which also gives you a multi/sub-object material to review materials, rename, etc. Combining keeps the amount of objects to deal with lower, and makes for an easier Shaders set up Unity. You can further break the objects up once the baked textures are created.  In addition, it's also a good place to check for sub-object selections and deselect them!

4. Unwrap. I have a maxscript tool that a friend built for me to speed up this step. Tik_uv_unwrap_and_pack_v003.ms, download here. It does a beautiful job. One thing to note is that objects cannot have sub-object selections. This will cause issues in the unwrap (since only the selected polys will get unwrapped). So be sure to check for selection when the scene is combined as a single mesh. I then do a basic UVW Unwrap 'flatten' within texture channel 5 or 10. Then I run UV-Packer through the same channel, which does the best job of optimizing uv space and packing those flattened UVs. Finally, I collapse everything.

 

5. Bake! Everything should be ready to go. A couple important things to note: you should make sure you are using regular cameras to preview the lighting. You can use vray exposure control to match a vray cam exposure so that it works with Render To Texture. Also make sure you're baking your gamma into the render. For me, this is simply changing my color mapping mode to 'color mapping & gamma'. Also make sure output gamma is 2.2 (these settings might be different depending on how you render, test with a single object until the baking matches a vray render)

In the Render to Texture panel, check 'color mapping' & select the desired elements to bake. I currently I only bake with the VrayCompleteMap.

note: vraydisplacement wont bake out, so you'll need to place the texture being used into an actual displace modifier, subdivide the geometry, then collapse & optimize the geometry to be suitable for baking.

6. Export. Prep the file for export once everything has baked. If I net render the baking, I'll run the Render To Texture on my local machine with 'skip existing files' selected. At the point, I'll also choose under Baked Material 'Save Source/Create New Baked (Standard:Blin), and set the target map slot to diffuse color. Note: setting the wire color of all the objects to white before doing this will set the ambient color of the Blin material to white, which will make things easier in Unity when imported)

Run the bake again.  It will skip all the objects since they've baked already, but it will put the textures into standard materials. I'll also click 'Update Baked Materials' for good measure. Then select 'keep baked materials' and clear the shell. Now you're left with a scene that has all standard materials, with white diffuse color, and the baked texture.

Optional: At this point I also use a script to load the diffuse textures into the viewport so they're visible. http://www.scriptspot.com/3ds-max/scripts/turn-viewport-maps-onoff

Shuffle the baked UV (10, or whatever channel you used), into channel 1. Channel 1 is the UV channel Unity uses.

Now you can export everything as an FBX.  Note: I embed media, and for units scale I uncheck automatic and set it to centimeters.

 

7. Import into Unity! The FBX should load automatically if you export it into your Assets folder. The model should also have all the baked textures on all its materials.  The shaders will be default Unity diffuse shaders. I use this script that my friend made to select all shaders and switch them to unlit/texture. UnlitDefaultShaderPostProcessorPlusShaderConverterTool_1.1.unitypackage, download here. There's also a post processor in there that's suppose to automatically convert all shaders to Unlit/Texture. You can delete it if you wish. You should now be in a pretty decent starting place to preview the space in Unity.

The next steps that I take are to isolate and work with materials that should be reflective. These need special shaders that will accept cubemaps, bump maps, etc. You might then go back into 3dsmax and isolate the objects with these materials so that they can be separate geometry for using the correct probes.   You might also re-bake those specific objects to obtain texture textures for bump/spec/gloss/whatever. I recommend looking at Cubemapper and Reflection Manager. Unity 5 should also have a great set of reflection tools included, so look out for that!

I'm also eyeing Amplify Texture as a way to bring in larger baked maps, however I haven't seen performance hits from 2k textures yet, so I've been slow to adopt it into my process.

 Let me know if you have any questions, either by emailing or leaving a comment. Have fun!

Workflow Exploration; 3dsmax to Unity3d

I haven't posted in a bit, since everything is still a mess. I've also been doing experiments with projects I can't share so that's another reason. But I thought I'd catch up on what I've been trying out so far. What has or hasn't worked.

So I'm currently trying to devise a workflow that allows me to bring scenes from 3dsmax, with all the glorious lighting from V-Ray baked into them.

Here's the current method:

1. Optimize all geometry as much as possible. Reducing turbosmooths, reducing curve interpolation on rendered splines and/or sweeps. Some things I've just applied an optimize modifier to reduce.

2. Unwrap. I usually do a shoddy job of just putting simple box mapping on objects. So before I start combining meshes, I unwrap them as properly as possible. I'm still trying to find a better workflow that doesn't damage the existing mapping until after baking.

3. Combine. At this point I combine the whole entire scene into a single object. This is simply so that I can explode it back into pieces based on material. This is because if I have two of the same material in the scene and bake them as two textures - the material is confused as to which baked texture to use.

http://www.scriptspot.com/3ds-max/scripts/detach-by-material-id
detach by material name

4. Organize. Now each mesh should have a jumble of UVs, so it needs to be packed more cleanly. Currently I'm simply using the 3dsmax pack uv function, but I'm looking into other plugins to do this better.

5. Bake! Everything should be ready to go. A couple important things are that; you make sure you're using regular cameras to preview the lighting. You can still use a vray exposure control to match an exposure so that it works with Render To Texture. Also make sure you're baking your gamma into the render. For me this is simply changing my color mapping mode to 'color mapping & gamma'.  Also I have the baked texture replace the existing diffuse slot texture, so that I can convert the material to standard and export with the geometry without issue.

In the Render to Texture panel, check 'color mapping' & select the desired elements to bake:

VrayCompleteMap - everything
VrayDiffuseFilterMap - just diffuse
VrayRawLightingMap - just lighting/shadows
VrayMtlReflectHighlightGlossinessBake - just the texture used in the reflection
VrayBumpNormalsMap - normals from bump material (if any)

I've gotten a lot of issues during this step - ranging from issues if any of the materials are anything besides a regular VRayMtl. So blend materials, 2-sided, light material will cause issue, the issue being that render to texture can't find the diffuse slot of that material to place the baked texture into.

6. Export. Once everything has baked. If you've set the baked materials to load into the diffuse slots. Next you'll convert all the materials to standard. I use this:

http://www.scriptspot.com/3ds-max/scripts/vray-material-to-standard-material

At this point I also use a script to load the diffuse textures into the viewport so they're visible. I can't find the exact script but there are multiple ones on scriptspot.

Now you can export everything as an FBX, I embed media, and for units scale I uncheck automatic and set it to centimeters.

7. Import. The FBX should load automatically if you exported it into your Assets folder somewhere. The model should also have all the baked textures on all its materials. You can now go through them and change them to more complex materials and load the other baked materials if needed (bump & reflection). I'm still struggling to find the best methods for reflections since all my materials usually have some sort of subtle reflective property w/ fresnel. I'll probably wait for Unity 5 before I purchase anymore assets - but I have been eyeing something like Candela SSRR or Screen Space Reflections (SSR). I still need to figure out and make use of the Shader Forge asset I purchased :)


I'll leave you with this, a little test I did yesterday. There's this triangle shaped building near where I live that has had the lower level up for lease, I've been wanting to imagine some use for this space. So yesterday I went and took about 150 pictures of the facade from all angles and processed them in PhotoScan - I got a pretty decent mesh that I'll use for reference when i model it properly. But for now I did a ProOptimize on it, and threw it into Unity to view :)