Pull request #17: Locking render textures to current dimension layer

Merge in CEGJ/creative-jam-20 from jason to main

* commit 'f6fd5798b2b2da1683929c9ef5ba84ff7134adf1':
  Locking render textures to current dimension layer
This commit is contained in:
Jason Durand 01 2022-05-15 15:09:51 +00:00
commit b40f860650
2 changed files with 3108 additions and 18395 deletions

File diff suppressed because it is too large Load Diff

View File

@ -108,10 +108,11 @@ public class WorldSwitcher : MonoBehaviour {
void ResetQuadPositions() {
Camera currCam = worldInfos[currentWorldIndex].camera;
LayerMask currLayer = worldInfos[currentWorldIndex].layer;
for (int i = 0; i < worldInfos.Length; ++i) {
bool usingRenderTexture = i != currentWorldIndex;
worldInfos[i].SetUsingRenderTexture(usingRenderTexture);
worldInfos[i].SetUsingRenderTexture(usingRenderTexture, currLayer);
if (usingRenderTexture) {
bool fromRight = i - currentWorldIndex > 0;
@ -128,12 +129,14 @@ struct WorldInfo {
[HideInInspector] public RenderTexture texture;
public Transform renderQuad;
[HideInInspector] public Material material;
public int layer;
static readonly int CameraTexture = Shader.PropertyToID("_CameraTexture");
public void SetUsingRenderTexture(bool usingTexture) {
public void SetUsingRenderTexture(bool usingTexture, int layer) {
if (usingTexture) {
camera.targetTexture = texture;
renderQuad.gameObject.SetActive(true);
renderQuad.gameObject.layer = layer;
}else {
camera.targetTexture = null;
renderQuad.gameObject.SetActive(false);
@ -145,8 +148,8 @@ struct WorldInfo {
if (usingTexture)
camera.targetTexture = null;
//float height = 2f * Mathf.Atan(Mathf.Deg2Rad * camera.fieldOfView) * quadOffset;
renderQuad.localScale = new Vector3(camera.aspect, 1f, 1f);
float height = 2f * Mathf.Atan(Mathf.Deg2Rad * camera.fieldOfView) * quadOffset;
renderQuad.localScale = new Vector3(camera.aspect * height, height, 1f);
texture = new RenderTexture(Screen.width, Screen.height, 32);
material.SetTexture(CameraTexture, texture);