Skip to content

Instantly share code, notes, and snippets.

@cslroot
Last active September 21, 2015 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cslroot/c66ebadf2ad3651bcab3 to your computer and use it in GitHub Desktop.
Save cslroot/c66ebadf2ad3651bcab3 to your computer and use it in GitHub Desktop.
Unity Ray Tracing 0
using UnityEngine;
using System.Collections;
public class RayTracer : MonoBehaviour {
private Texture2D myCanvas;
// Use this for initialization
void Start () {
myCanvas = new Texture2D(Screen.width, Screen.height); // ゲーム実行時のスクリーンサイズと同じにしておく
Rendering();
}
// Update is called once per frame
void Update () {
}
void Rendering()
{
Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 1.0f);
for (int h = 0; h < myCanvas.height; h++) {
for (int w = 0; w < myCanvas.width; w++) {
Color c = backgroundColor;
myCanvas.SetPixel(w, h, c);
}
}
myCanvas.Apply();
}
void OnGUI() {
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), myCanvas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment