Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close Your name Your email Suggestion* Switch to Manual Declarationpublic void
SetMatrix(string
name,
Matrix4x4 value);
Declarationpublic void
SetMatrix(int
nameID,
Matrix4x4 value);
Parameters Parameter Description nameID Property name ID, use Shader.PropertyToID to get it. name Property name, e.g. "_CubemapRotation". value Matrix value to set. DescriptionSets a named matrix for the shader.
This is mostly used with custom shaders that need extra matrix parameters. Matrix parameters are not exposed in the material inspector, but can be set and queried with SetMatrix
and GetMatrix
from scripts.
Additional resources: GetMatrix, Materials, ShaderLab documentation, Shader.PropertyToID, Properties in Shader Programs.
// Use this shader on an object together with the above example script. // The shader transforms texture coordinates with a matrix set from a script. Shader "RotatingTexture" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment fragstruct v2f { float2 uv : TEXCOORD0; float4 pos : SV_POSITION; };
float4x4 _TextureRotation;
v2f vert (float4 pos : POSITION, float2 uv : TEXCOORD0) { v2f o; o.pos = UnityObjectToClipPos(pos); o.uv = mul(_TextureRotation, float4(uv,0,1)).xy; return o; }
sampler2D _MainTex; fixed4 frag (v2f i) : SV_Target { return tex2D(_MainTex, i.uv); } ENDCG } } }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4