當前位置: 首頁>>代碼示例>>C#>>正文


C# RenderTexture.SetGlobalShaderProperty方法代碼示例

本文整理匯總了C#中UnityEngine.RenderTexture.SetGlobalShaderProperty方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderTexture.SetGlobalShaderProperty方法的具體用法?C# RenderTexture.SetGlobalShaderProperty怎麽用?C# RenderTexture.SetGlobalShaderProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.RenderTexture的用法示例。


在下文中一共展示了RenderTexture.SetGlobalShaderProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Blit

 /// Copies one render texture onto another.
 public static void Blit(RenderTexture source, Rect sourceRect, RenderTexture dest, Rect destRect, BlendMode blendMode)
 {
     // Make the destination texture the target for all rendering
     RenderTexture.active = dest;
     // Assign the source texture to a property from a shader
     source.SetGlobalShaderProperty ("__RenderTex");
     // Set up the simple Matrix
     GL.PushMatrix ();
     GL.LoadOrtho ();
     Material blitMaterial = GetBlitMaterial(blendMode);
     for (int i = 0; i < blitMaterial.passCount; i++) {
         blitMaterial.SetPass (i);
         DrawQuad();
     }
     GL.PopMatrix ();
 }
開發者ID:ChrAfonso,項目名稱:imagination,代碼行數:17,代碼來源:ImageEffects.cs

示例2: FourTapCone

    // Performs one blur iteration.
    public void FourTapCone(RenderTexture source, RenderTexture dest, int iteration)
    {
        RenderTexture.active = dest;
        source.SetGlobalShaderProperty ("__RenderTex");

        float offsetX = (.5F+iteration*blurSpread) / (float)source.width;
        float offsetY = (.5F+iteration*blurSpread) / (float)source.height;
        GL.PushMatrix ();
        GL.LoadOrtho ();

        for (int i = 0; i < material.passCount; i++) {
            material.SetPass (i);
            Render4TapQuad( dest, offsetX, offsetY );
        }
        GL.PopMatrix ();
    }
開發者ID:fluffyfreak,項目名稱:Unity-Community-Ocean,代碼行數:17,代碼來源:BlurEffect.cs

示例3: OnRenderImage

	public void OnRenderImage(RenderTexture src, RenderTexture dst){
		Graphics.Blit(src, myRT);
		RenderTexture.active = dst;
		//sets the global shader property of the material to be src
		src.SetGlobalShaderProperty ("_RenderTexy");
		GL.PushMatrix ();
		GL.LoadOrtho ();
		// activate the first pass (in this case we know it is the only pass)
		mat.SetPass (0);
		// draw a quad that covers the viewport
		GL.Begin (GL.QUADS);
		GL.TexCoord2 (0, 0); GL.Vertex3 (0, 0, 0.1f);
		GL.TexCoord2 (1, 0); GL.Vertex3 (1, 0, 0.1f);
		GL.TexCoord2 (1, 1); GL.Vertex3 (1, 1, 0.1f);
		GL.TexCoord2 (0, 1); GL.Vertex3 (0, 1, 0.1f);
		GL.End ();
		GL.PopMatrix ();
	}
開發者ID:ly774508966,項目名稱:Light-Harvest-Unity3D,代碼行數:18,代碼來源:SyphonServerBridge.cs

示例4: Blit

	/// <summary>
	/// Blit - Copies one render texture onto another through a material
	/// flip will flip the render horizontally
	/// </summary>
	/// <param name="source">Source.</param>
	/// <param name="dest">Destination.</param>
	/// <param name="m">M.</param>
	/// <param name="flip">If set to <c>true</c> flip.</param>
	public void Blit (RenderTexture source, RenderTexture dest, Material m, bool flip) 
	{
		Material material = m;
		
		// Make the destination texture the target for all rendering
		RenderTexture.active = dest;  		
		
		// Assign the source texture to a property from a shader
		source.SetGlobalShaderProperty ("_MainTex");	
		
		// Set up the simple Matrix
		GL.PushMatrix ();
		GL.LoadOrtho ();
		for(int i = 0; i < material.passCount; i++)
		{
			material.SetPass(i);
			DrawQuad(flip);
		}
		GL.PopMatrix ();
	}
開發者ID:iveos,項目名稱:SIG-ET-2015-OR,代碼行數:28,代碼來源:OVRUtils.cs

示例5: SetupTexture

 private void SetupTexture()
 {
     if (myRenderTexture!=null) {
         myRenderTexture.Release();
     }
     myRenderTexture=new RenderTexture(Screen.width, Screen.height, 16);
     if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth)) {
         myRenderTexture.format=RenderTextureFormat.Depth;
     }
     myRenderTexture.Create();
     myRenderTexture.filterMode=FilterMode.Point;
     RenderTexture.active=myRenderTexture;
     myRenderTexture.SetGlobalShaderProperty("_GrassDepthTex");
 }
開發者ID:gordonklarson,項目名稱:Perfect-Soccer,代碼行數:14,代碼來源:SetupForGrassRendering.cs

示例6: CreateAssets

    //---------------------------------------------------------------------------------------------------------------------------------------------------
    void CreateAssets()
    {
        // Create camera
        if ( !m_shadowCamera )
        {
            m_shadowCamera = CreateRenderCamera( "Valve Shadow Camera" );
            m_cullLightsInSceneEditor = false;
            m_cullLightsFromEditorCamera = false;
            m_hideAllValveMaterials = false;
        }

        // Shadow depth texture
        if ( !m_shadowDepthTexture || ( m_shadowDepthTexture.width != m_valveShadowTextureWidth ) || ( m_shadowDepthTexture.height != m_valveShadowTextureHeight ) )
        {
            if ( m_shadowDepthTexture )
            {
                DestroyImmediate( m_shadowDepthTexture );
                m_shadowDepthTexture = null;
            }

            m_shadowDepthTexture = new RenderTexture( m_valveShadowTextureWidth, m_valveShadowTextureHeight, 24, RenderTextureFormat.Shadowmap, RenderTextureReadWrite.Linear );
            if ( m_shadowDepthTexture )
            {
                m_shadowDepthTexture.name = "m_shadowDepthTexture";
                m_shadowDepthTexture.hideFlags = HideFlags.HideAndDontSave;
                m_shadowDepthTexture.useMipMap = false;
                m_shadowDepthTexture.filterMode = FilterMode.Bilinear;
                m_shadowDepthTexture.wrapMode = TextureWrapMode.Clamp;
                m_shadowDepthTexture.antiAliasing = 1;
                m_shadowDepthTexture.Create();
                m_shadowDepthTexture.SetGlobalShaderProperty( "g_tShadowBuffer" );
                //Shader.SetGlobalTexture( "g_tShadowBuffer", m_shadowDepthTexture );
                #if ( UNITY_EDITOR )
                {
                    EditorUtility.SetDirty( this );
                }
                #endif
            }
            else
            {
                Debug.LogWarning( "ERROR! Cannot create shadow depth texture!\n" );
            }
        }

        // Cast shadows shader
        if ( !m_shaderCastShadows )
        {
            m_shaderCastShadows = Resources.Load( "vr_cast_shadows" ) as Shader;
            if ( !m_shaderCastShadows )
            {
                Debug.LogWarning( "ERROR! Can't find Resources/vr_cast_shadows!\n" );
            }
            else if ( !m_shaderCastShadows.isSupported )
            {
                Debug.LogWarning( "ERROR! Resources/vr_cast_shadows not supported!\n" );
            }
        }

        // Shadows vis shader and material
        #if ( UNITY_EDITOR )
        {
            if ( !m_shaderShadowVis )
            {
                m_shaderShadowVis = Resources.Load( "vr_shadow_vis" ) as Shader;
                if ( !m_shaderShadowVis )
                {
                    Debug.LogWarning( "ERROR! Can't find Resources/vr_shadow_vis!\n" );
                }
                else if ( !m_shaderShadowVis.isSupported )
                {
                    Debug.LogWarning( "ERROR! Resources/vr_shadow_vis not supported!\n" );
                }
                else
                {
                    m_materialShadowVis = new Material( m_shaderShadowVis );
                    m_materialShadowVis.hideFlags = HideFlags.HideAndDontSave;
                }
            }
        }
        #endif
    }
開發者ID:RandomTiger,項目名稱:OgresLairVR,代碼行數:82,代碼來源:ValveCamera.cs

示例7: DownSample4x

    // Downsamples the texture to a quarter resolution.
    private void DownSample4x(RenderTexture source, RenderTexture dest)
    {
        RenderTexture.active = dest;
        source.SetGlobalShaderProperty ("__RenderTex");

        float offsetX = 1.0f / (float)source.width;
        float offsetY = 1.0f / (float)source.height;

        GL.PushMatrix ();
        GL.LoadOrtho ();
        for (int i = 0; i < material.passCount; i++)
        {
            material.SetPass (i);
            Render4TapQuad( dest, offsetX, offsetY );
        }
        GL.PopMatrix ();
    }
開發者ID:fluffyfreak,項目名稱:Unity-Community-Ocean,代碼行數:18,代碼來源:BlurEffect.cs

示例8: FourTapCone

    // Performs one blur iteration.
    private void FourTapCone( RenderTexture source, RenderTexture dest, int iteration )
    {
        RenderTexture.active = dest;
        source.SetGlobalShaderProperty( "__RenderTex" );

        float offsetX = ( 0.5f + iteration*blurSpread )/source.width;
        float offsetY = ( 0.5f + iteration*blurSpread )/source.height;
        GL.PushMatrix();
        GL.LoadOrtho();

        Material mat = GetMaterial();
        for( int i = 0; i < mat.passCount; ++i )
        {
            mat.SetPass( i );
            Render4TapQuad( dest, offsetX, offsetY );
        }
        GL.PopMatrix();
    }
開發者ID:Jonas90,項目名稱:iss,代碼行數:19,代碼來源:FunkyGlowingThingsEffect.cs

示例9: DownSample4x

    // Downsamples the texture to a quarter resolution.
    private void DownSample4x(RenderTexture source, RenderTexture dest)
    {
        RenderTexture.active = dest;
        source.SetGlobalShaderProperty ("__RenderTex");

        downsampleMaterial.color = new Color( glowTint.r, glowTint.g, glowTint.b, glowTint.a/4.0f );

        GL.PushMatrix ();
        GL.LoadOrtho ();
        for (int i = 0; i < downsampleMaterial.passCount; i++)
        {
            downsampleMaterial.SetPass (i);
            ImageEffects.DrawGrid( 1, 1 );
        }
        GL.PopMatrix ();
    }
開發者ID:juanluislm,項目名稱:MindShoot,代碼行數:17,代碼來源:GlowEffect.cs

示例10: BlitGlow

    public void BlitGlow( RenderTexture source, RenderTexture dest )
    {
        RenderTexture.active = dest;
        source.SetGlobalShaderProperty ("__RenderTex");

        compositeMaterial.color = new Color(1F, 1F, 1F, Mathf.Clamp01(glowIntensity));

        GL.PushMatrix ();
        GL.LoadOrtho ();
        for (int i = 0; i < compositeMaterial.passCount; i++) {
            compositeMaterial.SetPass (i);
            ImageEffects.DrawGrid(1,1);
        }
        GL.PopMatrix ();
    }
開發者ID:juanluislm,項目名稱:MindShoot,代碼行數:15,代碼來源:GlowEffect.cs


注:本文中的UnityEngine.RenderTexture.SetGlobalShaderProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。