当前位置: 首页>>代码示例>>C#>>正文


C# Camera.SetReplacementShader方法代码示例

本文整理汇总了C#中UnityEngine.Camera.SetReplacementShader方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.SetReplacementShader方法的具体用法?C# Camera.SetReplacementShader怎么用?C# Camera.SetReplacementShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Camera的用法示例。


在下文中一共展示了Camera.SetReplacementShader方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Awake

    // Use this for initialization
    void Awake()
    {
        GameObject go = new GameObject("depthCamera");
        depthCamera = go.AddComponent<Camera>();
        depthCamera.transform.position = Vector3.zero;
        depthCamera.transform.rotation = transform.rotation;
        depthCamera.transform.localPosition += transform.forward * Near;
        depthCamera.transform.parent = transform;
        depthCamera.isOrthoGraphic = true;

        depthCamera.clearFlags = CameraClearFlags.SolidColor;
        depthCamera.backgroundColor = Color.white;
        depthTexture = new RenderTexture(TextureSize,TextureSize, 16, RenderTextureFormat.ARGB32);
        depthTexture.filterMode = FilterMode.Point;
        depthCamera.targetTexture = depthTexture;
        depthCamera.SetReplacementShader(shader, null);
        depthCamera.enabled = false;
        biasMatrix = Matrix4x4.identity;
        biasMatrix[ 0, 0 ] = 0.5f;
        biasMatrix[ 1, 1 ] = 0.5f;
        biasMatrix[ 2, 2 ] = 0.5f;
        biasMatrix[ 0, 3 ] = 0.5f;
        biasMatrix[ 1, 3 ] = 0.5f;
        biasMatrix[ 2, 3 ] = 0.5f;
    }
开发者ID:kokichi88,项目名称:shadowmapping,代码行数:26,代码来源:GenerateDepthTexture2.cs

示例2: SetupRadarCamera

		public static void SetupRadarCamera()
		{
			if(radarRT && radarTex2D && radarCam && radarShader)
			{
				return;
			}

			//setup shader first
			if(!radarShader)
			{
				radarShader = BDAShaderLoader.UnlitBlackShader;//.LoadManifestShader("BahaTurret.UnlitBlack.shader");
			}

			//then setup textures
			radarRT = new RenderTexture(radarResolution,radarResolution,16);
			radarTex2D = new Texture2D(radarResolution,radarResolution, TextureFormat.ARGB32, false);

			//set up camera
			radarCam = (new GameObject("RadarCamera")).AddComponent<Camera>();
			radarCam.enabled = false;
			radarCam.clearFlags = CameraClearFlags.SolidColor;
			radarCam.backgroundColor = Color.white;
			radarCam.SetReplacementShader(radarShader, string.Empty);
			radarCam.cullingMask = 1<<0;
			radarCam.targetTexture = radarRT;
			//radarCam.nearClipPlane = 75;
			//radarCam.farClipPlane = 40000;
		}
开发者ID:tetryds,项目名称:BDArmory,代码行数:28,代码来源:RadarUtils.cs

示例3: Start

 void Start()
 {
     cam = GetComponent<Camera> ();
     cam.SetReplacementShader (Shader.Find("Sprites/Default"), null);
     boarder = GameObject.Find("Minimap-Image");
     Input.ResetInputAxes ();
 }
开发者ID:MarbleGameDev,项目名称:2DPlatformer,代码行数:7,代码来源:MinimapShader.cs

示例4: Awake

    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);
        }
    }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:59,代码来源:normal_camera.cs

示例5: GetOrCreateNormalCamera

    // Fetches an existing camera in the hierarchy, or creates a new one.
    private void GetOrCreateNormalCamera()
    {
        // if we've already got a distortion camera, then just return immediately.
        if (_normalCamera) return;

        // otherwise, search the hierarchy for an existing one. If it's there, we're
        // all set. Asign our camera reference, and return.
        Transform foundTranform = this.transform.Find( "ImageEffect_Gotow_HeatDistortion_Camera" );
        if (foundTranform) {
            _normalCamera = foundTranform.GetComponent<Camera>();
            return;
        }

        // if we're still here, then we've got to create a camera ourselves, and add it
        // to the scene. First, construct a GameObject with our known name.
        GameObject obj = new GameObject( "ImageEffect_Gotow_HeatDistortion_Camera" );
        // set it to be uneditable, and invisible in the scene hierarchy.
        // it can be recreated later if we need it, and it will confuse the user to have
        // another camera floating around.
        obj.hideFlags = HideFlags.NotEditable | HideFlags.HideAndDontSave;
        // Set its transform to this script's transform, so that it will always follow
        // the camera we're putting the image effect on.
        obj.transform.parent = this.transform;
        obj.transform.position = this.transform.position;
        obj.transform.rotation = this.transform.rotation;

        // Now, attach a camera component.
        _normalCamera = obj.AddComponent<Camera>();
        // set its projection matrix to match that of our main camera. This way, we
        // can always be sure that the cameras line up properly.
        _normalCamera.depth = _camera.depth;
        _normalCamera.renderingPath = _camera.renderingPath;
        _normalCamera.projectionMatrix = _camera.projectionMatrix;
        _normalCamera.fieldOfView = _camera.fieldOfView;
        _normalCamera.orthographic = _camera.orthographic;
        _normalCamera.orthographicSize = _camera.orthographicSize;

        // Set the camera to clear to a normal-neutral background.
        _normalCamera.clearFlags = CameraClearFlags.SolidColor;
        _normalCamera.backgroundColor = new Color( 0.5f, 0.5f, 1.0f );

        // Lastly, set up the replacement shader. We want only our defining particle
        // effects to render into the distortion normal buffer, everything else in the
        // scene will use a depth-only shader, so that the particles can be occluded.
        _normalCamera.SetReplacementShader( Shader.Find( "Hidden/ImageEffects/Gotow/DistortionMap" ), "RenderType" );
    }
开发者ID:andrewgotow,项目名称:Heatwave,代码行数:47,代码来源:ImageEffect_Gotow_Heatwave.cs

示例6: Awake

	void Awake() {
		if(!ms_shadowTextureFakePoint) {
			ms_shadowTextureFakePoint = new Texture2D(1, 1, TextureFormat.Alpha8, false, true);
			ms_shadowTextureFakePoint.filterMode = FilterMode.Point;
			ms_shadowTextureFakePoint.SetPixel(0, 0, new Color(0f, 0f, 0f, 0f));
			ms_shadowTextureFakePoint.Apply(false, true);

			ms_shadowMatrixID = Shader.PropertyToID("u_UniqueShadowMatrix");
			ms_shadowTextureID = Shader.PropertyToID("u_UniqueShadowTexture");
		}

		EnsureLightSource();

		m_shadowMatrix = Matrix4x4.identity;
		var shadowCameraGO = new GameObject("#> _Shadow Camera < " + this.name);
		shadowCameraGO.hideFlags = HideFlags.DontSave | HideFlags.NotEditable | HideFlags.HideInHierarchy;
		m_shadowCamera = shadowCameraGO.AddComponent<Camera>();
		m_shadowCamera.renderingPath = RenderingPath.Forward;
		m_shadowCamera.clearFlags = CameraClearFlags.Depth;
		m_shadowCamera.depthTextureMode = DepthTextureMode.None;
		m_shadowCamera.useOcclusionCulling = false;
		m_shadowCamera.cullingMask = useSceneCapture ? (LayerMask)~0 : inclusionMask;
		m_shadowCamera.orthographic = true;
		m_shadowCamera.depth = -100;
		m_shadowCamera.aspect = 1f;
		m_shadowCamera.SetReplacementShader(uniqueShadowDepthShader, "RenderType");
		m_shadowCamera.enabled = false;
		
		SetFocus(startFocus);

		m_materialInstances = new List<Material>();
		var materialMap = new Dictionary<Material, Material>();
		foreach(var r in GetComponentsInChildren<Renderer>()) {
			if(!r.receiveShadows)
				continue;

			bool hadMaterials = false;
			var sharedMaterials = r.sharedMaterials;
			for(int i  = 0, n = sharedMaterials.Length; i < n; ++i) {
				var m = sharedMaterials[i];

				Material mi = null;
				if(!materialMap.TryGetValue(m, out mi)) {
					materialMap[m] = mi = new Material(m);
					mi.name = m.name + " (uniq)";
					mi.shaderKeywords = m.shaderKeywords;
					mi.renderQueue = m.renderQueue;
					SetStaticShaderUniforms(mi);
					m_materialInstances.Add(mi);
				}
				sharedMaterials[i] = mi;
				hadMaterials = true;
			}

			if(hadMaterials)
				r.sharedMaterials = sharedMaterials;
		}

		if(m_materialInstances.Count > 0) {
			var mesh = new Mesh();
			mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f);
			mesh.hideFlags = HideFlags.HideAndDontSave;
			var mf = gameObject.AddComponent<MeshFilter>();
			mf.sharedMesh = mesh;
			var mr = gameObject.AddComponent<MeshRenderer>();
			mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
			mr.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
			mr.useLightProbes = false;
		}
	}
开发者ID:jamahalwin,项目名称:silhouette-z,代码行数:70,代码来源:UniqueShadow.cs

示例7: Awake

    void Awake()
    {
        _vertex_color_mask_shader = (Shader)Resources.Load("shader/hdr_vertex_color_mask");

        if (_mask_camera_camera == null){
            //create clipping mask for masks;
            _mask =
                    1 << 0 |
                    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(0.5f,0.5f,0.5f);
            _mask_camera_camera_component.cullingMask = _mask;

            //set replacementshader
            _mask_camera_camera_component.SetReplacementShader(_vertex_color_mask_shader,"");

            //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);
        }
    }
开发者ID:FabianSchempp,项目名称:DUNDON,代码行数:62,代码来源:_mask_camera_vertex.cs

示例8: Start

 /// <summary>
 /// Inicializacion
 /// </summary>
 private void Start()
 {
     CurrentCamera = GetComponent<Camera>();
     CurrentCamera.SetReplacementShader(RenderShader, null);
 }
开发者ID:jennydvr,项目名称:SimpleRunner,代码行数:8,代码来源:VanishingPoint.cs


注:本文中的UnityEngine.Camera.SetReplacementShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。