CopyFrom() private method

private CopyFrom ( Camera other ) : void
other Camera
return void
コード例 #1
0
ファイル: _map_camera.cs プロジェクト: FabianSchempp/DUNDON
    void Awake()
    {
        if (_map_camera_camera == null){
            //create clipping mask for map;
            _mask = 1 << 23 | 1 << 19;

            //create a new camera;
            _map_camera_camera =  new GameObject("map_camera");
            //add camera and copy attributes of original camera
            _map_camera_camera_component = _map_camera_camera.AddComponent<Camera>();
            _map_camera_camera_component.CopyFrom(camera);
            _map_camera_camera_component.depth = 2;

            _map_camera_camera_component.cullingMask = _mask;
            _map_camera_camera_component.backgroundColor = Color.black;
            _map_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;

            //parent and reset it to original camera;
            _map_camera_camera.transform.rotation = transform.rotation;
            _map_camera_camera.transform.position = transform.position;
            _map_camera_camera.transform.parent = transform;

            //create a new Render Texture for the map pass and assign it to the Camera
            _map_render_texture = new RenderTexture(Screen.width,Screen.height,8,RenderTextureFormat.ARGBHalf);
            _map_render_texture.name = "map_pass";
            _map_camera_camera_component.targetTexture = _map_render_texture;

            //set mask Texture global for all shaders
        Shader.SetGlobalTexture("_map_texture", _map_render_texture);
        }
    }
コード例 #2
0
ファイル: normal_camera.cs プロジェクト: FabianSchempp/DUNDON
    void Awake()
    {
        if (_normal_camera == null){
            //create clipping mask for normals;
            _normal_mask =
                    1 << 1 |
                    1 << 2 |
                    1 << 3 |
                    1 << 4 |
                    1 << 5 |
                    1 << 6 |
                    1 << 7 |
                    1 << 8 |
                    1 << 9 |
                    1 << 10 |
                    1 << 11 |
                    1 << 12 |
                    1 << 13 |
                    1 << 14 |
        //				1 << 15 |
        //				1 << 16 |
                    1 << 17 |
        //				1 << 18;
                    1 << 22;

            //create a new camera;
            _normal_camera =  new GameObject("normal_camera");

            //add camera and copy attributes of original camera
            _normal_camera_camera_component = _normal_camera.AddComponent<Camera>();
            _normal_camera_camera_component.CopyFrom(camera);
            _normal_camera_camera_component.depth = -1;
            _normal_camera_camera_component.cullingMask = _normal_mask;

            //add blur shader
            _normal_blur_component = _normal_camera.AddComponent<normal_blur>();

            //set_background to null normal
            _normal_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;
            _normal_camera_camera_component.backgroundColor = new Color(0.5f,0.5f,1.0f);
            _normal_camera_camera_component.camera.depthTextureMode = DepthTextureMode.DepthNormals;

            //sets replacementshader to render normals
            _normal_camera_camera_component.SetReplacementShader(_display_normal_shader,"");

            //parent and reset it to original camera;
            _normal_camera.transform.rotation = transform.rotation;
            _normal_camera.transform.position = transform.position;
            _normal_camera.transform.parent = transform;

            //create a new Render Texture for the normal pass and assign it to the Camera
            _normal_render_texture = new RenderTexture(Screen.width,Screen.height,32,RenderTextureFormat.ARGBHalf);
            _normal_render_texture.name = "normal_pass";
            _normal_camera_camera_component.targetTexture = _normal_render_texture;

            //set normal Texture global for all shaders
            Shader.SetGlobalTexture("_objectNormalTexture", _normal_render_texture);
        }
    }
コード例 #3
0
 void Awake()
 {
     GameObject holyObject = new GameObject("Holy Camera");
     holyObject.transform.SetParent(transform, false);
     Camera mainCam = GetComponent<Camera>();
     holyCam = holyObject.AddComponent<Camera>();
     holyCam.CopyFrom(mainCam);
     holyCam.nearClipPlane = nearClip;
 }
コード例 #4
0
ファイル: _mask_camera.cs プロジェクト: FabianSchempp/DUNDON
    void Awake()
    {
        //create clipping mask for masks;
        _mask =
        //				1 << 1 |
        //				1 << 2 |
        //				1 << 3 |
        //				1 << 4 |
        //				1 << 5 |
        //				1 << 6 |
        //				1 << 7 |
        //				1 << 8 |
        //				1 << 9 |
        //				1 << 10 |
        //				1 << 11 |
        //				1 << 12 |
        //				1 << 13 |
        //				1 << 14 |
        //				1 << 15 |
        //				1 << 16 |
        //				1 << 17 |
                1 << 18;

        //create a new camera;
        _mask_camera_camera =  new GameObject("mask_camera");

        //add camera and copy attributes of original camera
        _mask_camera_camera_component = _mask_camera_camera.AddComponent<Camera>();
        _mask_camera_camera_component.CopyFrom(camera);
        _mask_camera_camera_component.depth = -2;

        //		//sets replacementshader to render normals
        //		_mask_camera_camera_component.SetReplacementShader(gray_unlit_shader ,"Opaque");

        //set_background to null mask
        _mask_camera_camera_component.clearFlags = CameraClearFlags.SolidColor;
        _mask_camera_camera_component.backgroundColor = new Color(1f,1f,1f);
        _mask_camera_camera_component.cullingMask = _mask;

        //parent and reset it to original camera;
        _mask_camera_camera.transform.rotation = transform.rotation;
        _mask_camera_camera.transform.position = transform.position;
        _mask_camera_camera.transform.parent = transform;

        //set hdr rendering to on
        _mask_camera_camera_component.hdr = true;

        //create a new Render Texture for the mask pass and assign it to the Camera
        _mask_render_texture = new RenderTexture(Screen.width,Screen.height,8,RenderTextureFormat.ARGBHalf);
        _mask_render_texture.name = "mask_pass";
        _mask_camera_camera_component.targetTexture = _mask_render_texture;

        //set mask Texture global for all shaders
        Shader.SetGlobalTexture("_mask_Texture", _mask_render_texture);
    }
コード例 #5
0
        /// <summary>
        /// Renders the excluded objects to targetTexture
        /// </summary>
        private void SyncCamera(Camera excludeCamera)
        {
            // Copy settings from primary camera.
            excludeCamera.CopyFrom(GetComponent<Camera>());

            // Change Camera Culling Mask, Clear Flags and Depth.
            excludeCamera.cullingMask = m_ExcludeLayers.value;
            excludeCamera.clearFlags = CameraClearFlags.Nothing;
            excludeCamera.depth = excludeCamera.depth + 1;

            // Set parent camera culling mask.
            GetComponent<Camera>().cullingMask = GetComponent<Camera>().cullingMask & ~m_ExcludeLayers.value;
        }
コード例 #6
0
 static public int CopyFrom(IntPtr l)
 {
     try {
         UnityEngine.Camera self = (UnityEngine.Camera)checkSelf(l);
         UnityEngine.Camera a1;
         checkType(l, 2, out a1);
         self.CopyFrom(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #7
0
 static public int CopyFrom(IntPtr l)
 {
     try{
         UnityEngine.Camera self = (UnityEngine.Camera)checkSelf(l);
         UnityEngine.Camera a1;
         checkType(l, 2, out a1);
         self.CopyFrom(a1);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #8
0
ファイル: CapturePNG.cs プロジェクト: technicalvgda/Adagio
    void InitializeCamera()
    {
        whiteObject = new GameObject();
        cameraWhite = whiteObject.AddComponent<Camera>();
        cameraWhite.CopyFrom(cameraMain);
        cameraWhite.backgroundColor = Color.white;
        whiteObject.transform.SetParent(transform, true);

        blackObject = new GameObject();
        cameraBlack = blackObject.AddComponent<Camera>();
        cameraBlack.CopyFrom(cameraMain);
        cameraBlack.backgroundColor = Color.black;
        blackObject.transform.SetParent(transform, true);
    }
コード例 #9
0
ファイル: OIT.cs プロジェクト: nobnak/BlendedOIT
 void Awake()
 {
     _attachedCam = GetComponent<Camera>();
     if (_renderGO == null) {
         _renderGO = new GameObject();
         _renderGO.hideFlags = HideFlags.DontSave;
         _renderGO.transform.SetParent(transform, false);
         _renderCam = _renderGO.AddComponent<Camera>();
         _renderCam.CopyFrom(_attachedCam);
         _renderCam.enabled = false;
         _renderCam.clearFlags = CameraClearFlags.Nothing;
     }
     if (_postEffectMat == null) {
         _postEffectMat = new Material(postEffectShader);
         _postEffectMat.hideFlags = HideFlags.DontSave;
     }
     weight = Mathf.Min(0f, weight);
     Shader.SetGlobalFloat("_Weight", (weightEnabled ? weight : 0f));
 }
コード例 #10
0
 private void Initialize()
 {
     goCamera = new GameObject("RenderTextureCamera");
     cameraInstance = goCamera.AddComponent<Camera>();
     var cam = Camera.main;
     cameraInstance.CopyFrom(cam);
     cameraInstance.depth++;
     cameraInstance.cullingMask = CullingMask;
     cameraInstance.renderingPath = RenderingPath;
     goCamera.transform.parent = cam.transform;
     renderTexture = new RenderTexture(Mathf.RoundToInt(Screen.width * TextureScale), Mathf.RoundToInt(Screen.height * TextureScale), 16, RenderTextureFormat);
     renderTexture.DiscardContents();
     renderTexture.filterMode = FilterMode;
     cameraInstance.targetTexture = renderTexture;
     instanceCameraTransform = cameraInstance.transform;
     oldPosition = instanceCameraTransform.position;
     Shader.SetGlobalTexture("_GrabTextureMobile", renderTexture);
     isInitialized = true;
 }
コード例 #11
0
        public void loadSetting(CameraSetting _camSetting)
        {
            if (rt == null)
            {
                camera = this.GetComponent<Camera>();
                Camera mainCamera = GameObject.Find("Main Camera").GetComponent<Camera>();
                camera.CopyFrom(mainCamera);

                resolutionWidth = (int)camera.pixelWidth;
                resolutionHeight = (int)camera.pixelHeight;

                rt = new RenderTexture(resolutionWidth, resolutionHeight, 24);
                camera.targetTexture = rt;
            }

            camSetting = _camSetting;
            camera.transform.position = _camSetting.position;
            Quaternion quat = new Quaternion();
            quat.eulerAngles = new Vector3(-_camSetting.pitch,-_camSetting.yaw,-_camSetting.roll);
            camera.transform.localRotation = quat;
            camera.name = _camSetting.id;
            camera.fieldOfView = _camSetting.fieldOfView;
        }
コード例 #12
0
    public override void OnStart(StartState state)
    {
        if (state != StartState.Editor)
        {
            nextRenderTime = Time.time + freq;
            Camera sourceNearCam = null;
            Camera sourceFarCam  = null;
            Camera sourceSkyCam  = null;

            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera 00") {sourceNearCam = cam;break;}}
            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera 01") {sourceFarCam = cam;break;}}
            foreach (Camera cam in Camera.allCameras) {	if (cam.name == "Camera ScaledSpace") {sourceSkyCam = cam;break;}}

            var NearCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera 00");
            NearCamera = NearCameraGameObject.AddComponent<Camera> ();
            NearCamera.CopyFrom (sourceNearCam);
            NearCamera.enabled = false;
            NearCamera.fieldOfView = fovAngle;
            NearCamera.aspect = aspect;

            var FarCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera 01");
            FarCamera = FarCameraGameObject.AddComponent<Camera> ();
            FarCamera.CopyFrom (sourceFarCam);
            FarCamera.enabled = false;
            FarCamera.fieldOfView = fovAngle;
            FarCamera.aspect = aspect;

            var SkyboxCameraGameObject = new GameObject ("GoAtThrottleUp Cam Camera ScaledSpace");
            SkyboxCamera = SkyboxCameraGameObject.AddComponent<Camera> ();
            SkyboxCamera.transform.position = sourceSkyCam.transform.position;
            SkyboxCamera.CopyFrom (sourceSkyCam);
            SkyboxCamera.enabled = false;
            SkyboxCamera.fieldOfView = fovAngle;
            SkyboxCamera.aspect = aspect;

        }
    }
コード例 #13
0
	// Use this for initialization
	void Start () 
	{
		if(!SystemInfo.supportsImageEffects)
		{
			enabled = false;
			return;
		}
		
		camera = GetComponent<Camera>();           
		
		//Buffers for mask checking. Not the most elegant solution, but least CPU-intensive - still pretty heavy CPU-wise due to ReadPixels (pipeline break)
		checkBuffer1 = new RenderTexture(512,512,0);
		checkBuffer2 = new RenderTexture(64,64,0);
		checkBuffer3 = new RenderTexture(8,8,0);
		
		checkTexture = new Texture2D(8,8);
		
		//Shaders for mask rendering
		redMaskShader = Shader.Find("Hidden/STS_red_mask");
		redMaskShaderRT = Shader.Find("Hidden/STS_red_mask_RT");
		greenMaskShader = Shader.Find("Hidden/STS_green_mask");
		greenMaskShaderRT = Shader.Find("Hidden/STS_green_mask_RT");
		coloredMaskShader = Shader.Find("Hidden/STS_colored_mask");
		coloredMaskShaderRT = Shader.Find("Hidden/STS_colored_mask_RT");
		
		//Shaders for sfx background rendering
		outlineShader = Shader.Find("See-Through System/Outline");
		hologramShader = Shader.Find("See-Through System/Hologram");
		alphaHologramShader = Shader.Find("See-Through System/Alpha_Hologram");
		
		//for monitoring camera render area resizes
		oldResolution = new Vector2((int)camera.pixelWidth,(int)camera.pixelHeight);
		
		//Creating cameras;
		GameObject obj = new GameObject("STS_mask_camera");
		obj.transform.parent = transform;
		objectsCamera = obj.AddComponent<Camera>();
		objectsCamera.CopyFrom(camera);
		objectsCamera.cullingMask = TriggerLayers;
		objectsCamera.backgroundColor = Color.black;
		objectsCamera.clearFlags = CameraClearFlags.Color;
		objectsCamera.depthTextureMode = DepthTextureMode.None;
		objectsTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
		obstaclesTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
		if (preserveDepthTexture)
		{
			originalZBuffer =  new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,0);
			originalZBuffer.format = RenderTextureFormat.RFloat;
		}
		objectsCamera.targetTexture = objectsTexture;
		objectsCamera.enabled = false;
		
		if (backgroundCamera == null)
		{
			obj = new GameObject("STS_background_camera");
			obj.transform.parent = transform;
			backgroundCamera = obj.AddComponent<Camera>();
			backgroundCamera.CopyFrom(camera);
			backgroundCamera.cullingMask = backgroundCamera.cullingMask & (~ObstacleLayers.value);
			backgroundTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight,24);
			backgroundCamera.depthTextureMode = DepthTextureMode.None;
			backgroundCamera.enabled = false;
		}
		
		backgroundCamera.targetTexture = backgroundTexture;
		satMaterial.SetFloat("_power",1);
	}
コード例 #14
0
ファイル: Portal.cs プロジェクト: mmandel/8Nights2
        protected void UpdateCameraModes(Camera src, Camera dest)
        {
            if (!dest)
            return;

            //set portal camera to act like the current camera

            // This doesn't fully work in all Unity versions work for some reason (I haven't had a good reason to figure out why, either)
            // So we'll start with that, and then make sure things actually work.
            dest.CopyFrom(src);

            //NB: Render to the full frame, irrespective of what the source camera does:
            dest.rect = new Rect(0, 0, 1, 1);

            dest.clearFlags = src.clearFlags;
            dest.backgroundColor = src.backgroundColor;
            if (src.clearFlags == CameraClearFlags.Skybox) {
            Skybox sky = src.GetComponent<Skybox>();
            Skybox mysky = dest.GetComponent<Skybox>();
            if (!sky || !sky.material) {
                mysky.enabled = false;
            } else {
                mysky.enabled = true;
                mysky.material = sky.material;
            }
            }

            // update other values to match current camera.
            // even if we are supplying custom camera & projection matrices,
            // some of values are used elsewhere (e.g. sky box uses far plane)
            dest.farClipPlane = src.farClipPlane;
            dest.nearClipPlane = src.nearClipPlane;
            dest.orthographic = src.orthographic;
            dest.fieldOfView = src.fieldOfView;
            dest.aspect = src.aspect;
            dest.orthographicSize = src.orthographicSize;
        }
コード例 #15
0
        public override void OnStart(StartState state)
        {
            if (state != StartState.Editor)
            {
                freq = 1.0f / (float)fps;

                hasParentAntenna = this.vessel.parts.FindAll (thepart => thepart.Modules.Contains ("GATUAntenna")).Count > 0;
                if (!hasParentAntenna) {
                    return;
                }

                nextRenderTime = Time.time + freq;
                Camera sourceNearCam = null;
                Camera sourceFarCam = null;
                Camera sourceSkyCam = null;
                Camera sourceGalaxyCam = null;

                foreach (Camera cam in Camera.allCameras) {
                    if (cam.name == "Camera 00")               { sourceNearCam = cam; }
                    else if (cam.name == "Camera 01")          { sourceFarCam = cam; }
                    else if (cam.name == "Camera ScaledSpace") { sourceSkyCam = cam; }
                    else if (cam.name == "GalaxyCamera")       { sourceGalaxyCam = cam; }
                }

                var NearCameraGameObject = new GameObject ("GATU Camera 00");
                NearCamera = NearCameraGameObject.AddComponent<Camera> ();
                NearCamera.CopyFrom (sourceNearCam);
                NearCamera.enabled = false;
                NearCamera.fieldOfView = fovAngle;
                NearCamera.aspect = aspect;

                var FarCameraGameObject = new GameObject ("GATU Camera 01");
                FarCamera = FarCameraGameObject.AddComponent<Camera> ();
                FarCamera.CopyFrom (sourceFarCam);
                FarCamera.enabled = false;
                FarCamera.fieldOfView = fovAngle;
                FarCamera.aspect = aspect;

                var SkyboxCameraGameObject = new GameObject ("GATU Camera ScaledSpace");
                SkyboxCamera = SkyboxCameraGameObject.AddComponent<Camera> ();
                SkyboxCamera.transform.position = sourceSkyCam.transform.position;
                SkyboxCamera.CopyFrom (sourceSkyCam);
                SkyboxCamera.enabled = false;
                SkyboxCamera.fieldOfView = fovAngle;
                SkyboxCamera.aspect = aspect;

                var GalaxyCameraGameObject = new GameObject ("GATU GalaxyCamera");
                GalaxyCamera = GalaxyCameraGameObject.AddComponent<Camera> ();
                GalaxyCamera.transform.position = sourceGalaxyCam.transform.position;
                GalaxyCamera.CopyFrom (sourceGalaxyCam);
                GalaxyCamera.enabled = false;
                GalaxyCamera.fieldOfView = fovAngle;
                GalaxyCamera.aspect = aspect;

            }
        }
コード例 #16
0
ファイル: SSAOPro.cs プロジェクト: carlotes247/GGJ_2016
	void OnPreRender()
	{
		if (!UseHighPrecisionDepthMap)
			return;
		
		// Create the camera used to generate the alternate depth map
		if (m_RWSCamera == null)
		{
			GameObject go = new GameObject("Depth Normal Camera", typeof(Camera));
			go.hideFlags = HideFlags.HideAndDontSave;
			m_RWSCamera = go.GetComponent<Camera>();
			m_RWSCamera.CopyFrom(m_Camera);
			m_RWSCamera.renderingPath = RenderingPath.Forward;
			m_RWSCamera.clearFlags = CameraClearFlags.Color;
			m_RWSCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
			m_RWSCamera.enabled = false;
		}

		// Render depth & normals to a custom Float RenderTexture
		m_RWSCamera.CopyFrom(m_Camera);
		m_RWSCamera.rect = new Rect(0f, 0f, 1f, 1f);
		m_RWSCamera.renderingPath = RenderingPath.Forward;
		m_RWSCamera.clearFlags = CameraClearFlags.Color;
		m_RWSCamera.backgroundColor = new Color(1f, 1f, 1f, 1f);
		m_RWSCamera.farClipPlane = CutoffDistance;

		RenderTexture rt = RenderTexture.GetTemporary((int)m_Camera.pixelWidth, (int)m_Camera.pixelHeight, 24, m_RTFormat);
		rt.filterMode = FilterMode.Bilinear;
		m_RWSCamera.targetTexture = rt;
		m_RWSCamera.RenderWithShader(m_ShaderHighPrecisionDepth, "RenderType");
		rt.SetGlobalShaderProperty("_DepthNormalMapF32");
		m_RWSCamera.targetTexture = null;
		RenderTexture.ReleaseTemporary(rt);
	}
コード例 #17
0
 //helper method that copies camera properties from one camera to another
 //copies from srcCamera to destCamera
 private void CopyCamera(Camera srcCamera, Camera destCamera)
 {
     //Copy the camera properties.
     destCamera.CopyFrom(srcCamera);
     destCamera.depth = 0;
     //@todo Copy other components attached to the DisplayController?
 }           
コード例 #18
0
    RenderTexture UpdateOcclusionCamera(Camera source, Camera target, Shader replacement)
    {
        if(target.targetTexture) {
            Debug.LogError("Didn't expect existing render texture: " + target.name);
            RenderTexture.ReleaseTemporary(target.targetTexture);
            target.targetTexture = null;
        }

        // Start by copying everything from src, but then override quite a few things.
        target.CopyFrom(source);

        var pr = source.pixelRect;
        var rt = target.targetTexture = RenderTexture.GetTemporary(
            Mathf.RoundToInt(pr.width),
            Mathf.RoundToInt(pr.height),
            Application.isPlaying ? 24 : 16, // this avoids a bug that corrupts scene view depth
            RenderTextureFormat.ARGB2101010
        );

        target.renderingPath = RenderingPath.Forward;
        target.depthTextureMode = DepthTextureMode.None;
        target.clearFlags = CameraClearFlags.SolidColor;
        target.backgroundColor = Color.white;
        target.useOcclusionCulling = false;
        target.cullingMask = cullingMask;
        target.farClipPlane = maxDistance + 5f;

        target.RenderWithShader(replacement, "Special");

        return rt;
    }
コード例 #19
0
        private void ConfigureCamCursor(Camera camCursor, Camera cam, BasicSettings.Sides caveSide, bool isEyeLeft = true)
        {
            camCursor.CopyFrom(cam);
            camCursor.cullingMask = LayerMask.GetMask("UI");

            camCursor.name = "CameraCursor" + caveSide.ToString() + (isEyeLeft ? "Left" : "Right");
            camCursor.clearFlags = CameraClearFlags.Depth;
            camCursor.transform.SetParent(cam.transform.parent);
            camCursor.depth = (int)CameraDepths.Cursor;
            camCursor.enabled = false;
            camCursor.orthographic = true;
            camCursor.farClipPlane = 10f;
            camCursor.nearClipPlane = 5f;
        }
コード例 #20
0
        private void ConfigureCamGUI(Camera camGUI, Camera cam, bool isEyeLeft = true)
        {
            camGUI.CopyFrom(cam);
            camGUI.cullingMask = LayerMask.GetMask("UI");

            camGUI.name = isEyeLeft ? "CameraGUILeft" : "CameraGUIRight";
            camGUI.clearFlags = CameraClearFlags.Depth;
            camGUI.transform.SetParent(cam.transform.parent);
            camGUI.depth = (int)CameraDepths.GUI;
            camGUI.orthographic = true;
            camGUI.farClipPlane = 10f;
            camGUI.nearClipPlane = 5f;
        }
コード例 #21
0
        public void OnLevelWasLoaded(int level)
        {
            if (!occulusVR)
            {
                if (level == 14)
                {
                    oldParamVisible = GameMain.Instance.CMSystem.GetSystemVers("夜伽_HideScroll_HorizontalRigt");
                    faceCameraObj = new GameObject("faceCamera");
                    faceCamera = faceCameraObj.AddComponent<Camera>();
                    faceCamera.CopyFrom(Camera.main);

                    SetRect(oldParamVisible);

                    faceCameraObj.SetActive(true);

                    SearchMaid();

                    allowUpdate = true;
                }
                else
                {
                    allowUpdate = false;
                }
            }
        }
 private void Awake()
 {
     if (m_Camera == null)
     {
         m_Camera = this.gameObject.AddComponent<Camera>();
         m_Camera.CopyFrom(Camera.main);
         m_Camera.renderingPath = RenderingPath.Forward; // important to make fragment shader work with function Camera.RenderWithShader() - it won't work in deferred, this is no problem since we only want to render a custom index rendertexture anyway
         m_Camera.enabled = false; // important to disable camera so we can invoke Camera.RenderWithShader() manually later
     }
 }
コード例 #23
0
    void OnEnable()
    {
        if(!RTcustom_CAMERA)
        {

        //Render Cam
        GameObject go = new GameObject ("RenderCamPos", typeof(Camera));
        go.hideFlags  = HideFlags.HideAndDontSave;
           		RTcustom_CAMERA      = go.GetComponent<Camera>();
        RTcustom_CAMERA.CopyFrom(this.GetComponent<Camera>());
           	RTcustom_CAMERA.clearFlags = CameraClearFlags.Color;
        RTcustom_CAMERA.renderingPath = RenderingPath.Forward;
        RTcustom_CAMERA.backgroundColor = new Color(0,0,0,0);
        RTcustom_CAMERA.enabled = false;

        }

        //Create The Materials Required
        SSRR_MATERIAL 		    = new Material(Shader.Find("Hidden/CandelaSSRRv2"));
        SSRR_MATERIAL.hideFlags = HideFlags.HideAndDontSave;
        POST_COMPOSE_MATERIAL   = new Material(Shader.Find("Hidden/CandelaCompose"));
        POST_COMPOSE_MATERIAL.hideFlags = HideFlags.HideAndDontSave;

        LUMACOMP_MAT = new Material(Shader.Find("Hidden/LumaComp"));
        LUMACOMP_MAT.hideFlags = HideFlags.HideAndDontSave;
    }
コード例 #24
0
  void InitCamera()
  {
    SceneCamera = GetComponent<Camera>();

    // setup separate camera for render buffer
    var camTrans = transform.FindChild("CamNode");
    if (camTrans != null)
    {
      DestroyImmediate(camTrans.gameObject);
    }

    var camNode = new GameObject("CamNode");
    camNode.transform.parent = transform;
    m_bufferCam = camNode.AddComponent<Camera>();
    m_bufferCam.CopyFrom(SceneCamera);
    m_bufferCam.enabled = false;

    if (m_bufferCam == null)
    {
      Debug.LogError("Camera must not be null!");
    }
    m_bufferCam.depthTextureMode |= DepthTextureMode.Depth;

    // default forward rendering
    if (m_bufferCam.renderingPath == RenderingPath.UsePlayerSettings)
    {
      m_bufferCam.renderingPath = RenderingPath.Forward;
    }
    // memorize rendering path
    m_currentRenderingPath = m_bufferCam.renderingPath;

    // set initial frustum rays
    SetFrustumRays();
  }
コード例 #25
0
        /// <summary>ゲームレベルが変化した際に呼ばれる</summary>
        public void OnLevelWasLoaded(int level)
        {
            m_AllowUpdate = false;
            if( m_bOculusVR)
                return;

            // 現在の level が ScenesEnable リストに含まれていたら有効にする
            if(( "," + m_cfg.ScenesEnable + "," ).Contains( level.ToString())
                    || m_cfg.ScenesEnable.ToUpper().Contains( "ALL" ))
            {
                // 左目用カメラ
                m_CameraL = (new GameObject( "ParallaxCameraL" )).AddComponent<Camera>();
                m_CameraL.CopyFrom( Camera.main );
                // 右目用カメラ
                m_CameraR = (new GameObject( "ParallaxCameraR" )).AddComponent<Camera>();
                m_CameraR.CopyFrom( Camera.main );

                SetStereoPower( m_cfg.DefaultPower );
                SetStereoMode( m_cfg.DefaultMode );

                m_AllowUpdate = true;
            }
        }
コード例 #26
0
 void Start()
 {
     if(Application.isPlaying)
     {
         if (!(targetCamera = GetComponent<Camera>()))
         {
             LogCameraError();
             return;
         }
         GameObject newChild = new GameObject("Final Pass Camera");
         newChild.transform.parent = transform;
         //newChild.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable;
         finalPassCamera = newChild.AddComponent<Camera>();
         finalPassCamera.CopyFrom(targetCamera);
         finalPassCamera.clearFlags = CameraClearFlags.Nothing;
         finalPassCamera.backgroundColor = new Color(1, 1, 1, 0);
         finalPassCamera.cullingMask = 0;
         finalPassCamera.orthographic = true;
         finalPassCamera.depth = targetCamera.depth + 0.01f;
         finalPassCamera.hdr = targetCamera.hdr;
         finalPassCamera.renderingPath = RenderingPath.Forward;
         finalPassCamera.useOcclusionCulling = false;
         subScript = newChild.AddComponent<CustomRenderResolutionFinalStage>();
         subScript.creator = this;
         BuildTexture();
     }
     else
     {
         if (!GetComponent<Camera>())
         {
             LogCameraError();
             return;
         }
     }
 }
void CreateBlackAndWhiteCameras (){
  whiteCamGameObject = (GameObject) new GameObject();
  whiteCamGameObject.name="White Background Camera";
  whiteCam=whiteCamGameObject.AddComponent<Camera>();
  whiteCam.CopyFrom(mainCam);
  whiteCam.backgroundColor=Color.white;
  whiteCamGameObject.transform.SetParent(gameObject.transform, true);

  blackCamGameObject = (GameObject) new GameObject();
  blackCamGameObject.name="Black Background Camera";
  blackCam=blackCamGameObject.AddComponent<Camera>();
  blackCam.CopyFrom(mainCam);
  blackCam.backgroundColor=Color.black;
  blackCamGameObject.transform.SetParent(gameObject.transform, true);
}