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