Ejemplo n.º 1
1
		protected virtual void MultiPassBlur(RenderTexture source, RenderTexture destination)
		{
			int w = Mathf.FloorToInt((float)source.width / Downscaling);
			int h = Mathf.FloorToInt((float)source.height / Downscaling);
			Vector2 horizontal = new Vector2(1f / w, 0f);
			Vector2 vertical = new Vector2(0f, 1f / h);
			RenderTexture rt1 = RenderTexture.GetTemporary(w, h, 0, source.format);
			RenderTexture rt2 = RenderTexture.GetTemporary(w, h, 0, source.format);

			Material.SetVector("_Direction", horizontal);
			Graphics.Blit(source, rt1, Material);
			Material.SetVector("_Direction", vertical);
			Graphics.Blit(rt1, rt2, Material);

			for (int i = 1; i < Passes; i++)
			{
				Material.SetVector("_Direction", horizontal);
				Graphics.Blit(rt2, rt1, Material);
				Material.SetVector("_Direction", vertical);
				Graphics.Blit(rt1, rt2, Material);
			}

			Graphics.Blit(rt2, destination);

			RenderTexture.ReleaseTemporary(rt1);
			RenderTexture.ReleaseTemporary(rt2);
		}
Ejemplo n.º 2
0
        protected void PipeTextures()
        {
            RefreshTextureScript rts = this.GetComponent<RefreshTextureScript>();
            if (rts != null) {
            this.source = rts.toReplace;

            } else {
            //grab original base texture. this is source.
            this.source = this.renderer.material.GetTexture("_MainTex");
            }
            if ((this.source as RenderTexture) != null) {
            RenderTexture s = this.source as RenderTexture;
            //create new destination texture.
            this.destination = new RenderTexture(s.width,s.height,s.depth);

            } else {
            this.destination = new RenderTexture(source.width,source.height,24);
            }

            //assign destination texture to existing shader.
            if (rts != null) {
            rts.toReplace = this.destination;
            } else {
            this.renderer.material.SetTexture("_MainTex",this.destination);
            }
        }
Ejemplo n.º 3
0
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (CheckResources() == false) {
                Graphics.Blit (source, destination);
                return;
            }

            tiltShiftMaterial.SetFloat("_BlurSize", maxBlurSize < 0.0f ? 0.0f : maxBlurSize);
            tiltShiftMaterial.SetFloat("_BlurArea", blurArea);
            source.filterMode = FilterMode.Bilinear;

            RenderTexture rt = destination;
            if (downsample > 0f) {
                rt = RenderTexture.GetTemporary (source.width>>downsample, source.height>>downsample, 0, source.format);
                rt.filterMode = FilterMode.Bilinear;
            }

            int basePassNr = (int) quality; basePassNr *= 2;
            Graphics.Blit (source, rt, tiltShiftMaterial, mode == TiltShiftMode.TiltShiftMode ? basePassNr : basePassNr + 1);

            if (downsample > 0) {
                tiltShiftMaterial.SetTexture ("_Blurred", rt);
                Graphics.Blit (source, destination, tiltShiftMaterial, 8);
            }

            if (rt != destination)
                RenderTexture.ReleaseTemporary (rt);
        }
Ejemplo n.º 4
0
		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material.SetFloat("_Exposure", 8f - Exposure);
			Material.SetVector("_Balance", Vector3.one - Balance);
			Material.SetFloat("_Amount", Amount);
			Graphics.Blit(source, destination, Material);
		}
Ejemplo n.º 5
0
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (_material == null)
            {
                _material = new Material(_shader);
                _material.hideFlags = HideFlags.DontSave;
            }

            var cam = GetComponent<Camera>();
            var aspect = new Vector4(cam.aspect, 1.0f / cam.aspect, 1, 0);

            _material.SetVector("_CameraAspect", aspect);
            _material.SetFloat("_LateralShift", _lateralShift);
            _material.SetFloat("_AxialStrength", _axialStrength);
            _material.SetFloat("_AxialShift", _axialShift);

            if (_axialStrength == 0)
            {
                _material.DisableKeyword("AXIAL_SAMPLE_LOW");
                _material.DisableKeyword("AXIAL_SAMPLE_HIGH");
            }
            else if (_axialQuality == QualityLevel.Low)
            {
                _material.EnableKeyword("AXIAL_SAMPLE_LOW");
                _material.DisableKeyword("AXIAL_SAMPLE_HIGH");
            }
            else
            {
                _material.DisableKeyword("AXIAL_SAMPLE_LOW");
                _material.EnableKeyword("AXIAL_SAMPLE_HIGH");
            }

            Graphics.Blit(source, destination, _material, 0);
        }
Ejemplo n.º 6
0
        /*
         * Constructor
         * Input: The owning part's transform.
         * Purpose: This constructor will start up the owning part's camera object. The idea behind this
         * was to allow for multiple telescopes on the same craft.
         */
        public CactEyeCamera(Transform Position)
        {
            this.CameraTransform = Position;

            CameraWidth = (int)(Screen.width*0.4f);
            CameraHeight = (int)(Screen.height*0.4f);

            ScopeRenderTexture = new RenderTexture(CameraWidth, CameraHeight, 24);
            ScopeRenderTexture.Create();

            FullResolutionTexture = new RenderTexture(Screen.width, Screen.height, 24);
            FullResolutionTexture.Create();

            ScopeTexture2D = new Texture2D(CameraWidth, CameraHeight);
            FullTexture2D = new Texture2D(Screen.width, Screen.height);

            CameraSetup(0, "GalaxyCamera"); //As of KSP 1.0, the GalaxyCamera object was added. Thanks to MOARDv for figuring this one out.
            CameraSetup(1, "Camera ScaledSpace");
            CameraSetup(2, "Camera 01");
            CameraSetup(3, "Camera 00");
            CameraSetup(4, "Camera VE Underlay");
            CameraSetup(5, "Camera VE Overlay");

            skyboxRenderers = (from Renderer r in (FindObjectsOfType(typeof(Renderer)) as IEnumerable<Renderer>) where (r.name == "XP" || r.name == "XN" || r.name == "YP" || r.name == "YN" || r.name == "ZP" || r.name == "ZN") select r).ToArray<Renderer>();
            if (skyboxRenderers == null)
            {
                Debug.Log("CactEye 2: Logical Error: skyboxRenderers is null!");
            }

            scaledSpaceFaders = FindObjectsOfType(typeof(ScaledSpaceFader)) as ScaledSpaceFader[];
            if (scaledSpaceFaders == null)
            {
                Debug.Log("CactEye 2: Logical Error: scaledSpaceFaders is null!");
            }
        }
        // flat blur
        void Blur(RenderTexture from  ,RenderTexture  to , int iterations  , int blurPass, float spread  )
        {
            RenderTexture tmp  = RenderTexture.GetTemporary (to.width, to.height, 0);

            if (iterations < 2) {
                dofBlurMaterial.SetVector ("offsets", new Vector4 (0.0f, spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (from, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  0.0f, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);
            }
            else {
                dofBlurMaterial.SetVector ("offsets", new Vector4 (0.0f, spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (from, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  0.0f, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (to, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  -spread * oneOverBaseSize, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);
            }

            RenderTexture.ReleaseTemporary (tmp);
        }
		public void Cleanup()
		{
			if (this.m_Camera)
			{
				UnityEngine.Object.DestroyImmediate(this.m_Camera.gameObject, true);
			}
			if (this.m_RenderTexture)
			{
				UnityEngine.Object.DestroyImmediate(this.m_RenderTexture);
				this.m_RenderTexture = null;
			}
			if (this.m_RenderTextureGammaCorrect)
			{
				UnityEngine.Object.DestroyImmediate(this.m_RenderTextureGammaCorrect);
				this.m_RenderTextureGammaCorrect = null;
			}
			Light[] light = this.m_Light;
			for (int i = 0; i < light.Length; i++)
			{
				Light light2 = light[i];
				if (light2)
				{
					UnityEngine.Object.DestroyImmediate(light2.gameObject, true);
				}
			}
		}
Ejemplo n.º 9
0
        void OnRenderImage(RenderTexture src, RenderTexture dst)
        {
            if (m_material == null)
            {
                m_material = new Material(m_shader);
            }

            if (m_edge_highlighting)
            {
                m_material.EnableKeyword("ENABLE_EDGE_HIGHLIGHTING");
            }
            else
            {
                m_material.DisableKeyword("ENABLE_EDGE_HIGHLIGHTING");
            }

            if (m_mul_smoothness)
            {
                m_material.EnableKeyword("ENABLE_SMOOTHNESS_ATTENUAION");
            }
            else
            {
                m_material.DisableKeyword("ENABLE_SMOOTHNESS_ATTENUAION");
            }

            m_material.SetVector("_Color", GetLinearColor());
            m_material.SetVector("_Params1", new Vector4(m_fresnel_bias, m_fresnel_scale, m_fresnel_pow, m_intensity));
            m_material.SetVector("_Params2", new Vector4(m_edge_intensity, m_edge_threshold, m_edge_radius, 0.0f));
            Graphics.Blit(src, dst, m_material);
        }
Ejemplo n.º 10
0
	//This will write the values in data array into tex
	static public void WriteIntoRenderTexture(RenderTexture tex, int channels, float[] data)
	{
		if(tex == null)
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture - RenderTexture is null");
			return;
		}
		
		if(data == null)
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture - Data is null");
			return;
		}
		
		if(channels < 1 || channels > 4)
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture - Channels must be 1, 2, 3, or 4");
			return;
		}
		
		int w = tex.width;
		int h = tex.height;
		int size = w*h*channels;
		
		Color[] map = new Color[size];
		
		float max = 1.0f;
		float min = 0.0f;
		LoadData(data, map, size, ref min, ref max);
		
		DecodeFloat(w, h, channels, min, max, tex, map);
	}
Ejemplo n.º 11
0
        void BuildTexture()
        {
            if(Application.isPlaying)
            {
                if (resolutionType == Type.CustomResolution)
                {
                    customResolution.x = Mathf.Max(1, customResolution.x);
                    customResolution.x = Mathf.Min(Screen.width * 4, customResolution.x);
                    customResolution.y = Mathf.Max(1, customResolution.y);
                    customResolution.y = Mathf.Min(Screen.height * 4, customResolution.y);
                    customTexture = new RenderTexture(customResolution.x, customResolution.y, 32);
                }
                else if (resolutionType == Type.ScreenResolutionMultiplier)
                {
                    screenResolutionMultiplier = Mathf.Max(0, screenResolutionMultiplier);
                    screenResolutionMultiplier = Mathf.Min(4, screenResolutionMultiplier);
                    int width = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.width));
                    int height = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.height));
                    customTexture = new RenderTexture(width, height, 32);
                }
                customTexture.filterMode = filterMode;
                customTexture.name = "Custom Render Resolution Texture";
                customTexture.Create();
                targetCamera.targetTexture = customTexture;
                subScript.customTexture = customTexture;

                customResolutionLast = customResolution;
                filterModeLast = filterMode;
                screenResolutionMultiplierLast = screenResolutionMultiplier;
            }
        }
        public void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            CheckResources();
            originalTex = new Texture2D(source.width, source.height);

            // change texture. every white pixel should be transparent after this
            int y = 0;
            while (y < originalTex.height)
            {
                int x = 0;
                while (x < originalTex.width)
                {
                    Color colorAtPixel = new Color();
                    colorAtPixel = originalTex.GetPixel(x, y);
                    if (colorAtPixel[0] == 1 && colorAtPixel[1] == 1 && colorAtPixel[2] == 1 && colorAtPixel[3] == 1)
                    {
                        originalTex.SetPixel(x, y, Color.clear);
                    }
                    else
                    {
                        originalTex.SetPixel(x, y, new Color(colorAtPixel[0], colorAtPixel[1], colorAtPixel[2], colorAtPixel[3] ));
                    }
                    ++x;
                }
                ++y;
            }
            originalTex.Apply();

            transparentMaterial.SetTexture("_MainTex", originalTex);

            Graphics.Blit(source, destination, transparentMaterial, 0);
        }
Ejemplo n.º 13
0
        IEnumerator PostScreenshot()
        {
            yield return new WaitForEndOfFrame();

            var cam = Camera.current;
            var renderTexture = new RenderTexture(Screen.width, Screen.height, 24);
            cam.targetTexture = renderTexture;
            cam.Render();
            cam.targetTexture = null;

            Texture2D screenshot = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.RGB24, false);
            screenshot.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
            screenshot.Apply();
            Debug.Log("Screenshot taken...");

            Imvu.Login().Then(
                userModel => userModel.GetPersonalFeed()
            ).Then(
                feedCollection => {
                    return feedCollection.PostImage(screenshot);
                }
            ).Then(
                _ => Debug.Log("Screenshot posted!")
            ).Catch(
                error => Debug.Log(error.message)
            );
        }
Ejemplo n.º 14
0
 RenderTexture CreateTextureFor(Camera cam)
 {
     RenderTexture rt = new RenderTexture(Mathf.FloorToInt(cam.pixelWidth * 0.5F),
         Mathf.FloorToInt(cam.pixelHeight * 0.5F), 24);
     rt.hideFlags = HideFlags.DontSave;
     return rt;
 }
Ejemplo n.º 15
0
 public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
 {
     ourVessel = thatPart.vessel;
     ourPart = thatPart;
     screenTexture = screen;
     cameraAspect = aspect;
 }
Ejemplo n.º 16
0
		void OnRenderImage (RenderTexture source, RenderTexture destination) 
		{
			if(BDArmorySettings.BW_TARGET_CAM || TargetingCamera.Instance.nvMode)
			{
				Graphics.Blit (source, destination, grayscaleMaterial); //apply grayscale
			}
		}
Ejemplo n.º 17
0
		void OnRenderImage(RenderTexture source, RenderTexture destination) {
			base.material.SetFloat("_DirectionX", directionX);
			base.material.SetFloat("_DirectionY", directionY);
			base.material.SetFloat("_Speed", speed);
			base.material.SetFloat("_Amplitude", amplitude);
			Graphics.Blit (source, destination, material);
		}
Ejemplo n.º 18
0
 // Called by camera to apply image effect
 void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     material.SetTexture("_RampTex", textureRamp);
     material.SetFloat("_RampOffset", rampOffset);
     material.SetFloat("_EffectAmount", effectAmount);
     Graphics.Blit (source, destination, material);
 }
Ejemplo n.º 19
0
        void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            int desiredDepth = Math.Max(src.depth, dest.depth);

            for (int i = 0; i < temp.Length; i++)
            {
                if (onRenderImageMethods.Count > i + 1)
                {
                    if (temp[i] != null &&
                        (temp[i].width != dest.width || temp[i].height != dest.height || temp[i].depth != desiredDepth || temp[i].format != dest.format))
                    {
                        Destroy(temp[i]);
                        temp[i] = null;
                    }
                    if (temp[i] == null)
                        temp[i] = new RenderTexture(dest.width, dest.height, desiredDepth, dest.format);
                }
            }

            var sequence = new List<RenderTexture>();
            sequence.Add(src);
            for (int i = 0; i < onRenderImageMethods.Count - 1; i++)
                sequence.Add(i % 2 == 0 ? temp[0] : temp[1]);
            sequence.Add(dest);

            for (int i = 0; i < onRenderImageMethods.Count; i++)
                onRenderImageMethods[i].Method.Invoke(onRenderImageMethods[i].Instance, new object[] { sequence[i], sequence[i + 1] });
        }
Ejemplo n.º 20
0
		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material.SetVector("_Params", new Vector4(Sharpness * 0.01f, Darkness * 0.02f, Contrast * 0.01f, EdgeBlending * 0.01f));
			Material.SetVector("_Coeffs", ContrastCoeff);
			Material.SetVector("_Center", Center);
			Graphics.Blit(source, destination, Material);
		}
Ejemplo n.º 21
0
		void OnRenderImage(RenderTexture source, RenderTexture destination) {
			base.material.SetFloat("_Speed", speed);
			base.material.SetFloat("_Thickness", thickness);
			base.material.SetFloat("_Luminance", luminance);
			base.material.SetFloat("_Darkness", darkness);
			Graphics.Blit (source, destination, material);
		}
Ejemplo n.º 22
0
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (CheckResources() == false)
            {
                Graphics.Blit (source, destination);
                return;
            }

            Vector4 UV_Transform = new  Vector4(1, 0, 0, 1);

            #if UNITY_WP8
            // WP8 has no OS support for rotating screen with device orientation,
            // so we do those transformations ourselves.
            if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
                UV_Transform = new Vector4(0, -1, 1, 0);
            }
            if (Screen.orientation == ScreenOrientation.LandscapeRight) {
                UV_Transform = new Vector4(0, 1, -1, 0);
            }
            if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) {
                UV_Transform = new Vector4(-1, 0, 0, -1);
            }
            #endif

            overlayMaterial.SetVector("_UV_Transform", UV_Transform);
            overlayMaterial.SetFloat ("_Intensity", intensity);
            overlayMaterial.SetTexture ("_Overlay", texture);
            Graphics.Blit (source, destination, overlayMaterial, (int) blendMode);
        }
Ejemplo n.º 23
0
        private void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (CheckResources() == false)
            {
                Graphics.Blit(source, destination);
                return;
            }

            float widthOverHeight = (1.0f*source.width)/(1.0f*source.height);
            float oneOverBaseSize = 1.0f/512.0f;

            RenderTexture hrTex = RenderTexture.GetTemporary(source.width, source.height, 0);
            RenderTexture lrTex1 = RenderTexture.GetTemporary(source.width/2, source.height/2, 0);
            RenderTexture lrTex2 = RenderTexture.GetTemporary(source.width/2, source.height/2, 0);

            Graphics.Blit(source, hrTex, depthFetchMaterial);
            Graphics.Blit(hrTex, lrTex1);

            for (int i = 0; i < softness; i++)
            {
                blurMaterial.SetVector("offsets", new Vector4(0.0f, spread*oneOverBaseSize, 0.0f, 0.0f));
                Graphics.Blit(lrTex1, lrTex2, blurMaterial);
                blurMaterial.SetVector("offsets", new Vector4(spread*oneOverBaseSize/widthOverHeight, 0.0f, 0.0f, 0.0f));
                Graphics.Blit(lrTex2, lrTex1, blurMaterial);
            }

            creaseApplyMaterial.SetTexture("_HrDepthTex", hrTex);
            creaseApplyMaterial.SetTexture("_LrDepthTex", lrTex1);
            creaseApplyMaterial.SetFloat("intensity", intensity);
            Graphics.Blit(source, destination, creaseApplyMaterial);

            RenderTexture.ReleaseTemporary(hrTex);
            RenderTexture.ReleaseTemporary(lrTex1);
            RenderTexture.ReleaseTemporary(lrTex2);
        }
Ejemplo n.º 24
0
		void OnRenderImage( RenderTexture source, RenderTexture destination )
		{
			if( CheckResources() == false )
			{
				Graphics.Blit( source, destination );
				return;
			}

			cloudsMaterial.SetFloat( "_ForwardIntegrator", m_distTravelledForward );

			Vector4 camPos = new Vector4( transform.position.x, transform.position.y, transform.position.z, 0.0f );
			cloudsMaterial.SetVector( "_CamPos", camPos );
			
			Vector4 camForward = new Vector4( transform.forward.x, transform.forward.y, transform.forward.z, 0.0f );
			cloudsMaterial.SetVector( "_CamForward", camForward );
			Vector4 camRight = new Vector4( transform.right.x, transform.right.y, transform.right.z, 0.0f );
			cloudsMaterial.SetVector( "_CamRight", camRight );

			/*
			Vector4 spherePos = Vector4.zero;
			if( sphere )
				spherePos.Set( sphere.position.x, sphere.position.y, sphere.position.z, 0.0f );
			cloudsMaterial.SetVector( "_SphereCenter", spherePos );
			*/

			cloudsMaterial.SetTexture( "_NoiseTex", noiseTexture );

			Graphics.Blit( source, destination, cloudsMaterial, 0 );

			cloudsMaterial.SetFloat( "_SamplesCurvature", m_samplesCurvature );
			//cloudsMaterial.SetFloat( "_CenterOfRot",  centerOfRot );

			float fov = Mathf.Max( Camera.main.aspect, 1.0f ) * Camera.main.fieldOfView * Mathf.Deg2Rad;
			cloudsMaterial.SetFloat( "_HalfFov", fov/2.0f );
		}
        // Postprocess the image
        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (_material == null) return;

            var transitionStepFloat = CurrentTransitionStep as TransitionStepFloat;
            if (transitionStepFloat != null)
            {

                _material.SetTexture("_OverlayTex", TransitionMode == TransitionModeType.In ? InConfig.Texture : OutConfig.Texture);
                _material.SetColor("_Color", TransitionMode == TransitionModeType.In ? InConfig.Color : OutConfig.Color);
                _material.SetTexture("_MaskTex", TransitionMode == TransitionModeType.In ? InConfig.MaskTexture : OutConfig.MaskTexture);
                _material.SetFloat("_Amount", transitionStepFloat.Value);
                if (TransitionMode == TransitionModeType.In ? InConfig.InvertMask : OutConfig.InvertMask)
                    _material.EnableKeyword("INVERT_MASK");
                else
                    _material.DisableKeyword("INVERT_MASK");

                // We can set skip idle rendering to only do image effect if a transition is in progress. This can however cause problems with
                // multiple image effects.
                // TODO: Check the below condition is still valid, in particular the Amount part
                //if (SkipIdleRendering &&
                //    ((TransitionMode == TransitionModeType.In && TransitionInConfig.TransitionType == TransitionHelper.TransitionType.none) ||
                //    (TransitionMode == TransitionModeType.Out && TransitionOutConfig.TransitionType == TransitionHelper.TransitionType.none) ||
                //    Amount == 0)) return;

                Graphics.Blit(source, destination, _material);
            }
        }
Ejemplo n.º 26
0
        static void CustomGraphicsBlit(RenderTexture source, RenderTexture dest, Material fxMaterial, int passNr)
        {
            RenderTexture.active = dest;

            fxMaterial.SetTexture ("_MainTex", source);

            GL.PushMatrix ();
            GL.LoadOrtho ();

            fxMaterial.SetPass (passNr);

            GL.Begin (GL.QUADS);

            GL.MultiTexCoord2 (0, 0.0f, 0.0f);
            GL.Vertex3 (0.0f, 0.0f, 3.0f); // BL

            GL.MultiTexCoord2 (0, 1.0f, 0.0f);
            GL.Vertex3 (1.0f, 0.0f, 2.0f); // BR

            GL.MultiTexCoord2 (0, 1.0f, 1.0f);
            GL.Vertex3 (1.0f, 1.0f, 1.0f); // TR

            GL.MultiTexCoord2 (0, 0.0f, 1.0f);
            GL.Vertex3 (0.0f, 1.0f, 0.0f); // TL

            GL.End ();
            GL.PopMatrix ();
        }
Ejemplo n.º 27
0
 protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     Material.SetVector("_RedClamp", Red);
     Material.SetVector("_GreenClamp", Green);
     Material.SetVector("_BlueClamp", Blue);
     Graphics.Blit(source, destination, Material);
 }
Ejemplo n.º 28
0
	//Load 32 bit float data from raw file and write into render texture with option of returning raw loaded data
		//static public void WriteIntoRenderTexture(RenderTexture tex, int channels, string path, float[] fdata = null)
		static public void WriteIntoRenderTexture(RenderTexture tex, int channels, string path, float[] fdata)
	{
		if(tex == null)
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture- RenderTexture is null");
			return;
		}
		
		if(channels < 1 || channels > 4)
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture - Channels must be 1, 2, 3, or 4");
			return;
		}
		
		int w = tex.width;
		int h = tex.height;
		int size = w*h*channels;
		
		Color[] map = new Color[size];
		if(fdata == null) fdata = new float[size];
		
		float max = 1.0f;
		float min = 0.0f;
		if(!LoadRawFile(path, map, size, ref min, ref max, fdata))
		{
			Debug.Log("EncodeFloat::WriteIntoRenderTexture - Error loading raw file " + path);
			return;
		}
		
		DecodeFloat(w, h, channels, min, max, tex, map);
		
	}
Ejemplo n.º 29
0
        void LateUpdate()
        {
            if (Input.GetKeyUp(KeyCode.S)) {
            #if !UNITY_WEBPLAYER
            int resWidth = 4096, resHeight = 2048;
            RenderTexture rt = new RenderTexture(resWidth, resHeight, 24);
            camera.targetTexture = rt;
            camera.Render();
            RenderTexture prevActive = RenderTexture.active;
            RenderTexture.active = rt;

            Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.ARGB32, false);
            screenShot.ReadPixels(new Rect(0, 0, resWidth, resHeight), 0, 0, false);

            camera.targetTexture = null;
            RenderTexture.active = prevActive;
            Destroy(rt);

            screenShot = DownSample(screenShot);

            byte[] bytes = screenShot.EncodeToPNG();
            string filename = ScreenshotPath();
            System.IO.File.WriteAllBytes(filename, bytes);
            Debug.Log("Screenshot stored at: '" + filename + "'");
            #else
            Debug.LogWarning("Screen shot not supported in WebPlayer.");
            #endif
            }
        }
Ejemplo n.º 30
0
		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material.SetVector("_Red", m_Channels[(int)RedSource]);
			Material.SetVector("_Green", m_Channels[(int)GreenSource]);
			Material.SetVector("_Blue", m_Channels[(int)BlueSource]);
			Graphics.Blit(source, destination, Material);
		}
 static public int set_format(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture       self = (UnityEngine.RenderTexture)checkSelf(l);
         UnityEngine.RenderTextureFormat v;
         checkEnum(l, 2, out v);
         self.format = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_antiAliasing(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture self = (UnityEngine.RenderTexture)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.antiAliasing = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_isVolume(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture self = (UnityEngine.RenderTexture)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.isVolume = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 34
0
 static public int set_descriptor(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture           self = (UnityEngine.RenderTexture)checkSelf(l);
         UnityEngine.RenderTextureDescriptor v;
         checkValueType(l, 2, out v);
         self.descriptor = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 35
0
 static public int set_dimension(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture self = (UnityEngine.RenderTexture)checkSelf(l);
         UnityEngine.Rendering.TextureDimension v;
         checkEnum(l, 2, out v);
         self.dimension = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int SetGlobalShaderProperty(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture self = (UnityEngine.RenderTexture)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         self.SetGlobalShaderProperty(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 37
0
    static bool Graphics_Blit__Texture__RenderTexture__Material(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 3)
        {
            UnityEngine.Texture       arg0 = (UnityEngine.Texture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.RenderTexture arg1 = (UnityEngine.RenderTexture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Material      arg2 = (UnityEngine.Material)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Graphics.Blit(arg0, arg1, arg2);
        }

        return(true);
    }
Ejemplo n.º 38
0
 static public int set_memorylessMode(IntPtr l)
 {
     try {
         UnityEngine.RenderTexture           self = (UnityEngine.RenderTexture)checkSelf(l);
         UnityEngine.RenderTextureMemoryless v;
         checkEnum(l, 2, out v);
         self.memorylessMode = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 39
0
    static public int constructor(IntPtr l)
    {
        int argc = LuaDLL.lua_gettop(l);

        UnityEngine.RenderTexture o;
        if (argc == 6)
        {
            System.Int32 a1;
            checkType(l, 2, out a1);
            System.Int32 a2;
            checkType(l, 3, out a2);
            System.Int32 a3;
            checkType(l, 4, out a3);
            UnityEngine.RenderTextureFormat a4;
            checkEnum(l, 5, out a4);
            UnityEngine.RenderTextureReadWrite a5;
            checkEnum(l, 6, out a5);
            o = new UnityEngine.RenderTexture(a1, a2, a3, a4, a5);
            pushObject(l, o);
            return(1);
        }
        else if (argc == 5)
        {
            System.Int32 a1;
            checkType(l, 2, out a1);
            System.Int32 a2;
            checkType(l, 3, out a2);
            System.Int32 a3;
            checkType(l, 4, out a3);
            UnityEngine.RenderTextureFormat a4;
            checkEnum(l, 5, out a4);
            o = new UnityEngine.RenderTexture(a1, a2, a3, a4);
            pushObject(l, o);
            return(1);
        }
        else if (argc == 4)
        {
            System.Int32 a1;
            checkType(l, 2, out a1);
            System.Int32 a2;
            checkType(l, 3, out a2);
            System.Int32 a3;
            checkType(l, 4, out a3);
            o = new UnityEngine.RenderTexture(a1, a2, a3);
            pushObject(l, o);
            return(1);
        }
        LuaDLL.luaL_error(l, "New object failed.");
        return(0);
    }
Ejemplo n.º 40
0
    public void OnDropdownValueChange()
    {
        int v = m_Dropdown.value;
        int height = 1, width = 1;

        switch (v)
        {
        case 0:                     //1440p
            height = 1440;
            width  = 2560;
            break;

        case 1:                     //1080p
            height = 1080;
            width  = 1920;
            break;

        case 2:                     //720p
            height = 720;
            width  = 1280;
            break;

        case 3:                     //480p
            height = 340;
            width  = 480;
            break;

        case 4:                     //360p
            height = 360;
            width  = 640;
            break;

        case 5:                     //240p
            height = 240;
            width  = 427;
            break;

        case 6:                     //144p
            height = 144;
            width  = 256;
            break;
        }

        m_RTexture = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);


        m_MainCamera.targetTexture = m_RTexture;

        m_TextureTarget.texture = m_RTexture;
    }
Ejemplo n.º 41
0
 static public int SetGlobalShaderProperty(IntPtr l)
 {
     try{
         UnityEngine.RenderTexture self = (UnityEngine.RenderTexture)checkSelf(l);
         System.String             a1;
         checkType(l, 2, out a1);
         self.SetGlobalShaderProperty(a1);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 42
0
    static bool Graphics_SetRenderTarget__RenderTexture__Int32__CubemapFace(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 3)
        {
            UnityEngine.RenderTexture arg0 = (UnityEngine.RenderTexture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32            arg1   = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.CubemapFace arg2   = (UnityEngine.CubemapFace)JSApi.getEnum((int)JSApi.GetType.Arg);
            UnityEngine.Graphics.SetRenderTarget(arg0, arg1, arg2);
        }

        return(true);
    }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.RenderTexture o;
     if (matchType(l, 1, typeof(int), typeof(int), typeof(int), typeof(UnityEngine.RenderTextureFormat), typeof(UnityEngine.RenderTextureReadWrite)))
     {
         System.Int32 a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         System.Int32 a3;
         checkType(l, 3, out a3);
         UnityEngine.RenderTextureFormat a4;
         checkEnum(l, 4, out a4);
         UnityEngine.RenderTextureReadWrite a5;
         checkEnum(l, 5, out a5);
         o = new UnityEngine.RenderTexture(a1, a2, a3, a4, a5);
         pushObject(l, o);
         return(1);
     }
     else if (matchType(l, 1, typeof(int), typeof(int), typeof(int), typeof(UnityEngine.RenderTextureFormat)))
     {
         System.Int32 a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         System.Int32 a3;
         checkType(l, 3, out a3);
         UnityEngine.RenderTextureFormat a4;
         checkEnum(l, 4, out a4);
         o = new UnityEngine.RenderTexture(a1, a2, a3, a4);
         pushObject(l, o);
         return(1);
     }
     else if (matchType(l, 1, typeof(int), typeof(int), typeof(int)))
     {
         System.Int32 a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         System.Int32 a3;
         checkType(l, 3, out a3);
         o = new UnityEngine.RenderTexture(a1, a2, a3);
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Ejemplo n.º 44
0
        public IEnumerator VideoStreamAddTrackAndRemoveTrack()
        {
            var width  = 256;
            var height = 256;
            var format = WebRTC.GetSupportedRenderTextureFormat(UnityEngine.SystemInfo.graphicsDeviceType);
            var rt     = new UnityEngine.RenderTexture(width, height, 0, format);

            rt.Create();
            var stream = new MediaStream();
            var track  = new VideoStreamTrack(rt);

            bool isCalledOnAddTrack    = false;
            bool isCalledOnRemoveTrack = false;

            stream.OnAddTrack = e =>
            {
                Assert.That(e.Track, Is.EqualTo(track));
                isCalledOnAddTrack = true;
            };
            stream.OnRemoveTrack = e =>
            {
                Assert.That(e.Track, Is.EqualTo(track));
                isCalledOnRemoveTrack = true;
            };

            // wait for the end of the initialization for encoder on the render thread.
            yield return(0);

            Assert.That(track.Kind, Is.EqualTo(TrackKind.Video));
            Assert.That(stream.GetVideoTracks(), Has.Count.EqualTo(0));
            Assert.That(stream.AddTrack(track), Is.True);
            Assert.That(stream.GetVideoTracks(), Has.Count.EqualTo(1));
            Assert.That(stream.GetVideoTracks(), Has.All.Not.Null);
            Assert.That(stream.RemoveTrack(track), Is.True);
            Assert.That(stream.GetVideoTracks(), Has.Count.EqualTo(0));

            var op1 = new WaitUntilWithTimeout(() => isCalledOnAddTrack, 5000);

            yield return(op1);

            var op2 = new WaitUntilWithTimeout(() => isCalledOnRemoveTrack, 5000);

            yield return(op2);

            track.Dispose();

            stream.Dispose();
            Object.DestroyImmediate(rt);
        }
Ejemplo n.º 45
0
    void Start()
    {
        // Get view component
        var view = GetComponent <NoesisView>();

        // Find the rectangle where texture will be drawn
        var rect = (Rectangle)view.Content.FindName("rtRect");

        // Create render texture
        UnityEngine.RenderTexture renderTexture = new UnityEngine.RenderTexture(
            512, 512, 1, UnityEngine.RenderTextureFormat.Default);
        UnityEngine.RenderTexture.active = renderTexture;

        // Set render texture as camera target
        this._offscreenCamera.targetTexture = renderTexture;
        this._offscreenCamera.aspect        = 1;

        // Create Noesis texture
        renderTexture.Create();
        var tex = Noesis.Texture.WrapTexture(renderTexture, renderTexture.GetNativeTexturePtr(),
                                             renderTexture.width, renderTexture.height, 1);

        // Create brush to store render texture and assign it to the rectangle
        rect.Fill = new ImageBrush()
        {
            ImageSource = new TextureSource(tex),
            Stretch     = Stretch.UniformToFill,
            Opacity     = 0.9f
        };

        // Title bar drag to move
        this._titleBar = (Border)view.Content.FindName("titleBar");
        this._titleBar.MouseLeftButtonDown += this.OnTitleBarMouseDown;
        this._titleBar.MouseLeftButtonUp   += this.OnTitleBarMouseUp;
        this._titleBar.MouseMove           += this.OnTitleBarMouseMove;

        var panel = (Panel)view.Content.FindName("panel");

        this._panelPosition = (TranslateTransform)panel.RenderTransform;

        // Model rotation
        var rotateLeft = (RepeatButton)view.Content.FindName("rotateLeft");

        rotateLeft.Click += this.OnRotateLeft;

        var rotateRight = (RepeatButton)view.Content.FindName("rotateRight");

        rotateRight.Click += this.OnRotateRight;
    }
Ejemplo n.º 46
0
 static void RenderTexture_format(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
         var result = _this.format;
         JSApi.setEnum((int)JSApi.SetType.Rval, (int)result);
     }
     else
     {
         UnityEngine.RenderTextureFormat arg0  = (UnityEngine.RenderTextureFormat)JSApi.getEnum((int)JSApi.GetType.Arg);
         UnityEngine.RenderTexture       _this = (UnityEngine.RenderTexture)vc.csObj;
         _this.format = arg0;
     }
 }
Ejemplo n.º 47
0
 static void Camera_targetTexture(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Camera _this = (UnityEngine.Camera)vc.csObj;
         var result = _this.targetTexture;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.RenderTexture arg0  = (UnityEngine.RenderTexture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.Camera        _this = (UnityEngine.Camera)vc.csObj;
         _this.targetTexture = arg0;
     }
 }
Ejemplo n.º 48
0
// fields

// properties
    static void RenderTexture_width(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
            var result = _this.width;
            JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
        }
        else
        {
            System.Int32 arg0 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
            _this.width = arg0;
        }
    }
Ejemplo n.º 49
0
    static bool ReflectionProbe_BlendCubemap__Texture__Texture__Single__RenderTexture(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 4)
        {
            UnityEngine.Texture       arg0 = (UnityEngine.Texture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Texture       arg1 = (UnityEngine.Texture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Single             arg2 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            UnityEngine.RenderTexture arg3 = (UnityEngine.RenderTexture)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(UnityEngine.ReflectionProbe.BlendCubemap(arg0, arg1, arg2, arg3)));
        }

        return(true);
    }
Ejemplo n.º 50
0
 static void RenderTexture_generateMips(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
         var result = _this.generateMips;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean            arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
         _this.generateMips = arg0;
     }
 }
Ejemplo n.º 51
0
 static void RenderTexture_enableRandomWrite(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
         var result = _this.enableRandomWrite;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean            arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.RenderTexture _this = (UnityEngine.RenderTexture)vc.csObj;
         _this.enableRandomWrite = arg0;
     }
 }
Ejemplo n.º 52
0
        public static Texture2D Resize(Texture2D source, int newWidth, int newHeight)
        {
            source.filterMode = FilterMode.Bilinear;
            UnityEngine.RenderTexture rt = UnityEngine.RenderTexture.GetTemporary(newWidth, newHeight);
            rt.filterMode = FilterMode.Bilinear;

            UnityEngine.RenderTexture.active = rt;
            Graphics.Blit(source, rt);
            var nTex = new Texture2D(newWidth, newHeight);

            nTex.ReadPixels(new Rect(0, 0, newWidth, newHeight), 0, 0);
            nTex.Apply();
            UnityEngine.RenderTexture.active = null;
            UnityEngine.RenderTexture.ReleaseTemporary(rt);
            return(nTex);
        }
Ejemplo n.º 53
0
        public Unity_Renderer(Unity_RenderManager renderManager, UnityEngine.RenderTexture renderTexture) :
            base(renderManager, Alt.Sketch.Graphics.RSN_Unity)
        {
            //NoNeed	m_RenderTexture = renderTexture;

            TransformMatrixSupported = true;

            RenderLinesByPolygons = renderManager.RenderLinesByPolygons;

            //  Now supports only 1 texture (need more shaders researches)
            MaxTextureCountPerBrushMaterial          = 1; // renderManager.MaxTextureCountPerBrushMaterial;
            MaxTextureCoordsSetCountPerBrushMaterial = 1; // renderManager.MaxTextureCoordsSetCountPerBrushMaterial;

            NonPowerOf2TexturesSupported = renderManager.NonPowerOf2TexturesSupported;

            //  We cah't use NeoAxis RenderToTexture yet, so use Software render
            RenderToTextureSupported = renderManager.RenderToTextureSupported;

            //  Can't to set Texture Matrix yet
            TextureMatrixSupported = false;// renderManager.TextureMatrixSupported;

            //  Clipping is not supported (We can't get ScissorRect or Viewport to work...)
            ClippingSupported =
#if TRY_CLIPPINGRECT
                renderManager.ClippingSupported;
#else
                false;
#endif

            SizeI maxTextureSize = renderManager.MaxTextureSize;
            //  LinearGradientTextureMaxSize
            {
                SizeI baseLinearGradientTextureMaxSize = base.LinearGradientTextureMaxSize;

                LinearGradientTextureMaxSize = new SizeI(
                    System.Math.Min(maxTextureSize.Width, baseLinearGradientTextureMaxSize.Width),
                    System.Math.Min(maxTextureSize.Height, baseLinearGradientTextureMaxSize.Height));
            }
            //  RadialGradientTextureMaxSize
            {
                SizeI baseRadialGradientTextureMaxSize = base.RadialGradientTextureMaxSize;

                RadialGradientTextureMaxSize = new SizeI(
                    System.Math.Min(maxTextureSize.Width, baseRadialGradientTextureMaxSize.Width),
                    System.Math.Min(maxTextureSize.Height, baseRadialGradientTextureMaxSize.Height));
            }
        }
Ejemplo n.º 54
0
    static int get_antiAliasing(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RenderTexture obj = (UnityEngine.RenderTexture)o;
            int ret = obj.antiAliasing;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index antiAliasing on a nil value"));
        }
    }
Ejemplo n.º 55
0
    static int get_enableRandomWrite(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RenderTexture obj = (UnityEngine.RenderTexture)o;
            bool ret = obj.enableRandomWrite;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index enableRandomWrite on a nil value"));
        }
    }
Ejemplo n.º 56
0
    static int get_depthBuffer(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RenderTexture obj = (UnityEngine.RenderTexture)o;
            UnityEngine.RenderBuffer  ret = obj.depthBuffer;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index depthBuffer on a nil value"));
        }
    }
Ejemplo n.º 57
0
    static int set_depth(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RenderTexture obj = (UnityEngine.RenderTexture)o;
            int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
            obj.depth = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index depth on a nil value"));
        }
    }
Ejemplo n.º 58
0
    static int set_isPowerOfTwo(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RenderTexture obj = (UnityEngine.RenderTexture)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.isPowerOfTwo = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isPowerOfTwo on a nil value"));
        }
    }
Ejemplo n.º 59
0
        public UnityEngine.RenderTexture InitializeReceiver(int width, int height)
        {
            if (IsDecoderInitialized)
            {
                throw new InvalidOperationException("Already initialized receiver");
            }

            m_needFlip = true;
            var format = WebRTC.GetSupportedRenderTextureFormat(UnityEngine.SystemInfo.graphicsDeviceType);

            m_sourceTexture = CreateRenderTexture(width, height, format);
            m_destTexture   = CreateRenderTexture(m_sourceTexture.width, m_sourceTexture.height, format);

            m_renderer = new UnityVideoRenderer(WebRTC.Context.CreateVideoRenderer(), this);

            return(m_destTexture);
        }
Ejemplo n.º 60
0
    void Update()
    {
        UnityEngine.Vector2 mousePos = new Vector2(-100, -100);
        if (this.camera != null)
        {
            Ray        mouseRay = this.camera.ScreenPointToRay(UnityEngine.Input.mousePosition);
            RaycastHit hit;
            if (UnityEngine.Physics.Raycast(mouseRay, out hit) && hit.collider.transform == this.transform)
            {
                UnityEngine.Vector3 localPos = hit.collider.transform.worldToLocalMatrix.MultiplyPoint(hit.point);
                mousePos = new UnityEngine.Vector2(localPos.x + 0.5f, localPos.y + 0.5f);
            }
        }

        if (!Input.GetMouseButton(0))
        {
            mousePos = new UnityEngine.Vector2(-100, -100);
        }

        if (this.renderTexture0 != null)
        {
            ++this.frameIndex;
            this.renderTextureIndex = !this.renderTextureIndex;
            UnityEngine.RenderTexture inputRenderTexture  = this.renderTextureIndex ? this.renderTexture0 : this.renderTexture1;
            UnityEngine.RenderTexture outputRenderTexture = this.renderTextureIndex ? this.renderTexture1 : this.renderTexture0;

            if (this.evolveMaterial)
            {
                this.evolveMaterial.SetVector("_MousePos", mousePos);
                UnityEngine.Graphics.Blit(inputRenderTexture, outputRenderTexture, this.evolveMaterial, 0);
            }

            if (this.resetStateEvery > 0 && (this.frameIndex % this.resetStateEvery == 0))
            {
                if (this.firstPassMaterial)
                {
                    UnityEngine.Graphics.Blit(inputRenderTexture, outputRenderTexture, this.firstPassMaterial, 0);
                }
            }

            if (this.displayMaterial)
            {
                this.displayMaterial.SetTexture(this.inputMaterialName, outputRenderTexture);
            }
        }
    }