本文整理汇总了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 ();
}
示例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 ();
}
示例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 ();
}
示例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 ();
}
示例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");
}
示例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
}
示例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 ();
}
示例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();
}
示例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 ();
}
示例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 ();
}