devwiki:vr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
devwiki:vr [2022/06/29 17:24] – [VR Framework setup] yingdevwiki:vr [2022/07/02 03:57] (current) – [VR quick workflow] ying
Line 264: Line 264:
 ====== VR quick workflow ====== ====== VR quick workflow ======
  
-wip+VR quick setup
  
 +**initial setup**
 +  - new project: build settings - android
 +  - player settings: input: new inputs
 +  - [add] package manager: install (alt+_)
 +    * XR plugin management 4.2.1
 +    * XR interactive toolkit 2.0.2 + import Starter Asset
 +    * oculus XR plugin: 1.12
 +  -  player setting:
 +    * xr plugin management: check oculus for both pc and android
 +  - [add] import external package:
 +    * Oculus Hands.unitypackage
 +    * VR Tunnelling Pro.unitypackage
 +**input tweak**
 +  - go Assets / Samples / XR Interaction toolkit / 2.0.2/ Starter
 +  - [add] select XRI default left+right controller: (top button in inspector) "add to ActionBasedController default"
 +  - [set] Project setting > Preset Manager:
 +    * filter "Right"/"Left" for "XRI Default Right/Left Controller"
 +**Settings**
 +  - Build settings: Android
 +    * texture compression: ASTC
 +  - Project setting:
 +    * Quality: go option Medium:
 +      * anistropic texture = disable
 +      * anti alias = 4x
 +      * shadow = disable
 +  - Player setting: 
 +    * other : Dynamic Batching = true
 +    * other : mini API = 23
 +    * prebake collision mesh = true
 +  - audio setting:
 +    * DSP buffet size = best latency
 +  - Time setting:
 +    * fixed timestep = 0.0138889 (1/72)
 +**MainScene**
 +  - Name MainScene
 +  - delete default cameras
 +  - First directional light
 +    * mode = realtime
 +    * shadow = no shadow
 +  - Second directional light
 +    * mode = baked
 +    * shadow = soft shadows
 +  - layer: Teleport / Grab / Player
 +    * project setting : physics : layer collision matrix > player not X grab 
 +**XR Rig**
 +  - [add] XR origin (action based)
 +    * to layer "Player" (no, this object only) << this is for VR, not XR origin without hand one.
 +    * tracking origin mode = "Floor"
 +  - inside XR origin:
 +    * duplicate L/R controllers 2 times
 +    * 0 = RightHand Direct Controller
 +      * remove Ray interactor
 +      * remove interactor line visual
 +      * remove Line renderer
 +      * [add] "XR Director Interactor"
 +        * hide controller on select = true
 +      * [add] "Sphere collider"
 +        * is trigger = true
 +        * radius = 0.1
 +    * 1 = RightHand Ray Controller (L)
 +      * enable interaction with UI = true
 +      * Raycast config > Raycast mask = UI
 +      * interactor line isual > invalid color gradient all alpha = 0 (???)
 +    * 2 = RightHand Teleport Controller (L)
 +      * active = disabled
 +      * XR controller : selection action = XRI RightHand Locomotion / Teleport select
 +      * Ray interactor : enable interaction with UI = false
 +      * Ray interactor : line type = projectile curve
 +      * Ray interactor : velocity = 8
 +      * Ray interactor : Raycast mast = Teleport
 +      * interactor line visual : override line length = false
 +**Blink effect**
 +  * XR origin > Camera offset > Main camera
 +    * clipping planes : near = 0.01
 +    * [add] as its child, add UI > RAW Image (as BlinkCanvas)
 +    * rename auto created Canvas as "BlinkCanvas"
 +  * BlinkCanvas
 +    * Canvas : render mode = world space, position = [0,0,.02], wh=[0,0]
 +    * [add] script "Blink.cs"
 +    * its child: RAWImage: position =[0,0,0], w=2, h=2, color=black
 +    * select BlinkCanvas, create animation
 +      * rawImage: f0: active=true, alpha=0
 +      * rawImage: f2: alpha=1; event: DoAction
 +      * rawImage: f15: active=false; alpha=0; event: TunnelingOn
 +      * BlinkAnimation (triangle shape icon): loop time = false
 +    * Panel > Animator
 +      * select BlinkCanvas animation controller (box with 2 dot shape icon)
 +      * [add] trigger "blink"
 +      * [add] empty state, and set as default
 +      * [connect] BlinkEmptyState > BlinkAnimation: has exit time = false, condition : blink
 +      * [connect] BlinkAnimation > BlinkEmptyState: has exit time = true
 +    * hide RAWImage by default
 +**tunneling effect**
 +  * Main camera
 +    * [add] Tunneling mobile
 +      * motion target = XR Origin (??? XR Rig)
 +      * effect coverage = 0.5
 +      * angular velocity = falsse
 +      * linear velocity = true; max = 1.5
 +**Locomotion system**
 +  * [add] XR > LocomotionSystem
 +    * remove Snap Turn Provider (action-based)
 +    * [add] [custom script: SnapTurn folder] Snap Turn Provider Blink Action-based (ActionBasedSnapTurnProviderBlink.cs)
 +      * system = locomotion system
 +      * enable turn around = false (???)
 +      * blink = BlinkCanvas
 +      * Right Hand Snap turn - use reference = true
 +      * reference = XRI RightHand Locomotion/Turn
 +    * remove Teleportation Provider
 +    * [add] [custom script: Teleportation folder] Teleportation Blink Provider
 +      * system = locomotion system
 +      * blink = BlinkCanvas
 +    * [add] [custom script: Continous ] Continous Move Provider blink (ActionBasedConituousMoveProviderBlink)
 +      * system = locomotion system
 +      * move speed = 2
 +      * Left hand move action - use reference = true
 +      * reference =  XRI LeftHand Locomotion/Move
 +      * forward source  = LeftHand Direct Controller (???? doc=RightHand Direct, or you mean right is always for move direction??)
 +    * [add][custom] Character controller Driver 2.cs
 +      * locomotion provvider = its Continous move provider (??? doc=locomotion system)
 +**Rig component**
 +  * XR Origin 
 +    * [add] Input Action Manager
 +      * action sets size = 1
 +      * element0 = XRI Default Input action
 +    * [add] Character controller
 +      * radius = 0.3
 +    * [add] [custom] ControllerModeSwap.cs
 +      * interactor controller = "RightHand Direct controller"
 +      * teleport controller = "RightHand Teleport controller"
 +      * teleport activation button - use refernece = true
 +      * reference = XRI RightHand Locomotion/Teleport mode activate
 +  * BlinkCavans > Blink.cs (uncomment that 2 lines)
 +    * animator = BlinkCanvas
 +    * tunneling = Main Camera
 +    * movement provider = locomotion system (contious move)
 +**Hand Presenece Prefab**
 +  * [create] empty LeftHand (pos=0,0,0)
 +    * [add] HandPresence.cs
 +    * [add] child: Oculus Hands\Prefabs\Left Hand Model
 +      * pos= 0,0,0; rot = 0,0,120
 +      * hand material: hands_solid = standard shader
 +      * [option] create transparent hand material: HandMat
 +        * albedo = transparent green, render mode = transparent
 +    * [add][custom: Controllers folder] child: Controllers\quest2_controllers_div0
 +    * hide Right parts
 +    * create controllerMat, standard, albedo = nextControllerBoth_color1k texture
 +    * assign that material to mesh
 +    * ----------
 +    * LeftHand > HandPresence
 +      * controller = quest2_controllers_div0
 +      * hand model = Left Hand Model
 +      * grip button - use reference = true
 +      * reference = XRI LeftHand interaction/ Select (??? last time we create custom input)
 +      * trigger button - use reference = true
 +      * reference = XRI LeftHand interaction/ Activate
 +    * LeftHand = Prefab; delete from scene
 +    * -----------
 +    * duplicate LeftHand prefab as RightHand
 +    * remove "Left Hand model"
 +    * [add] Oculus Hands\Prefabs\Right Hand, pos=0,0,0, rot=0,0,-120
 +    * assign handMaterial (optional)
 +    * assign controller material
 +    * RightHand > HandPresence
 +      * controller = quest2_controllers_div0
 +      * hand model = Right Hand Model
 +      * grip reference = XRI RightHand interaction/ Select
 +      * trigger reference = XRI RightHand interaction / activate
 +    * ------------
 +    * Back to Scene
 +    * LeftHand Direct Controller > XR controller 
 +      * model prefab = LeftHand prefab
 +    * RightHand Direct controller > XR controller 
 +      * model prefab = RightHand prefab
 +**Hand animation**
 +  * select hand prefab, right click
 +  * [create] animation controller for right hand 
 +    * [add] parameter float: Grip + Trigger
 +    * create state > from New Blend Tree, double click to edit
 +      * blend type= 2D freeform cartesian
 +      * parameter = grip + trigger
 +      * + x 4 = 4 motion fields, 00, 01,10,11
 +      * go Oculus Hands / animations
 +        * R_hand_default_anim, r_hand_pinch_anim, r_hand_fist_anim, r_hand_fist_anim
 +        * expand to see the triangle icon, and drag to the Blend Tree
 +  * [duplicate] right hand animation controller as LeftHandAnimationController
 +    * swap the blend tree animation
 +  * ------
 +  * inside "LeftHand" and "RightHand" prefab
 +    * select "Left Hand Model" and "Right Hand Model"
 +    * assign the animation controller accordingly
 +  * ------
 +  * go Sample >>> Starter Assets - XRI Default Input Action
 +    * edit button to open
 +    * XRI RightHand > Actions > +
 +      * Grip (type = value; type=axis; 
 +      * binding.path = XR controller \ XR controller (Right Hand) \ optional controls \ grip)
 +      * generic XR controller = true
 +    * XRI RightHand > Actions > +
 +      * Trigger (type = value; type = axis)
 +      * binding.path = XR Controller\XR Controller (Right Hand)\Optional Controls\trigger
 +      * generic XR controller = true
 +    * same Grip + Trigger for XRI Left Hand
 +    * click "save asset button"
 +    * ~~~~~~~
 +    * RightHand/LeftHand Prefab > HandPresence
 +      * update reference of Grip and Trigger
 +**Teleport reticle**
 +  * [drag] [custom Teleport folder] in
 +  * create "TeleportMat" with AlphaRamp (unlit/alpha ramp)
 +  * [Teleport] teleportHightLight : scale factor = 0.01; (apply)
 +  * [add] teleportHightLight to scene, scale = 0.5,1,0.5
 +  * assign TeleportMaterial
 +  * make it prefab = original prefab; remove from scene
 +  * name as TeleportReticle
 +**Teleport Anchor**
 +  * create cylinder, scale 1,0.1,1
 +  * remove collider
 +  * add mesh collider (convex = true)
 +  * [layer] = Teleport
 +  * [add] [teleportation] TeleportationBlinkAnchor.cs
 +  * [add as child] TeleportReticle (scale=0.5,5,0.5) under cylinder 
 +  * teleportationBlinkAncor: onFirstHoverEnter:
 +    * teleport reticle: active = true
 +  * teleportationBlinkAncor: onLastHoverEnter:
 +    * teleport reticle: active = false
 +  * hide teleport reticle
 +**Teleport Area**
 +  * add floor
 +  * [add] [teleporation] TeleportationBlinkArea.cs
 +    * custom reticle = teleportReticle prefab
 +    * teleport provider = locomotion system
 +  * floor [layer] = Teleport
 +**Grabbable**
 +  * add cube
 +  * [layer] = "Grab"
 +  * add collider
 +  * add rigidbody
 +  * [add] XR Grab Interactable 
 +    * or XROffsetGrabInteractable.cs (assign attach transform)
 +    *  move type=velocity
 +**Highlighting for grabable**
 +  * [custom: outlinedDiffuse ]create highlightMaterial (outlined/diffuse) with main color + outliner color + optional texture
 +  * assign that material to object to highlight
 +  * assign [custom] Highligher.cs to object to highlight
 +  * [drag] itself to both interactor and mesh render
 +**Socket for grabbable**
 +  * ceate empty game object
 +  * add sphere collider (is trigger = true)
 +  * add "XR Socket interactor"
 +    * [add] new SocketMaterial (transparent, green alpha 150, smooth 0)
 +    * to Hover Mesh Material
 +    * (optional) attach point
 +    * (optional) put a vis sphere under it
 +**other tag socket**
 +  * ??? (wip)
 +** UI **
 +  * [add]XR > UI Canvas (not the UI one) as XRUICanvas
 +  * scale = .002, .002, .002
 +  * add RAWImage alpha 0 to show ray
 +  * add rest text mesh pro ui
 +  * set canvas and all children [layer] = UI
 +**BigButton**
 +  * create base 
 +  * create top (+rigidbody = is kinematic)
 +  * [add] [custom: things] HandButton.cs
 +**Leveler**
 +  * [layer] = grab
 +  * add collider
 +  * add rigidbody; gavity = false
 +  * [add] XR Grab interactor
 +    * move type = velocity tracking
 +  * [add] Hinge joint
 +    * use visualizer to set Anchor (if pivot is correct, should be 000) and Axis
 +    * use limit = true
 +    * use spring = true (damper = 1, spring=1)
 +**Finalize**
 +  * create light > Light Probes Group
 +  * optional blob shadow for character and dynamic objects
 +  * unmoveable object set = static
 +  * Bake lightmaps: window  > Rendering > Light setting > Generate lighting
 +  * build
  • devwiki/vr.txt
  • Last modified: 2022/07/02 03:57
  • by ying