# SetGlobalTexture

> Sets a global texture property for all shaders.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## SetGlobalTexture(string, Texture)

Sets a global texture property for all shaders.

```csharp
public static void SetGlobalTexture(string name, Texture value)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property.**** (\[Texture]\(/engine/6000.0/script-reference/unityengine/texture)): The texture to set.

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" texture (for example, custom diffuse-lighting cubemap). Then you can set the global property from script and don't have to setup the same texture in all materials.

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: [RenderTextureSubElement.Color](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/color.md), [RenderTextureSubElement.Depth](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/depth.md), and [RenderTextureSubElement.Stencil](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/stencil.md).

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalFloat](/engine/6000.0/script-reference/unityengine/shader/setglobalfloat.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [RenderTextureSubElement](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement.md).

## SetGlobalTexture(int, Texture)

Sets a global texture property for all shaders.

```csharp
public static void SetGlobalTexture(int nameID, Texture value)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The name ID of the property retrieved by [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).**** (\[Texture]\(/engine/6000.0/script-reference/unityengine/texture)): The texture to set.

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" texture (for example, custom diffuse-lighting cubemap). Then you can set the global property from script and don't have to setup the same texture in all materials.

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: [RenderTextureSubElement.Color](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/color.md), [RenderTextureSubElement.Depth](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/depth.md), and [RenderTextureSubElement.Stencil](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/stencil.md).

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalFloat](/engine/6000.0/script-reference/unityengine/shader/setglobalfloat.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [RenderTextureSubElement](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement.md).

## SetGlobalTexture(string, RenderTexture, RenderTextureSubElement)

Sets a global texture property for all shaders.

```csharp
public static void SetGlobalTexture(string name, RenderTexture value, RenderTextureSubElement element)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property.**** (\[RenderTexture]\(/engine/6000.0/script-reference/unityengine/rendertexture)): The texture to set.**** (\[RenderTextureSubElement]\(/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement)): Optional parameter that specifies the type of data to set from the RenderTexture.

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" texture (for example, custom diffuse-lighting cubemap). Then you can set the global property from script and don't have to setup the same texture in all materials.

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: [RenderTextureSubElement.Color](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/color.md), [RenderTextureSubElement.Depth](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/depth.md), and [RenderTextureSubElement.Stencil](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/stencil.md).

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalFloat](/engine/6000.0/script-reference/unityengine/shader/setglobalfloat.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [RenderTextureSubElement](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement.md).

## SetGlobalTexture(int, RenderTexture, RenderTextureSubElement)

Sets a global texture property for all shaders.

```csharp
public static void SetGlobalTexture(int nameID, RenderTexture value, RenderTextureSubElement element)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The name ID of the property retrieved by [Shader.PropertyToID](/engine/6000.0/script-reference/unityengine/shader/propertytoid.md).**** (\[RenderTexture]\(/engine/6000.0/script-reference/unityengine/rendertexture)): The texture to set.**** (\[RenderTextureSubElement]\(/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement)): Optional parameter that specifies the type of data to set from the RenderTexture.

### Remarks

Global properties are used if a shader needs them but the material does not have them defined (for example, if the shader does not expose them in Properties block).

Usually this is used if you have a set of custom shaders that all use the same "global" texture (for example, custom diffuse-lighting cubemap). Then you can set the global property from script and don't have to setup the same texture in all materials.

By specifying a `RenderTextureSubElement`, you can indicate which type of data to set from the RenderTexture. The possible options are: [RenderTextureSubElement.Color](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/color.md), [RenderTextureSubElement.Depth](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/depth.md), and [RenderTextureSubElement.Stencil](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement/stencil.md).

Additional Resources: [Shader.SetGlobalColor](/engine/6000.0/script-reference/unityengine/shader/setglobalcolor.md), [Shader.SetGlobalFloat](/engine/6000.0/script-reference/unityengine/shader/setglobalfloat.md); [Material](/engine/6000.0/script-reference/unityengine/material.md) class, [ShaderLab documentation](/engine/6000.0/manual/materials-and-shaders/shaders.md), [RenderTextureSubElement](/engine/6000.0/script-reference/unityengine/rendering/rendertexturesubelement.md).
