hi, can anyone explain what does OnRenderImage, OnPostRender and OnPreRender.
i have read the documentation but still don’t understand:(
my goal is create image effects, modify pixel colors, lighting effects, radiosity ![]()
bye
hi, can anyone explain what does OnRenderImage, OnPostRender and OnPreRender.
i have read the documentation but still don’t understand:(
my goal is create image effects, modify pixel colors, lighting effects, radiosity ![]()
bye
Unity Documentation is very clear about this
If you still dont understand, please be more specific
Hi, for example, on pre render, “is called before a camera starts rendering the scene” , it means that it works like a Start() function? or make an infinite loop with onpre,onrender and onpost (in order) ?
The camera renders the scene once every frame.
–Eric
Well, cameras re-render every frame, so I would say it is a “per frame” function. For example, if you want to do something after a camera has rendered as well as all the gui element you need to use the “WaitUntilEndOfFrame” co-routine (the docs also mention this). I remember this from doing a project where we had to “scan” a shap and project it onto a flat plane. Here is the part I used to do that. Note the part where I had to render the camera.
public void takePics()
{
GameObject curObject = GameObject.FindGameObjectWithTag("renderer");
Renderer r = curObject.GetComponentInChildren<Renderer>();
string[] temp = curObject.transform.parent.name.Split('_');
int tempNr = int.Parse(temp[1].Trim());
r.material.mainTexture = shapes[tempNr-1];
int a = 0;
foreach (GameObject go in GameObject.FindGameObjectsWithTag("picCam"))
{
Camera cam = go.GetComponent<Camera>();
resWidth = (int)cam.pixelWidth;
resHeight = (int)cam.pixelHeight;
cam.Render();
Texture2D screenShot = new Texture2D(resWidth, resHeight, TextureFormat.RGB24, false);
screenShot.ReadPixels(new Rect(cam.pixelRect), 0, 0);
screenShot.name = a.ToString();
screenShot.Apply();
images[a] = screenShot;
a++;
}
name = 0;
r.material.mainTexture = green_shape;
}