mirror of
https://github.com/maxartz15/InteractiveMask.git
synced 2024-11-23 05:55:32 +01:00
Global shader parameters.
Switched to using global shader parameter names instead of directly assigning the data to the materials.
This commit is contained in:
parent
c782f5ac4f
commit
88b0bd925b
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TAO.InteractiveMask
|
||||
@ -22,7 +23,11 @@ namespace TAO.InteractiveMask
|
||||
}
|
||||
private RenderTexture source = null;
|
||||
|
||||
public List<Material> materials = new List<Material>();
|
||||
[SerializeField]
|
||||
private string maskTextureGlobalParameterName = "_TAO_Mask";
|
||||
[SerializeField]
|
||||
private string maskDataGlobalParameterName = "_TAO_MaskData";
|
||||
|
||||
public bool debugGui = false;
|
||||
|
||||
private void Awake()
|
||||
@ -53,10 +58,8 @@ namespace TAO.InteractiveMask
|
||||
maskRenderer.source = source;
|
||||
maskRenderer.Init();
|
||||
|
||||
foreach (var m in materials)
|
||||
{
|
||||
m.SetTexture("_Mask", Target);
|
||||
}
|
||||
// Set texture.
|
||||
Shader.SetGlobalTexture(maskTextureGlobalParameterName, Target);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
@ -101,10 +104,8 @@ namespace TAO.InteractiveMask
|
||||
|
||||
maskRenderer.Render();
|
||||
|
||||
foreach (var m in materials)
|
||||
{
|
||||
m.SetVector("_MaskData", new Vector4(maskCamera.transform.position.x, maskCamera.transform.position.z, maskCamera.orthographicSize, 0));
|
||||
}
|
||||
// Set data.
|
||||
Shader.SetGlobalVector(maskDataGlobalParameterName, new Vector4(maskCamera.transform.position.x, maskCamera.transform.position.z, maskCamera.orthographicSize, 0));
|
||||
}
|
||||
|
||||
private void SnapCameraPosition()
|
||||
|
Loading…
Reference in New Issue
Block a user