Much better color format for render textures
This commit is contained in:
parent
25cfbf616a
commit
9149172db4
@ -31,6 +31,7 @@ public class WorldSwitcher : MonoBehaviour {
|
||||
int lastWorldIndex;
|
||||
int currentWorldIndex;
|
||||
Coroutine transition;
|
||||
bool supportHDR;
|
||||
|
||||
static readonly int UVOffset = Shader.PropertyToID("_UVOffset");
|
||||
//static readonly int Opacity = Shader.PropertyToID("_Opacity");
|
||||
@ -46,10 +47,12 @@ public class WorldSwitcher : MonoBehaviour {
|
||||
currentWorldIndex = 1;
|
||||
lastWorldIndex = 0;
|
||||
|
||||
supportHDR = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.DefaultHDR);
|
||||
|
||||
for (int i = 0; i < worldInfos.Length; i++) {
|
||||
worldInfos[i].material = worldInfos[i].renderQuad.GetComponent<Renderer>().material;
|
||||
|
||||
worldInfos[i].GenerateRenderTexture(quadOffset);
|
||||
worldInfos[i].GenerateRenderTexture(quadOffset, supportHDR);
|
||||
}
|
||||
|
||||
ResetQuadPositions();
|
||||
@ -65,7 +68,7 @@ public class WorldSwitcher : MonoBehaviour {
|
||||
//TODO Block window resize during transition?
|
||||
foreach (WorldInfo worldInfo in worldInfos) {
|
||||
if (Screen.width != worldInfo.texture.width || Screen.height != worldInfo.texture.height)
|
||||
worldInfo.GenerateRenderTexture(quadOffset);
|
||||
worldInfo.GenerateRenderTexture(quadOffset, supportHDR);
|
||||
}
|
||||
|
||||
lastWorldIndex = currentWorldIndex;
|
||||
@ -228,7 +231,7 @@ struct WorldInfo {
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateRenderTexture(float quadOffset) {
|
||||
public void GenerateRenderTexture(float quadOffset, bool supportHDR) {
|
||||
bool usingTexture = !ReferenceEquals(camera.targetTexture, null);
|
||||
if (usingTexture)
|
||||
camera.targetTexture = null;
|
||||
@ -236,6 +239,8 @@ struct WorldInfo {
|
||||
float height = 2f * Mathf.Tan(Mathf.Deg2Rad * camera.fieldOfView / 2f) * quadOffset;
|
||||
renderQuad.localScale = new Vector3(camera.aspect * height, height, 1f);
|
||||
texture = new RenderTexture(Screen.width, Screen.height, 32);
|
||||
if (supportHDR)
|
||||
texture.format = RenderTextureFormat.DefaultHDR;
|
||||
material.SetTexture(CameraTexture, texture);
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user