public override void OnInspectorGUI() { RATProjectionPass control = (RATProjectionPass)target; DrawDefaultInspector(); if (GUILayout.Button("Set Static Defaults")) { control.SetDefaultStaticShaders(); } if (GUILayout.Button("Set Dynamic Defaults")) { control.SetDefaultDynamicShaders(); } EditorUtility.SetDirty(target); }
public virtual void RenderProjection(Camera camera) { RATProjectionPass[] layers = projectionLayers; for (int layerId = 0; layerId < layers.Length; layerId++) { RATProjectionPass layer = layers[layerId]; if (layer == null || !layer.enabled || layer.projectionShader == null || !layer.renderProjectionPass) { continue; } camera.cullingMask = layer.targetSurfaceLayers; //todo preload IDs Shader.SetGlobalVector("_UserViewPos", this.cam1.transform.position); Shader.SetGlobalTexture("_UserViewPointRGB", targetRGBTexture); //Shader.SetGlobalTexture("_UserViewPointDepth", targetDepthTexture); Shader.SetGlobalMatrix("_UserVP", this.cam1.projectionMatrix * this.cam1.worldToCameraMatrix); camera.RenderWithShader(layer.projectionShader, null); } }
public void AddUser() //helper method that sets up a simple User with projection passes for both Surface and Depth { GameObject userGO = new GameObject("User"); userGO.transform.parent = transform; RATUser user = userGO.AddComponent <RATUser>(); RATUserViewCamera userView = userGO.AddComponent <RATUserViewCamera>(); RATProjectionPass pass1 = userGO.AddComponent <RATProjectionPass>(); pass1.SetDefaultStaticShaders(); RATProjectionPass pass2 = userGO.AddComponent <RATProjectionPass>(); pass2.SetDefaultDynamicShaders(); user.skeletonProvider = transform.GetComponentInChildren <RATKinectClient>(true); RATProjectionPass[] layers = new RATProjectionPass[2]; layers[0] = pass1; layers[1] = pass2; userView.projectionLayers = layers; }