小编Col*_*ker的帖子

如何与C#统一进行实时光线跟踪

我正在制作一个统一的视频游戏,并决定使用光线跟踪.我有代码,但正如你将在一秒钟内看到的那样.它不是一帧一帧地渲染.这是我的光线跟踪代码,这是附加到主摄像头的主要脚本.

using UnityEngine;
using System.Collections;

public class RayTracer : MonoBehaviour
{

    public Color backgroundColor = Color.black;
    public float RenderResolution = 1f;
    public float maxDist = 100f;
    public int maxRecursion = 4;


    private Light[] lights;
    private Texture2D renderTexture;

    void Awake()
    {
        renderTexture = new Texture2D((int)(Screen.width * RenderResolution), (int)(Screen.height * RenderResolution));
        lights = FindObjectsOfType(typeof(Light)) as Light[];
    }

    void Start()
    {
        RayTrace();
    }

    void OnGUI()
    {
        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), renderTexture);
    }

    void RayTrace()
    {
        for (int x = 0; x < …
Run Code Online (Sandbox Code Playgroud)

c# raytracing unity-game-engine

1
推荐指数
1
解决办法
9493
查看次数

标签 统计

c# ×1

raytracing ×1

unity-game-engine ×1