本文整理汇总了C#中UnityEngine.Material.SetPass方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetPass方法的具体用法?C# Material.SetPass怎么用?C# Material.SetPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.SetPass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawAnswers
public static void DrawAnswers(List<Bar> bars, Material material)
{
if(bars.Count == 0) return;
// Draw bar chart.
GL.PushMatrix();
material.SetPass(0);
GL.LoadOrtho();
// Draw arrows.
GL.Begin(GL.LINES);
foreach(Bar bar in bars){
double barY = System.Math.Min(100.0, bar.y + 0.5);
Vector3 origin = ConvertToPixel(bar.x, barY);
Vector3 end = ConvertToPixel(System.Math.Max(barY, m_minX), barY);
if(System.Math.Abs(bar.x - barY) <= Answer.CLOSE_ENOUGH) continue;
int arrowSign = System.Math.Sign(end.x - origin.x);
GL.Color(arrowSign > 0 ? Color.cyan : Color.magenta);
GLVertex(origin);
GL.Color(Color.yellow);
GLVertex(end);
GLVertex(end + new Vector3(-arrowSign * 10f / Screen.width, 10f / (float)Screen.height, 0f));
GLVertex(end);
GLVertex(end + new Vector3(-arrowSign * 10f / Screen.width, -10f / (float)Screen.height, 0f));
GLVertex(end);
}
GL.End();
DrawAxis(bars);
GL.PopMatrix();
}
示例2: Render
public void Render(Material mat, int pass = 0)
{
Graphics.SetRenderTarget(ColorBuffers, DepthBuffer);
GL.PushMatrix();
mat.SetPass(pass);
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.TexCoord(new Vector3(0, 0, 0));
GL.Vertex3(0, 0, 0);
GL.TexCoord(new Vector3(1, 0, 0));
GL.Vertex3(1, 0, 0);
GL.TexCoord(new Vector3(1, 1, 0));
GL.Vertex3(1, 1, 0);
GL.TexCoord(new Vector3(0, 1, 0));
GL.Vertex3(0, 1, 0);
GL.End();
GL.PopMatrix();
}
示例3: DrawLine
public static void DrawLine(Vector3 pointA, Vector3 pointB, float width, Material material)
{
material.SetPass(0);
GL.Begin(GL.QUADS);
float halfLineWidth = width * 0.5f;
Vector3 normal = -Camera.main.transform.forward;
Vector3 side = Vector3.Cross(normal, pointB-pointA);
side.Normalize();
Vector3 a = pointA + side * halfLineWidth;
Vector3 b = pointA - side * halfLineWidth;
Vector3 c = pointB + side * halfLineWidth;
Vector3 d = pointB - side * halfLineWidth;
GL.TexCoord2(0.0f, 0.0f);
GL.Vertex(a);
GL.TexCoord2(0.0f, 1.0f);
GL.Vertex(b);
GL.TexCoord2(1.0f, 1.0f);
GL.Vertex(d);
GL.TexCoord2(1.0f, 0.0f);
GL.Vertex(c);
GL.End();
}
示例4: MultiTargetBlit
/// <summary>
/// Renders into a array of render textures using multi-target blit.
/// Up to 4 render targets are supported in Unity but some GPU's can
/// support up to 8 so this may change in the future. You MUST set up
/// the materials shader correctly for multitarget blit for this to work.
/// </summary>
/// <param name="des">The destination render textures.</param>
/// <param name="mat">The amterial to use</param>
/// <param name="pass">Which pass of the materials shader to use.</param>
public static void MultiTargetBlit(RenderTexture[] des, Material mat, int pass = 0)
{
RenderBuffer[] rb = new RenderBuffer[des.Length];
// Set targets needs the color buffers so make a array from
// each textures buffer.
for(int i = 0; i < des.Length; i++)
rb[i] = des[i].colorBuffer;
//Set the targets to render into.
//Will use the depth buffer of the
//first render texture provided.
Graphics.SetRenderTarget(rb, des[0].depthBuffer);
GL.Clear(true, true, Color.clear);
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass(pass);
GL.Begin(GL.QUADS);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(0.0f, 0.0f, 0.1f);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1.0f, 0.0f, 0.1f);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1.0f, 1.0f, 0.1f);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(0.0f, 1.0f, 0.1f);
GL.End();
GL.PopMatrix();
}
示例5: RectLighting
void RectLighting(MeshFilter obj,Material exMat)
{
Mesh ms = obj.sharedMesh;
Transform tr = obj.transform;
exMat.SetPass(0);
Graphics.DrawMeshNow(ms, tr.localToWorldMatrix);
}
示例6: 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);
}
示例7: DrawFullScreenQuad
/// <summary>
/// Draws a full-screen rectangle with the given material.
/// </summary>
/// <param name="material">The material to render to the quad.</param>
/// <param name="rect">An optional rectangle region of the screen to render to.</param>
public static void DrawFullScreenQuad(Material material, Rect? rect = null)
{
if (rect == null)
rect = new Rect (0, 0, 1, 1);
Rect r = rect.Value;
GL.PushMatrix();
GL.LoadOrtho();
for (int i = 0; i < material.passCount; ++i)
{
material.SetPass(i);
GL.Begin(GL.QUADS);
GL.Color(Color.white);
GL.TexCoord2(0, 0);
GL.Vertex3(r.xMin, r.yMin, 0.1f);
GL.TexCoord2(1, 0);
GL.Vertex3(r.xMax, r.yMin, 0.1f);
GL.TexCoord2(1, 1);
GL.Vertex3(r.xMax, r.yMax, 0.1f);
GL.TexCoord2(0, 1);
GL.Vertex3(r.xMin, r.yMax, 0.1f);
GL.End();
}
GL.PopMatrix();
}
示例8: Blit
// static public void Blit(RenderTexture src, RenderTexture des, Material mat, int pass = 0, bool clear = true)
static public void Blit(RenderTexture src, RenderTexture des, Material mat, int pass, bool clear)
{
mat.SetTexture("_MainTex", src);
RenderTexture oldRT = RenderTexture.active;
Graphics.SetRenderTarget(des);
if(clear) GL.Clear(true, true, Color.clear);
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass(pass);
GL.Begin(GL.QUADS);
GL.TexCoord3(0.0f, 0.0f, 0.0f); GL.Vertex3(0.0f, 0.0f, 0.1f);
GL.TexCoord3(1.0f, 0.0f, 0.0f); GL.Vertex3(1.0f, 0.0f, 0.1f);
GL.TexCoord3(1.0f, 1.0f, 0.0f); GL.Vertex3(1.0f, 1.0f, 0.1f);
GL.TexCoord3(0.0f, 1.0f, 0.0f); GL.Vertex3(0.0f, 1.0f, 0.1f);
GL.End();
GL.PopMatrix();
RenderTexture.active = oldRT;
}
示例9: CustomGraphicsBlit
static void CustomGraphicsBlit(RenderTexture source, RenderTexture dest, Material fxMaterial, int passNr)
{
RenderTexture.active = dest;
fxMaterial.SetTexture ("_MainTex", source);
GL.PushMatrix ();
GL.LoadOrtho ();
fxMaterial.SetPass (passNr);
GL.Begin (GL.QUADS);
GL.MultiTexCoord2 (0, 0.0f, 0.0f);
GL.Vertex3 (0.0f, 0.0f, 3.0f); // BL
GL.MultiTexCoord2 (0, 1.0f, 0.0f);
GL.Vertex3 (1.0f, 0.0f, 2.0f); // BR
GL.MultiTexCoord2 (0, 1.0f, 1.0f);
GL.Vertex3 (1.0f, 1.0f, 1.0f); // TR
GL.MultiTexCoord2 (0, 0.0f, 1.0f);
GL.Vertex3 (0.0f, 1.0f, 0.0f); // TL
GL.End ();
GL.PopMatrix ();
}
示例10: BoxDrawing
/// <summary>
///
/// </summary>
/// <param name="lineMaterial"></param>
/// <param name="color"></param>
/// <param name="source"></param>
/// <param name="destination"></param>
public static void BoxDrawing(Material lineMaterial, Color color, float width, float height, Vector3 position)
{
lineMaterial.SetColor("_TintColor", color);
lineMaterial.SetPass(0);
GL.Begin(GL.LINES);
// upper width line
GL.Vertex3(position.x - width / 2, position.y, position.z + height / 2);
GL.Vertex3(position.x + width / 2, position.y, position.z + height / 2);
// right height line
GL.Vertex3(position.x + width / 2, position.y, position.z + height / 2);
GL.Vertex3(position.x + width / 2, position.y, position.z - height / 2);
// lower width line
GL.Vertex3(position.x + width / 2, position.y, position.z - height / 2);
GL.Vertex3(position.x - width / 2, position.y, position.z - height / 2);
//height lines
GL.Vertex3(position.x - width / 2, position.y, position.z - height / 2);
GL.Vertex3(position.x - width / 2, position.y, position.z + height / 2);
GL.End();
}
示例11: DrawProteinSphereBatches
public static void DrawProteinSphereBatches(Material renderProteinsMaterial, Camera camera, RenderBuffer colorBuffer, RenderBuffer depthBuffer, int pass, bool animated = false)
{
// Protein params
renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(PersistantSettings.Instance.EnableLod));
renderProteinsMaterial.SetFloat("_Scale", PersistantSettings.Instance.Scale);
renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", PersistantSettings.Instance.FirstLevelOffset);
renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);
renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Instance.LodInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Instance.ProteinInstanceInfo);
if(animated) renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinAnimationPositions);
else renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinInstancePositions);
if (animated) renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinAnimationRotations);
else renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinInstanceRotations);
renderProteinsMaterial.SetBuffer("_ProteinAtomCount", GPUBuffers.Instance.ProteinAtomCount);
renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Instance.ProteinColors);
renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Instance.ProteinAtoms);
renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Instance.ProteinAtomClusters);
renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Instance.SphereBatches);
Graphics.SetRenderTarget(colorBuffer, depthBuffer);
renderProteinsMaterial.SetPass(pass);
Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Instance.ArgBuffer);
}
示例12: Blit
public static void Blit(RenderTexture dest, Material fxMaterial, int passNr)
{
Graphics.SetRenderTarget(dest);
GL.PushMatrix ();
GL.LoadOrtho ();
fxMaterial.SetPass(passNr);
GL.Begin (GL.QUADS);
GL.MultiTexCoord2 (0, 0.0f, 0.0f);
GL.Vertex3 (0.0f, 0.0f, 0.0f); // BL
GL.MultiTexCoord2 (0, 1.0f, 0.0f);
GL.Vertex3 (1.0f, 0.0f, 0.0f); // BR
GL.MultiTexCoord2 (0, 1.0f, 1.0f);
GL.Vertex3 (1.0f, 1.0f, 0.0f); // TR
GL.MultiTexCoord2 (0, 0.0f, 1.0f);
GL.Vertex3 (0.0f, 1.0f, 0.0f); // TL
GL.End ();
GL.PopMatrix ();
}
示例13: CustomGraphicsBlit
void CustomGraphicsBlit(RenderTexture source, RenderTexture dest, Material mat, int pass)
{
RenderTexture.active = dest;
mat.SetTexture("_MainTex", source);
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass (pass);
GL.Begin (GL.QUADS);
//This custom blit is needed as information about what corner verts relate to what frustum corners is needed
//A index to the frustum corner is store in the z pos of vert
GL.MultiTexCoord2(0, 0.0f, 0.0f);
GL.Vertex3(0.0f, 0.0f, 3.0f); // BL
GL.MultiTexCoord2(0, 1.0f, 0.0f);
GL.Vertex3(1.0f, 0.0f, 2.0f); // BR
GL.MultiTexCoord2(0, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f); // TR
GL.MultiTexCoord2(0, 0.0f, 1.0f);
GL.Vertex3(0.0f, 1.0f, 0.0f); // TL
GL.End();
GL.PopMatrix();
}
示例14: CustomGraphicsBlit
static void CustomGraphicsBlit(RenderTexture src, RenderTexture dst, Material mat, int pass)
{
RenderTexture.active = dst;
mat.SetTexture("_MainTex", src);
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass(pass);
GL.Begin(GL.QUADS);
GL.MultiTexCoord2(0, 0.0f, 0.0f);
GL.Vertex3(0.0f, 0.0f, 3.0f); // BL
GL.MultiTexCoord2(0, 1.0f, 0.0f);
GL.Vertex3(1.0f, 0.0f, 2.0f); // BR
GL.MultiTexCoord2(0, 1.0f, 1.0f);
GL.Vertex3(1.0f, 1.0f, 1.0f); // TR
GL.MultiTexCoord2(0, 0.0f, 1.0f);
GL.Vertex3(0.0f, 1.0f, 0.0f); // TL
GL.End();
GL.PopMatrix();
}
示例15: PaintTexture
void PaintTexture(RenderTexture _canvas, Material _brush, float _size, float _posX, float _posY)
{
Debug.Log (string.Format("_size = {0}, _posX = {1}, _posY = {2}",_size,_posX,_posY));
float halfSize = _size / 2F;
_canvas.MarkRestoreExpected ();
Graphics.SetRenderTarget(_canvas);
GL.PushMatrix();
_brush.SetPass (0);
GL.LoadOrtho();
GL.Begin(GL.QUADS);
GL.TexCoord(new Vector3(0, 0, 0));
GL.Vertex3(_posX - halfSize, _posY - halfSize, 0);
GL.TexCoord(new Vector3(0, 1, 0));
GL.Vertex3(_posX - halfSize, _posY + halfSize, 0);
GL.TexCoord(new Vector3(1, 1, 0));
GL.Vertex3(_posX + halfSize, _posY + halfSize, 0);
GL.TexCoord(new Vector3(1, 0, 0));
GL.Vertex3(_posX + halfSize, _posY - halfSize, 0);
GL.End();
GL.PopMatrix();
Graphics.SetRenderTarget(null);
}