mirror of
https://github.com/maxartz15/InteractiveMask.git
synced 2024-11-23 14:05:35 +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.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace TAO.InteractiveMask
|
namespace TAO.InteractiveMask
|
||||||
@ -22,7 +23,11 @@ namespace TAO.InteractiveMask
|
|||||||
}
|
}
|
||||||
private RenderTexture source = null;
|
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;
|
public bool debugGui = false;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
@ -53,10 +58,8 @@ namespace TAO.InteractiveMask
|
|||||||
maskRenderer.source = source;
|
maskRenderer.source = source;
|
||||||
maskRenderer.Init();
|
maskRenderer.Init();
|
||||||
|
|
||||||
foreach (var m in materials)
|
// Set texture.
|
||||||
{
|
Shader.SetGlobalTexture(maskTextureGlobalParameterName, Target);
|
||||||
m.SetTexture("_Mask", Target);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
@ -101,10 +104,8 @@ namespace TAO.InteractiveMask
|
|||||||
|
|
||||||
maskRenderer.Render();
|
maskRenderer.Render();
|
||||||
|
|
||||||
foreach (var m in materials)
|
// Set data.
|
||||||
{
|
Shader.SetGlobalVector(maskDataGlobalParameterName, new Vector4(maskCamera.transform.position.x, maskCamera.transform.position.z, maskCamera.orthographicSize, 0));
|
||||||
m.SetVector("_MaskData", new Vector4(maskCamera.transform.position.x, maskCamera.transform.position.z, maskCamera.orthographicSize, 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SnapCameraPosition()
|
private void SnapCameraPosition()
|
||||||
|
Loading…
Reference in New Issue
Block a user