You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
940 B
42 lines
940 B
11 months ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Unity.VisualScripting;
|
||
|
using UnityEngine;
|
||
|
|
||
|
[ExecuteInEditMode]
|
||
|
public class CubemapRender : MonoBehaviour
|
||
|
{
|
||
|
public RenderTexture cubeMap4K;
|
||
|
public RenderTexture cubeMap1K;
|
||
|
public Material mat;
|
||
|
[Header("4K Rendering")]
|
||
|
public bool m_4k = false;
|
||
|
int faceMask = 63;
|
||
|
Camera cam;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
cam = GetComponent<Camera>();
|
||
|
}
|
||
|
|
||
|
void Update()
|
||
|
{
|
||
|
if (cubeMap1K != null && cubeMap4K != null)
|
||
|
{
|
||
|
// Render the scene to the cubemap
|
||
|
if (m_4k)
|
||
|
{
|
||
|
cam.RenderToCubemap(cubeMap4K, faceMask);
|
||
|
mat.SetTexture("_MainTex", cubeMap4K);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
mat.SetTexture("_MainTex", cubeMap1K);
|
||
|
cam.RenderToCubemap(cubeMap1K, faceMask);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|