SetMatrix() public method

Set a matrix property.

public SetMatrix ( int nameID, Matrix4x4 value ) : void
nameID int The name ID of the property retrieved by Shader.PropertyToID.
value Matrix4x4 The matrix value to set.
return void
Ejemplo n.º 1
0
 static public int SetMatrix(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Matrix4x4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l, 3, out a2);
             self.SetMatrix(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Matrix4x4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l, 3, out a2);
             self.SetMatrix(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function SetMatrix to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 2
0
    static int SetMatrix(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes <int, UnityEngine.Matrix4x4>(L, 2))
            {
                UnityEngine.MaterialPropertyBlock obj = (UnityEngine.MaterialPropertyBlock)ToLua.CheckObject(L, 1, typeof(UnityEngine.MaterialPropertyBlock));
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                UnityEngine.Matrix4x4 arg1 = StackTraits <UnityEngine.Matrix4x4> .To(L, 3);

                obj.SetMatrix(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, UnityEngine.Matrix4x4>(L, 2))
            {
                UnityEngine.MaterialPropertyBlock obj = (UnityEngine.MaterialPropertyBlock)ToLua.CheckObject(L, 1, typeof(UnityEngine.MaterialPropertyBlock));
                string arg0 = ToLua.ToString(L, 2);
                UnityEngine.Matrix4x4 arg1 = StackTraits <UnityEngine.Matrix4x4> .To(L, 3);

                obj.SetMatrix(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.MaterialPropertyBlock.SetMatrix"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 3
0
 void Start()
 {
     property_block = new MaterialPropertyBlock();
     property_block.SetMatrix("prev_Object2World", Matrix4x4.identity);
     mesh_renderer = GetComponent<MeshRenderer>();
     mesh_renderer.SetPropertyBlock(property_block);
 }
Ejemplo n.º 4
0
 static public int SetMatrix(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Matrix4x4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l, 3, out a2);
             self.SetMatrix(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Matrix4x4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4 a2;
             checkValueType(l, 3, out a2);
             self.SetMatrix(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function SetMatrix to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int SetMatrix__Int32__Matrix4x4(IntPtr l)
 {
     try {
         UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
         System.Int32 a1;
         checkType(l, 2, out a1);
         UnityEngine.Matrix4x4 a2;
         checkValueType(l, 3, out a2);
         self.SetMatrix(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    void SetMaterial()
    {
        if (!sprite)
        {
            Debug.LogError("No sprite set for UI fill", gameObject);
            return;
        }

        MaterialPropertyBlock block = new MaterialPropertyBlock();
        sprite.GetPropertyBlock(block);

        Vector3 scale = new Vector3(clockwise ? -1:1, 1, 1);
        Quaternion rot = Quaternion.Euler(0, 0, rotation + 90f);
        block.SetMatrix("_Rotation", Matrix4x4.TRS(Vector3.zero, rot, scale));
        block.SetFloat("_Fill", fillAmount);
        sprite.SetPropertyBlock(block);
    }
Ejemplo n.º 7
0
 private void InitShaderProperties()
 {
     if (this.isCut)
     {
         MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
         this.renderer.GetPropertyBlock(materialPropertyBlock);
         materialPropertyBlock.SetFloat("_Variation", Mathf.Abs(Mathf.Abs(base.transform.position.x + base.transform.position.z) * 0.1f % 1f - 0.5f) * 2f);
         Quaternion q = Quaternion.AngleAxis(-base.transform.rotation.eulerAngles.y, Vector3.up);
         this.m_Matrix.SetTRS(Vector3.zero, q, new Vector3(1f, 1f, 1f));
         materialPropertyBlock.SetMatrix("_TreeRotMatrix", this.m_Matrix);
         this.renderer.SetPropertyBlock(materialPropertyBlock);
         this.mat.EnableKeyword("_CUTVERSION");
     }
     else
     {
         this.mat.DisableKeyword("_CUTVERSION");
     }
 }
Ejemplo n.º 8
0
        public void SetPropertyBlock(MaterialPropertyBlock block,
                                     Transform modelTransform)
        {
            // model local space to world space matrix
            var l2w = modelTransform.localToWorldMatrix;

            // world space to effector local space matrix
            var w2e = transform.worldToLocalMatrix;

            // effector local space to normalized effector space matrix
            var es = _effectorSize;
            var invs = new Vector3(1.0f / es.x, 1.0f / es.y, 1.0f / es.z);
            var e2n = Matrix4x4.Scale(invs);

            block.SetMatrix("_Effector", e2n * w2e * l2w);

            block.SetVector("_Steepness", new Vector3(
                _transitionSteepness,
                _emissionTransitionSteepness,
                _scaleTransitionSteepness
            ));

            block.SetColor("_InitialEmission", _initialEmission);
            block.SetFloat("_InitialScale", _initialScale);

            if (_effectType == EffectType.Destruction)
                SetDestructionProps(block, modelTransform);
            else
                SetDisintegrationProps(block);
        }
Ejemplo n.º 9
0
 public bool AddToMaterialPropertyBlock(UnityEngine.MaterialPropertyBlock materialPropertyBlock)
 {
     materialPropertyBlock.SetMatrix(this.PropertyName, this.PropertyValue);
     return(false);
 }
Ejemplo n.º 10
0
		private void ApplyToBlock(ref MaterialPropertyBlock block, ShaderIDs bids) {
		#if USE_PROPERTY_BLOCKS
			#if UNITY_5 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2

				block.SetVector(bids.exposureIBL,	exposures);
				block.SetVector(bids.exposureLM,	exposuresLM);
				block.SetMatrix(bids.skyMatrix,		skyMatrix);
				block.SetMatrix(bids.invSkyMatrix,	invMatrix);

				block.SetVector(bids.skyMin, skyMin);
				block.SetVector(bids.skyMax, skyMax);			

				if(specularCube) block.SetTexture(bids.specCubeIBL, specularCube);
				else 			 block.SetTexture(bids.specCubeIBL, blackCube);

				block.SetVector(bids.SH[0],	SH.cBuffer[0]);
				block.SetVector(bids.SH[1],	SH.cBuffer[1]);
				block.SetVector(bids.SH[2],	SH.cBuffer[2]);
				block.SetVector(bids.SH[3],	SH.cBuffer[3]);
				block.SetVector(bids.SH[4],	SH.cBuffer[4]);
				block.SetVector(bids.SH[5],	SH.cBuffer[5]);
				block.SetVector(bids.SH[6],	SH.cBuffer[6]);
				block.SetVector(bids.SH[7],	SH.cBuffer[7]);
				block.SetVector(bids.SH[8], SH.cBuffer[8]);

			#else 

				block.AddVector(bids.exposureIBL,	exposures);
				block.AddVector(bids.exposureLM,	exposuresLM);

				block.AddMatrix(bids.skyMatrix,		skyMatrix);
				block.AddMatrix(bids.invSkyMatrix,	invMatrix);

				block.AddVector(bids.skyMin, skyMin);
				block.AddVector(bids.skyMax, skyMax);			

				if(specularCube) block.AddTexture(bids.specCubeIBL, specularCube);
				else 			 block.AddTexture(bids.specCubeIBL, blackCube);

				block.AddVector(bids.SH[0],	SH.cBuffer[0]);
				block.AddVector(bids.SH[1],	SH.cBuffer[1]);
				block.AddVector(bids.SH[2],	SH.cBuffer[2]);
				block.AddVector(bids.SH[3],	SH.cBuffer[3]);
				block.AddVector(bids.SH[4],	SH.cBuffer[4]);
				block.AddVector(bids.SH[5],	SH.cBuffer[5]);
				block.AddVector(bids.SH[6],	SH.cBuffer[6]);
				block.AddVector(bids.SH[7],	SH.cBuffer[7]);
				block.AddVector(bids.SH[8], SH.cBuffer[8]);

			#endif
		#endif
		}