本文整理汇总了C#中UnityEngine.Material.SetInt方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetInt方法的具体用法?C# Material.SetInt怎么用?C# Material.SetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.SetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
IEnumerator Start()
{
foreach (var r in GetComponentsInChildren<Renderer>()) {
renderers.Add(r);
originalMaterials[r] = r.sharedMaterial;
var material = new Material(r.material);
material.SetFloat("_Mode", 2);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
r.material = material;
}
for (float t = 0; t < 1f; t += Time.deltaTime) {
if (!UpdateRenderers(t)) {
yield break;
}
yield return null;
}
foreach (var r in renderers) {
if (r) {
r.material = originalMaterials[r];
}
}
Destroy(this);
}
示例2: DrawProteinsAtoms
public static void DrawProteinsAtoms(Material renderProteinsMaterial, Camera camera, RenderBuffer instanceId, RenderBuffer atomId, RenderBuffer depthBuffer, int pass)
{
// Protein params
renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(GlobalProperties.Get.EnableLod));
renderProteinsMaterial.SetFloat("_Scale", GlobalProperties.Get.Scale);
renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", GlobalProperties.Get.FirstLevelOffset);
renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);
renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Get.LodInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Get.ProteinInstancesInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Get.ProteinInstancePositions);
renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Get.ProteinInstanceRotations);
renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Get.IngredientsColors);
renderProteinsMaterial.SetBuffer("_ProteinAtomInfo", GPUBuffers.Get.ProteinAtomInfo);
renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Get.ProteinAtoms);
renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Get.ProteinAtomClusters);
renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Get.SphereBatches);
/****/
renderProteinsMaterial.SetInt("_NumCutObjects", SceneManager.Get.NumCutObjects);
renderProteinsMaterial.SetInt("_NumIngredientTypes", SceneManager.Get.NumAllIngredients);
renderProteinsMaterial.SetBuffer("_CutInfos", GPUBuffers.Get.CutInfo);
renderProteinsMaterial.SetBuffer("_CutScales", GPUBuffers.Get.CutScales);
renderProteinsMaterial.SetBuffer("_CutPositions", GPUBuffers.Get.CutPositions);
renderProteinsMaterial.SetBuffer("_CutRotations", GPUBuffers.Get.CutRotations);
/****/
Graphics.SetRenderTarget(new[] { instanceId, atomId }, depthBuffer);
renderProteinsMaterial.SetPass(1);
Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Get.ArgBuffer);
}
示例3: Awake
// Use this for initialization
void Awake()
{
//Initalize render textures
m_inputRenderTex = new RenderTexture(m_shadowSize, m_shadowSize, 0, RenderTextureFormat.ARGB32);
m_middleRenderTex = new RenderTexture(m_shadowSize, 1, 0, RenderTextureFormat.ARGB32);
//Initialize light material
m_lightMaterial = new Material(Shader.Find("2DLighting/Deferred_Point_2"));
m_lightMaterial.SetTexture("_DepthMap", m_middleRenderTex);
m_lightMaterial.SetInt("_Penumbra", m_penumbra ? 1 : 0);
m_lightMaterial.SetInt("_GradientFalloff", m_gradientFalloff ? 1 : 0);
//Initialize phase one material
phaseOneMaterial = new Material(Shader.Find("2DLighting/Deferred_Point_1"));
phaseOneMaterial.SetFloat("_DistanceModifier", 0.001f);
//Aquire camera component and initialize it
m_camera = GetComponent<Camera>();
m_camera.enabled = true;
m_camera.targetTexture = m_inputRenderTex;
//Create culling mask from given occluder layers
int occluders = 0;
for (int i = 0; i < m_occluderLayers.Count; i++)
{
occluders = occluders | (1 << LayerMask.NameToLayer(m_occluderLayers[i]));
}
m_camera.cullingMask = occluders;
//Assign mesh material
m_meshRenderer.material = m_lightMaterial;
}
示例4: CreateLineMaterial
public static void CreateLineMaterial(int iMat = 1)
{
Material mMat = lineMaterial1;
if (iMat == 2) mMat = lineMaterial2;
if (iMat == 3) mMat = lineMaterial3;
if (iMat == 4) mMat = lineMaterial4;
if (iMat == 5) mMat = lineMaterial5;
if (mMat == null)
{
var shader = Shader.Find("Hidden/Internal-Colored");
mMat = new Material(shader);
mMat.hideFlags = HideFlags.HideAndDontSave;
// Turn on alpha blending
mMat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
mMat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
// Turn backface culling off
mMat.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
// Turn off depth writes
mMat.SetInt("_ZWrite", 0);
if (iMat == 1) lineMaterial1 = mMat;
if (iMat == 2) lineMaterial2 = mMat;
if (iMat == 3) lineMaterial3 = mMat;
if (iMat == 4) lineMaterial4 = mMat;
if (iMat == 5) lineMaterial5 = mMat;
}
}
示例5: CloneMaterial
public override Material CloneMaterial(Material src, int nth)
{
Material m = new Material(src);
m.SetInt("g_batch_begin", nth * m_instances_par_batch);
m.SetBuffer("particles", m_world.GetParticleBuffer());
if (m_hdr)
{
m.SetInt("_SrcBlend", (int)BlendMode.One);
m.SetInt("_DstBlend", (int)BlendMode.One);
}
else
{
m.SetInt("_SrcBlend", (int)BlendMode.DstColor);
m.SetInt("_DstBlend", (int)BlendMode.Zero);
}
if(m_enable_shadow)
{
m.EnableKeyword("ENABLE_SHADOW");
switch (m_sample)
{
case Sample.Fast:
m.EnableKeyword("QUALITY_FAST");
break;
case Sample.Medium:
m.EnableKeyword("QUALITY_MEDIUM");
break;
case Sample.High:
m.EnableKeyword("QUALITY_HIGH");
break;
}
}
return m;
}
示例6: CloneMaterial
public override Material CloneMaterial(Material src, int nth)
{
var instance_texture = m_world.GetInstanceTexture();
Material m = new Material(src);
m.SetInt("g_batch_begin", nth * m_instances_par_batch);
m.SetTexture("g_instance_data", instance_texture);
Vector4 ts = new Vector4(
1.0f / instance_texture.width,
1.0f / instance_texture.height,
instance_texture.width,
instance_texture.height);
m.SetVector("g_instance_data_size", ts);
if (m_hdr)
{
m.SetInt("_SrcBlend", (int)BlendMode.One);
m.SetInt("_DstBlend", (int)BlendMode.One);
}
else
{
m.SetInt("_SrcBlend", (int)BlendMode.DstColor);
m.SetInt("_DstBlend", (int)BlendMode.Zero);
}
if (m_enable_shadow)
{
m.EnableKeyword("ENABLE_SHADOW");
switch (m_sample)
{
case Sample.Fast:
m.EnableKeyword ("QUALITY_FAST");
m.DisableKeyword("QUALITY_MEDIUM");
m.DisableKeyword("QUALITY_HIGH");
break;
case Sample.Medium:
m.DisableKeyword("QUALITY_FAST");
m.EnableKeyword ("QUALITY_MEDIUM");
m.DisableKeyword("QUALITY_HIGH");
break;
case Sample.High:
m.DisableKeyword("QUALITY_FAST");
m.DisableKeyword("QUALITY_MEDIUM");
m.EnableKeyword ("QUALITY_HIGH");
break;
}
}
else
{
m.DisableKeyword("ENABLE_SHADOW");
}
return m;
}
示例7: SetOpaque
public static void SetOpaque(Material material)
{
material.SetOverrideTag("RenderType", "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
}
示例8: Transparent
void Transparent(Material material)
{
material.SetFloat("_Mode", 3);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
}
示例9: setMaterialToFade
private void setMaterialToFade(Material m)
{
m.SetFloat("_Mode", 2);
m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
m.SetInt("_ZWrite", 0);
m.DisableKeyword("_ALPHATEST_ON");
m.EnableKeyword("_ALPHABLEND_ON");
m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
m.renderQueue = 3000;
}
示例10: setMaterialToOpaque
private void setMaterialToOpaque(Material m)
{
m.SetFloat("_Mode", 0);
m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
m.SetInt("_ZWrite", 1);
m.DisableKeyword("_ALPHATEST_ON");
m.DisableKeyword("_ALPHABLEND_ON");
m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
m.renderQueue = m.shader.renderQueue;
}
示例11: SetTransparent
public static void SetTransparent(Material material)
{
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
}
示例12: Opaque
void Opaque(Material material)
{
material.SetFloat("_Mode", 0);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
}
示例13: ApplyOpaque
public void ApplyOpaque(Color col)
{
rend = this.gameObject.GetComponent<Renderer>().material;
rend.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
rend.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
rend.SetInt("_ZWrite", 1);
rend.DisableKeyword("_ALPHATEST_ON");
rend.DisableKeyword("_ALPHABLEND_ON");
rend.DisableKeyword("_ALPHAPREMULTIPLY_ON");
rend.renderQueue = -1;
StartCoroutine(colorLerp1(rend.GetColor("_Color"), col));
}
示例14: CreateMaterial
void CreateMaterial()
{
var shader = Shader.Find("Hidden/Internal-Colored");
mat = new Material(shader);
mat.hideFlags = HideFlags.HideAndDontSave;
mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusDstColor);
mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
// Turn off backface culling, depth writes, depth test.
mat.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
mat.SetInt("_ZWrite", 0);
mat.SetInt("_ZTest", (int)UnityEngine.Rendering.CompareFunction.Always);
}
示例15: Start
void Start()
{
Material m = new Material(Shader.Find("Custom/StandardDepthBuffer"));
m.SetFloat("_Mode", 2);
m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
m.SetInt("_ZWrite", 0);
m.DisableKeyword("_ALPHATEST_ON");
m.EnableKeyword("_ALPHABLEND_ON");
m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
m.renderQueue = 3000;
}