Setup a matrix for pixel-correct rendering.
// Draws a red triangle using pixels as coordinates to paint on. var mat : Material; function OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(0); GL.LoadPixelMatrix(); GL.Color(Color.red); GL.Begin(GL.TRIANGLES); GL.Vertex3(0,0,0); GL.Vertex3(0,Screen.height/2,0); GL.Vertex3(Screen.width/2,Screen.height/2,0); GL.End(); GL.PopMatrix(); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Material mat; void OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(0); GL.LoadPixelMatrix(); GL.Color(Color.red); GL.Begin(GL.TRIANGLES); GL.Vertex3(0, 0, 0); GL.Vertex3(0, Screen.height / 2, 0); GL.Vertex3(Screen.width / 2, Screen.height / 2, 0); GL.End(); GL.PopMatrix(); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public mat as Material def OnPostRender() as void: if not mat: Debug.LogError('Please Assign a material on the inspector') return GL.PushMatrix() mat.SetPass(0) GL.LoadPixelMatrix() GL.Color(Color.red) GL.Begin(GL.TRIANGLES) GL.Vertex3(0, 0, 0) GL.Vertex3(0, (Screen.height / 2), 0) GL.Vertex3((Screen.width / 2), (Screen.height / 2), 0) GL.End() GL.PopMatrix()
Setup a matrix for pixel-correct rendering.
var mat : Material; function OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(0); GL.LoadPixelMatrix(10,20,10,20); GL.Color(Color.red); GL.Begin(GL.TRIANGLES); GL.Vertex3(10,10,0); GL.Vertex3(10,20,0); GL.Vertex3(20,20,0); GL.End(); GL.PopMatrix(); }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Material mat; void OnPostRender() { if (!mat) { Debug.LogError("Please Assign a material on the inspector"); return; } GL.PushMatrix(); mat.SetPass(0); GL.LoadPixelMatrix(10, 20, 10, 20); GL.Color(Color.red); GL.Begin(GL.TRIANGLES); GL.Vertex3(10, 10, 0); GL.Vertex3(10, 20, 0); GL.Vertex3(20, 20, 0); GL.End(); GL.PopMatrix(); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public mat as Material def OnPostRender() as void: if not mat: Debug.LogError('Please Assign a material on the inspector') return GL.PushMatrix() mat.SetPass(0) GL.LoadPixelMatrix(10, 20, 10, 20) GL.Color(Color.red) GL.Begin(GL.TRIANGLES) GL.Vertex3(10, 10, 0) GL.Vertex3(10, 20, 0) GL.Vertex3(20, 20, 0) GL.End() GL.PopMatrix()